Skip to content

Commit

Permalink
Remove networking
Browse files Browse the repository at this point in the history
Requested by IThundxr, move to Quark later
  • Loading branch information
BrokenK3yboard committed Oct 1, 2024
1 parent 03d1f07 commit 018f3cd
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 779 deletions.
2 changes: 1 addition & 1 deletion dependencies.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
neoforge=21.1.63
neoforge=21.1.65
20 changes: 2 additions & 18 deletions src/main/java/org/violetmoon/zeta/Zeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,12 @@
import org.violetmoon.zeta.config.ConfigManager;
import org.violetmoon.zeta.config.IZetaConfigInternals;
import org.violetmoon.zeta.config.SectionDefinition;
import org.violetmoon.zeta.event.bus.IZetaLoadEvent;
import org.violetmoon.zeta.event.bus.IZetaPlayEvent;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.bus.PlayEvent;
import org.violetmoon.zeta.event.bus.ZetaEventBus;
import org.violetmoon.zeta.event.bus.*;
import org.violetmoon.zeta.item.ext.ItemExtensionFactory;
import org.violetmoon.zeta.module.ModuleFinder;
import org.violetmoon.zeta.module.ZetaCategory;
import org.violetmoon.zeta.module.ZetaModuleManager;
import org.violetmoon.zeta.network.ZetaNetworkHandler;
import org.violetmoon.zeta.registry.BrewingRegistry;
import org.violetmoon.zeta.registry.CraftingExtensionsRegistry;
import org.violetmoon.zeta.registry.DyeablesRegistry;
import org.violetmoon.zeta.registry.PottedPlantRegistry;
import org.violetmoon.zeta.registry.RenderLayerRegistry;
import org.violetmoon.zeta.registry.VariantRegistry;
import org.violetmoon.zeta.registry.ZetaRegistry;
import org.violetmoon.zeta.registry.*;
import org.violetmoon.zeta.util.NameChanger;
import org.violetmoon.zeta.util.RaytracingUtil;
import org.violetmoon.zeta.util.RegistryUtil;
Expand Down Expand Up @@ -123,9 +112,6 @@ public Zeta(String modid, Logger log, ZetaSide side) {
//config (which isn't set in the constructor b/c module loading has to happen first)
public ConfigManager configManager;
public IZetaConfigInternals configInternals;

//network (which isn't set in the constructor b/c it has a user-specified protocol version TODO this isnt good api design, imo)
public ZetaNetworkHandler network;

// worldgen
public EntitySpawnHandler entitySpawn;
Expand Down Expand Up @@ -198,8 +184,6 @@ public EntitySpawnHandler createEntitySpawnHandler() {
return new EntitySpawnHandler(this);
}

public abstract ZetaNetworkHandler createNetworkHandler(int protocolVersion);

// event bus
public abstract <E, T extends E> T fireExternalEvent(T impl);

Expand Down
27 changes: 8 additions & 19 deletions src/main/java/org/violetmoon/zeta/client/ZetaClient.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
package org.violetmoon.zeta.client;

import org.jetbrains.annotations.Nullable;
import org.violetmoon.zeta.Zeta;
import org.violetmoon.zeta.client.config.ClientConfigManager;
import org.violetmoon.zeta.event.bus.IZetaLoadEvent;
import org.violetmoon.zeta.event.bus.IZetaPlayEvent;
import org.violetmoon.zeta.event.bus.ZetaEventBus;
import org.violetmoon.zeta.network.IZetaMessage;
import org.violetmoon.zeta.util.zetalist.IZeta;
import org.violetmoon.zeta.util.zetalist.ZetaClientList;

import net.minecraft.client.Minecraft;
import net.minecraft.client.color.block.BlockColor;
import net.minecraft.client.color.block.BlockColors;
import net.minecraft.client.color.item.ItemColor;
Expand All @@ -21,6 +10,14 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.level.ItemLike;
import net.minecraft.world.level.block.Block;
import org.jetbrains.annotations.Nullable;
import org.violetmoon.zeta.Zeta;
import org.violetmoon.zeta.client.config.ClientConfigManager;
import org.violetmoon.zeta.event.bus.IZetaLoadEvent;
import org.violetmoon.zeta.event.bus.IZetaPlayEvent;
import org.violetmoon.zeta.event.bus.ZetaEventBus;
import org.violetmoon.zeta.util.zetalist.IZeta;
import org.violetmoon.zeta.util.zetalist.ZetaClientList;

public abstract class ZetaClient implements IZeta {
public ZetaClient(Zeta zeta) {
Expand Down Expand Up @@ -65,14 +62,6 @@ public TopLayerTooltipHandler createTopLayerTooltipHandler() {
return new TopLayerTooltipHandler();
}

//ummm ??
public void sendToServer(IZetaMessage msg) {
if(Minecraft.getInstance().getConnection() == null)
return;

zeta.network.sendToServer(msg);
}

//kinda a grab bag of stuff that needs to happen client-only; hmm, not the best design
public abstract ClientRegistryExtension createClientRegistryExtension();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
package org.violetmoon.zeta.client.config;

import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.violetmoon.zeta.client.ZetaClient;
import org.violetmoon.zeta.client.config.definition.BooleanClientDefinition;
import org.violetmoon.zeta.client.config.definition.ClientDefinitionExt;
import org.violetmoon.zeta.client.config.definition.DoubleClientDefinition;
import org.violetmoon.zeta.client.config.definition.IConfigDefinitionProvider;
import org.violetmoon.zeta.client.config.definition.IntegerClientDefinition;
import org.violetmoon.zeta.client.config.definition.SectionClientDefinition;
import org.violetmoon.zeta.client.config.definition.StringClientDefinition;
import org.violetmoon.zeta.client.config.definition.StringListClientDefinition;
import org.violetmoon.zeta.client.config.definition.*;
import org.violetmoon.zeta.config.Definition;
import org.violetmoon.zeta.config.SectionDefinition;
import org.violetmoon.zeta.config.ValueDefinition;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.load.ZConfigChanged;
import org.violetmoon.zeta.network.message.C2SUpdateFlag;

import net.minecraft.client.Minecraft;
import java.util.List;

public class ClientConfigManager {

Expand Down Expand Up @@ -56,11 +44,4 @@ else if(val.defaultValue instanceof List<?>)
//This cast is unsound, but Default never actually uses its argument, so it's fineeeeee, right
throw new IllegalArgumentException(def + " is not a legal config value");
}

@LoadEvent
public void configChanged(ZConfigChanged event) {
if(Minecraft.getInstance().getConnection() != null)
zc.sendToServer(C2SUpdateFlag.createPacket());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
import net.minecraft.server.level.ServerPlayer;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.load.ZConfigChanged;
import org.violetmoon.zeta.mod.ZetaMod;
import org.violetmoon.zeta.network.message.S2CUpdateFlag;

import java.util.*;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -61,11 +57,6 @@ public static void receiveFlagInfoFromPlayer(ServerPlayer player, BitSet bitSet)
public static void receiveFlagInfoFromServer(BitSet bitSet) {
flagsFromServer.put(Minecraft.getInstance().getConnection(), decodeFlags(bitSet));
}

@LoadEvent
public static void sendFlagInfoToPlayers(ZConfigChanged event) {
ZetaMod.ZETA.network.sendToPlayers(S2CUpdateFlag.createPacket(), flagsFromPlayers.keySet());
}

private static final WeakHashMap<PacketListener, Set<String>> flagsFromServer = new WeakHashMap<>();
private static final WeakHashMap<ServerPlayer, Set<String>> flagsFromPlayers = new WeakHashMap<>();
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/org/violetmoon/zeta/mod/ZetaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import net.neoforged.bus.api.IEventBus;
import org.violetmoon.zeta.Zeta;
import org.violetmoon.zeta.config.ZetaGeneralConfig;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.load.ZCommonSetup;
import org.violetmoon.zeta.network.ZetaModInternalNetwork;

public class ZetaMod {

Expand All @@ -18,9 +15,7 @@ public static void start(Zeta zeta, ZetaModProxy proxy, IEventBus bus) {

ZETA.start(bus);
ZETA.loadModules(null, null, ZetaGeneralConfig.INSTANCE);

ZetaModInternalNetwork.init();

proxy.registerEvents(zeta);
}

}
}
5 changes: 0 additions & 5 deletions src/main/java/org/violetmoon/zeta/network/IZetaMessage.java

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 018f3cd

Please sign in to comment.