diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java index 7eb3c021..f4420206 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityCamera.java @@ -4,6 +4,9 @@ import li.cil.oc.api.machine.Arguments; import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkPosition; import cpw.mods.fml.common.Optional; @@ -23,11 +26,12 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV private final static int REGISTRY_UPDATE_INTERVAL_TICKS = 15 * 20; private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20; + private int packetSendTicks = 10; private int registryUpdateTicks = 20; - private int packetSendTicks = 20; public TileEntityCamera() { super(); + peripheralName = "warpdriveCamera"; addMethods(new String[] { "videoChannel" @@ -140,6 +144,19 @@ public class TileEntityCamera extends TileEntityAbstractInterfaced implements IV } } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + NBTTagCompound tagCompound = packet.func_148857_g(); + readFromNBT(tagCompound); + } + // OpenComputer callback methods @Callback @Optional.Method(modid = "OpenComputers") diff --git a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java index c64c0151..98a7354a 100644 --- a/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/detection/TileEntityMonitor.java @@ -4,6 +4,9 @@ import li.cil.oc.api.machine.Arguments; import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.StatCollector; import cpw.mods.fml.common.Optional; import cr0s.warpdrive.WarpDrive; @@ -19,7 +22,7 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I private int videoChannel = -1; private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20; - private int packetSendTicks = 20; + private int packetSendTicks = 10; public TileEntityMonitor() { super(); @@ -103,6 +106,19 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I tag.setInteger("videoChannel", videoChannel); } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + writeToNBT(tagCompound); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + NBTTagCompound tagCompound = packet.func_148857_g(); + readFromNBT(tagCompound); + } + // OpenComputer callback methods @Callback @Optional.Method(modid = "OpenComputers") diff --git a/src/main/java/cr0s/warpdrive/block/energy/TileEntityIC2reactorLaserMonitor.java b/src/main/java/cr0s/warpdrive/block/energy/TileEntityIC2reactorLaserMonitor.java index 85236e96..ccd90cf9 100644 --- a/src/main/java/cr0s/warpdrive/block/energy/TileEntityIC2reactorLaserMonitor.java +++ b/src/main/java/cr0s/warpdrive/block/energy/TileEntityIC2reactorLaserMonitor.java @@ -180,8 +180,8 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy { @Override public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { - NBTTagCompound tag = packet.func_148857_g(); - readFromNBT(tag); + NBTTagCompound tagCompound = packet.func_148857_g(); + readFromNBT(tagCompound); } @Override diff --git a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java index 73788a57..30a7ba92 100644 --- a/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java +++ b/src/main/java/cr0s/warpdrive/block/weapon/TileEntityLaserCamera.java @@ -4,6 +4,9 @@ import li.cil.oc.api.machine.Arguments; import li.cil.oc.api.machine.Callback; import li.cil.oc.api.machine.Context; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.util.StatCollector; import net.minecraft.world.ChunkPosition; import cpw.mods.fml.common.Optional; @@ -23,8 +26,8 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan private final static int REGISTRY_UPDATE_INTERVAL_TICKS = 15 * 20; private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20; + private int packetSendTicks = 10; private int registryUpdateTicks = 20; - private int packetSendTicks = 20; public TileEntityLaserCamera() { super(); @@ -50,6 +53,9 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan registryUpdateTicks--; if (registryUpdateTicks <= 0) { registryUpdateTicks = REGISTRY_UPDATE_INTERVAL_TICKS; + if (WarpDriveConfig.LOGGING_VIDEO_CHANNEL) { + WarpDrive.logger.info(this + " Updating registry (" + videoChannel + ")"); + } WarpDrive.instance.cameras.updateInRegistry(worldObj, new ChunkPosition(xCoord, yCoord, zCoord), videoChannel, CameraType.LASER_CAMERA); } } @@ -115,6 +121,21 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan tag.setInteger("videoChannel", videoChannel); } + @Override + public Packet getDescriptionPacket() { + NBTTagCompound tagCompound = new NBTTagCompound(); + // (beam frequency is server side only) + tagCompound.setInteger("videoChannel", videoChannel); + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tagCompound); + } + + @Override + public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) { + NBTTagCompound tagCompound = packet.func_148857_g(); + // (beam frequency is server side only) + setVideoChannel(tagCompound.getInteger("videoChannel")); + } + @Override public void invalidate() { WarpDrive.instance.cameras.removeFromRegistry(worldObj, new ChunkPosition(xCoord, yCoord, zCoord));