1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-04-04 09:46:58 +00:00

Get us booting on a dedicated server

It doesn't appear that blocks are syncing, so we'll need to look into
that. Hopefully fixes #193
This commit is contained in:
SquidDev 2019-04-29 08:04:24 +01:00
parent e8d7e6a562
commit e6094a59fa
4 changed files with 12 additions and 8 deletions

View File

@ -36,6 +36,7 @@ import dan200.computercraft.shared.turtle.items.ItemTurtle;
import dan200.computercraft.shared.turtle.upgrades.*;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
@ -196,7 +197,7 @@ public final class ComputerCraft implements ModInitializer
public void onInitialize()
{
ComputerCraftProxyCommon.setup();
if( net.fabricmc.loader.api.FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT )
if( FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT )
{
ComputerCraftProxyClient.setup();
}

View File

@ -7,6 +7,7 @@
package dan200.computercraft.client.proxy;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.client.FrameInfo;
import dan200.computercraft.client.ClientRegistry;
import dan200.computercraft.client.gui.*;
import dan200.computercraft.client.render.TileEntityCableRenderer;
@ -24,6 +25,7 @@ import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.render.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
public final class ComputerCraftProxyClient
{
@ -42,6 +44,8 @@ public final class ComputerCraftProxyClient
ModelLoadingRegistry.INSTANCE.registerResourceProvider( loader -> ( name, context ) ->
TurtleModelLoader.INSTANCE.accepts( name ) ? TurtleModelLoader.INSTANCE.loadModel( name ) : null
);
ClientTickCallback.EVENT.register( client -> FrameInfo.onTick() );
}
private static void registerContainers()

View File

@ -17,6 +17,8 @@ import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
import net.fabricmc.fabric.api.network.PacketContext;
import net.fabricmc.fabric.api.network.ServerSidePacketRegistry;
import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.packet.CustomPayloadS2CPacket;
import net.minecraft.entity.player.PlayerEntity;
@ -45,8 +47,11 @@ public final class NetworkHandler
public static void setup()
{
ClientSidePacketRegistry.INSTANCE.register( ID, NetworkHandler::receive );
ServerSidePacketRegistry.INSTANCE.register( ID, NetworkHandler::receive );
if( FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT )
{
ClientSidePacketRegistry.INSTANCE.register( ID, NetworkHandler::receive );
}
// Server messages
registerMainThread( 0, ComputerActionServerMessage::new );

View File

@ -11,7 +11,6 @@ import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.api.media.IMedia;
import dan200.computercraft.api.peripheral.IPeripheralTile;
import dan200.computercraft.api.turtle.event.TurtleEvent;
import dan200.computercraft.client.FrameInfo;
import dan200.computercraft.core.computer.MainThread;
import dan200.computercraft.core.tracking.Tracking;
import dan200.computercraft.shared.Registry;
@ -35,7 +34,6 @@ import dan200.computercraft.shared.turtle.recipes.TurtleUpgradeRecipe;
import dan200.computercraft.shared.util.ImpostorRecipe;
import dan200.computercraft.shared.util.ImpostorShapelessRecipe;
import dan200.computercraft.shared.util.TickScheduler;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.fabricmc.fabric.api.event.server.ServerStartCallback;
import net.fabricmc.fabric.api.event.server.ServerStopCallback;
import net.fabricmc.fabric.api.event.server.ServerTickCallback;
@ -109,10 +107,6 @@ public class ComputerCraftProxyCommon
{
CommandRegistry.INSTANCE.register( false, CommandComputerCraft::register );
ClientTickCallback.EVENT.register( client -> {
FrameInfo.onTick();
} );
ServerTickCallback.EVENT.register( server -> {
MainThread.executePendingTasks();
ComputerCraft.serverComputerRegistry.update();