Improved video channel synchronisation
This commit is contained in:
parent
7c47ab1423
commit
0a3a780f21
4 changed files with 59 additions and 5 deletions
|
@ -4,6 +4,9 @@ import li.cil.oc.api.machine.Arguments;
|
||||||
import li.cil.oc.api.machine.Callback;
|
import li.cil.oc.api.machine.Callback;
|
||||||
import li.cil.oc.api.machine.Context;
|
import li.cil.oc.api.machine.Context;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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.util.StatCollector;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import cpw.mods.fml.common.Optional;
|
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 REGISTRY_UPDATE_INTERVAL_TICKS = 15 * 20;
|
||||||
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
|
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
|
||||||
|
|
||||||
|
private int packetSendTicks = 10;
|
||||||
private int registryUpdateTicks = 20;
|
private int registryUpdateTicks = 20;
|
||||||
private int packetSendTicks = 20;
|
|
||||||
|
|
||||||
public TileEntityCamera() {
|
public TileEntityCamera() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
peripheralName = "warpdriveCamera";
|
peripheralName = "warpdriveCamera";
|
||||||
addMethods(new String[] {
|
addMethods(new String[] {
|
||||||
"videoChannel"
|
"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
|
// OpenComputer callback methods
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
|
|
@ -4,6 +4,9 @@ import li.cil.oc.api.machine.Arguments;
|
||||||
import li.cil.oc.api.machine.Callback;
|
import li.cil.oc.api.machine.Callback;
|
||||||
import li.cil.oc.api.machine.Context;
|
import li.cil.oc.api.machine.Context;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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.util.StatCollector;
|
||||||
import cpw.mods.fml.common.Optional;
|
import cpw.mods.fml.common.Optional;
|
||||||
import cr0s.warpdrive.WarpDrive;
|
import cr0s.warpdrive.WarpDrive;
|
||||||
|
@ -19,7 +22,7 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I
|
||||||
private int videoChannel = -1;
|
private int videoChannel = -1;
|
||||||
|
|
||||||
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
|
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
|
||||||
private int packetSendTicks = 20;
|
private int packetSendTicks = 10;
|
||||||
|
|
||||||
public TileEntityMonitor() {
|
public TileEntityMonitor() {
|
||||||
super();
|
super();
|
||||||
|
@ -103,6 +106,19 @@ public class TileEntityMonitor extends TileEntityAbstractInterfaced implements I
|
||||||
tag.setInteger("videoChannel", videoChannel);
|
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
|
// OpenComputer callback methods
|
||||||
@Callback
|
@Callback
|
||||||
@Optional.Method(modid = "OpenComputers")
|
@Optional.Method(modid = "OpenComputers")
|
||||||
|
|
|
@ -180,8 +180,8 @@ public class TileEntityIC2reactorLaserMonitor extends TileEntityAbstractEnergy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) {
|
public void onDataPacket(NetworkManager networkManager, S35PacketUpdateTileEntity packet) {
|
||||||
NBTTagCompound tag = packet.func_148857_g();
|
NBTTagCompound tagCompound = packet.func_148857_g();
|
||||||
readFromNBT(tag);
|
readFromNBT(tagCompound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,6 +4,9 @@ import li.cil.oc.api.machine.Arguments;
|
||||||
import li.cil.oc.api.machine.Callback;
|
import li.cil.oc.api.machine.Callback;
|
||||||
import li.cil.oc.api.machine.Context;
|
import li.cil.oc.api.machine.Context;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
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.util.StatCollector;
|
||||||
import net.minecraft.world.ChunkPosition;
|
import net.minecraft.world.ChunkPosition;
|
||||||
import cpw.mods.fml.common.Optional;
|
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 REGISTRY_UPDATE_INTERVAL_TICKS = 15 * 20;
|
||||||
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
|
private final static int PACKET_SEND_INTERVAL_TICKS = 60 * 20;
|
||||||
|
|
||||||
|
private int packetSendTicks = 10;
|
||||||
private int registryUpdateTicks = 20;
|
private int registryUpdateTicks = 20;
|
||||||
private int packetSendTicks = 20;
|
|
||||||
|
|
||||||
public TileEntityLaserCamera() {
|
public TileEntityLaserCamera() {
|
||||||
super();
|
super();
|
||||||
|
@ -50,6 +53,9 @@ public class TileEntityLaserCamera extends TileEntityLaser implements IVideoChan
|
||||||
registryUpdateTicks--;
|
registryUpdateTicks--;
|
||||||
if (registryUpdateTicks <= 0) {
|
if (registryUpdateTicks <= 0) {
|
||||||
registryUpdateTicks = REGISTRY_UPDATE_INTERVAL_TICKS;
|
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);
|
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);
|
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
|
@Override
|
||||||
public void invalidate() {
|
public void invalidate() {
|
||||||
WarpDrive.instance.cameras.removeFromRegistry(worldObj, new ChunkPosition(xCoord, yCoord, zCoord));
|
WarpDrive.instance.cameras.removeFromRegistry(worldObj, new ChunkPosition(xCoord, yCoord, zCoord));
|
||||||
|
|
Loading…
Reference in a new issue