From 2c763c919946491361f0b8e046759e89fa9bc6d3 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 18 Oct 2015 15:28:06 +0200 Subject: [PATCH] Less stupid method of syncing changes to the client --- .../network/PacketHandler.java | 6 +- .../network/sync/IPacketSyncerToClient.java | 31 ------- .../network/sync/PacketSyncerToClient.java | 88 ------------------- .../tile/TileEntityBase.java | 28 +++++- .../tile/TileEntityBreaker.java | 8 +- .../tile/TileEntityCanolaPress.java | 34 ++----- .../tile/TileEntityCoalGenerator.java | 29 ++---- .../tile/TileEntityCoffeeMachine.java | 35 ++------ .../tile/TileEntityCompost.java | 8 +- .../tile/TileEntityDirectionalBreaker.java | 27 ++---- .../tile/TileEntityDropper.java | 8 +- .../tile/TileEntityEnergizer.java | 27 ++---- .../tile/TileEntityEnervator.java | 27 ++---- .../tile/TileEntityFeeder.java | 28 ++---- .../tile/TileEntityFermentingBarrel.java | 39 ++------ .../tile/TileEntityFishingNet.java | 5 +- .../tile/TileEntityFluidCollector.java | 32 ++----- .../tile/TileEntityFurnaceDouble.java | 29 ++---- .../tile/TileEntityFurnaceSolar.java | 6 +- .../tile/TileEntityGreenhouseGlass.java | 10 +++ .../tile/TileEntityGrinder.java | 29 ++---- .../tile/TileEntityHeatCollector.java | 11 +++ .../tile/TileEntityInputter.java | 34 ++----- .../tile/TileEntityInventoryBase.java | 42 ++++----- .../tile/TileEntityItemRepairer.java | 27 ++---- .../tile/TileEntityLavaFactoryController.java | 6 +- .../tile/TileEntityLeafGenerator.java | 6 +- .../tile/TileEntityOilGenerator.java | 34 ++----- .../tile/TileEntityOreMagnet.java | 33 ++----- .../tile/TileEntityPhantomBooster.java | 11 +++ .../tile/TileEntityPhantomPlacer.java | 8 +- .../tile/TileEntityPhantomface.java | 8 +- .../tile/TileEntityRangedCollector.java | 27 ++---- .../tile/TileEntitySmileyCloud.java | 42 +-------- .../tile/TileEntityXPSolidifier.java | 27 ++---- 35 files changed, 196 insertions(+), 654 deletions(-) delete mode 100644 src/main/java/ellpeck/actuallyadditions/network/sync/IPacketSyncerToClient.java delete mode 100644 src/main/java/ellpeck/actuallyadditions/network/sync/PacketSyncerToClient.java diff --git a/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java b/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java index ed03d2d3e..212089ff1 100644 --- a/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/network/PacketHandler.java @@ -16,7 +16,6 @@ import cpw.mods.fml.relauncher.Side; import ellpeck.actuallyadditions.network.gui.PacketGuiButton; import ellpeck.actuallyadditions.network.gui.PacketGuiNumber; import ellpeck.actuallyadditions.network.gui.PacketGuiString; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.ModUtil; public class PacketHandler{ @@ -27,8 +26,7 @@ public class PacketHandler{ theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID_LOWER); theNetwork.registerMessage(PacketGuiButton.Handler.class, PacketGuiButton.class, 0, Side.SERVER); - theNetwork.registerMessage(PacketSyncerToClient.Handler.class, PacketSyncerToClient.class, 1, Side.CLIENT); - theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 2, Side.SERVER); - theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 3, Side.SERVER); + theNetwork.registerMessage(PacketGuiNumber.Handler.class, PacketGuiNumber.class, 1, Side.SERVER); + theNetwork.registerMessage(PacketGuiString.Handler.class, PacketGuiString.class, 2, Side.SERVER); } } diff --git a/src/main/java/ellpeck/actuallyadditions/network/sync/IPacketSyncerToClient.java b/src/main/java/ellpeck/actuallyadditions/network/sync/IPacketSyncerToClient.java deleted file mode 100644 index 2ee939a5d..000000000 --- a/src/main/java/ellpeck/actuallyadditions/network/sync/IPacketSyncerToClient.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file ("IPacketSyncerToClient.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015 Ellpeck - */ - -package ellpeck.actuallyadditions.network.sync; - -public interface IPacketSyncerToClient{ - - /** - * @return The values that should be sent to the Client - */ - int[] getValues(); - - /** - * Sets the Values on the Client - * - * @param values The Values - */ - void setValues(int[] values); - - /** - * Sends the Update - */ - void sendUpdate(); -} diff --git a/src/main/java/ellpeck/actuallyadditions/network/sync/PacketSyncerToClient.java b/src/main/java/ellpeck/actuallyadditions/network/sync/PacketSyncerToClient.java deleted file mode 100644 index 2ef1add5d..000000000 --- a/src/main/java/ellpeck/actuallyadditions/network/sync/PacketSyncerToClient.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file ("PacketSyncerToClient.java") is part of the Actually Additions Mod for Minecraft. - * It is created and owned by Ellpeck and distributed - * under the Actually Additions License to be found at - * http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015 Ellpeck - */ - -package ellpeck.actuallyadditions.network.sync; - -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.actuallyadditions.network.PacketHandler; -import io.netty.buffer.ByteBuf; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class PacketSyncerToClient implements IMessage{ - - private int x; - private int y; - private int z; - private int[] values; - - @SuppressWarnings("unused") - public PacketSyncerToClient(){ - - } - - public PacketSyncerToClient(TileEntity tile, int[] values){ - this.x = tile.xCoord; - this.y = tile.yCoord; - this.z = tile.zCoord; - this.values = values; - } - - public static void sendPacket(TileEntity tile){ - if(tile instanceof IPacketSyncerToClient){ - PacketHandler.theNetwork.sendToAllAround(new PacketSyncerToClient(tile, ((IPacketSyncerToClient)tile).getValues()), new NetworkRegistry.TargetPoint(tile.getWorldObj().provider.dimensionId, tile.xCoord, tile.yCoord, tile.zCoord, 128)); - } - } - - @Override - public void fromBytes(ByteBuf buf){ - this.x = buf.readInt(); - this.y = buf.readInt(); - this.z = buf.readInt(); - int length = buf.readInt(); - if(this.values == null){ - this.values = new int[length]; - } - for(int i = 0; i < length; i++){ - this.values[i] = buf.readInt(); - } - } - - @Override - public void toBytes(ByteBuf buf){ - buf.writeInt(this.x); - buf.writeInt(this.y); - buf.writeInt(this.z); - buf.writeInt(this.values.length); - for(int value : this.values){ - buf.writeInt(value); - } - } - - public static class Handler implements IMessageHandler{ - - @Override - @SideOnly(Side.CLIENT) - public IMessage onMessage(PacketSyncerToClient message, MessageContext ctx){ - World world = FMLClientHandler.instance().getClient().theWorld; - TileEntity tile = world.getTileEntity(message.x, message.y, message.z); - if(tile != null && tile instanceof IPacketSyncerToClient){ - ((IPacketSyncerToClient)tile).setValues(message.values); - } - return null; - } - } -} diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java index e666b69be..1faeb7cdc 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBase.java @@ -20,7 +20,7 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class TileEntityBase extends TileEntity{ +public abstract class TileEntityBase extends TileEntity{ public static void init(){ ModUtil.LOGGER.info("Registering TileEntities..."); @@ -64,20 +64,40 @@ public class TileEntityBase extends TileEntity{ GameRegistry.registerTileEntity(TileEntityRangedCollector.class, ModUtil.MOD_ID_LOWER+":tileEntityRangedCollector"); } + @Override + public final void readFromNBT(NBTTagCompound compound){ + super.readFromNBT(compound); + this.readSyncableNBT(compound, false); + } + + @Override + public final void writeToNBT(NBTTagCompound compound){ + super.writeToNBT(compound); + this.writeSyncableNBT(compound, false); + } + + public abstract void readSyncableNBT(NBTTagCompound compound, boolean isForSync); + + public abstract void writeSyncableNBT(NBTTagCompound compound, boolean isForSync); + @Override public Packet getDescriptionPacket(){ NBTTagCompound tag = new NBTTagCompound(); - this.writeToNBT(tag); - return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, tag); + this.writeSyncableNBT(tag, true); + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 3, tag); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt){ - this.readFromNBT(pkt.func_148857_g()); + this.readSyncableNBT(pkt.func_148857_g(), true); } @Override public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z){ return !(oldBlock.isAssociatedBlock(newBlock)); } + + protected void sendUpdate(){ + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + } } \ No newline at end of file diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java index db920d8f8..13952a500 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityBreaker.java @@ -78,14 +78,14 @@ public class TileEntityBreaker extends TileEntityInventoryBase{ } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.currentTime = compound.getInteger("CurrentTime"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("CurrentTime", this.currentTime); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java index 0ce28e87a..cccbf692c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCanolaPress.java @@ -18,8 +18,6 @@ import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.metalists.TheMiscItems; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -27,7 +25,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{ +public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler{ public EnergyStorage storage = new EnergyStorage(40000); public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); @@ -106,19 +104,19 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.currentProcessTime = compound.getInteger("ProcessTime"); this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("ProcessTime", this.currentProcessTime); this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -188,26 +186,4 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE public FluidTankInfo[] getTankInfo(ForgeDirection from){ return new FluidTankInfo[]{this.tank.getInfo()}; } - - @Override - public int[] getValues(){ - return new int[]{this.currentProcessTime, this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID(), this.storage.getEnergyStored()}; - } - - @Override - public void setValues(int[] values){ - this.currentProcessTime = values[0]; - if(values[2] != -1){ - this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[2]), values[1])); - } - else{ - this.tank.setFluid(null); - } - this.storage.setEnergyStored(values[3]); - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java index 19dbd8c1a..e9b1074b8 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoalGenerator.java @@ -15,15 +15,13 @@ import cofh.api.energy.IEnergyProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider, IPacketSyncerToClient{ +public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider{ public EnergyStorage storage = new EnergyStorage(60000); public int maxBurnTime; @@ -101,19 +99,19 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.currentBurnTime = compound.getInteger("BurnTime"); this.maxBurnTime = compound.getInteger("MaxBurnTime"); this.storage.readFromNBT(compound); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("BurnTime", this.currentBurnTime); compound.setInteger("MaxBurnTime", this.maxBurnTime); this.storage.writeToNBT(compound); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -150,21 +148,4 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements public boolean canConnectEnergy(ForgeDirection from){ return true; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored(), this.currentBurnTime, this.maxBurnTime}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - this.currentBurnTime = values[1]; - this.maxBurnTime = values[2]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java index 0a66cb040..60f1d12d9 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCoffeeMachine.java @@ -19,8 +19,6 @@ import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.ItemCoffee; import ellpeck.actuallyadditions.items.metalists.TheMiscItems; import ellpeck.actuallyadditions.network.gui.IButtonReactor; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -28,7 +26,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{ +public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, IFluidHandler{ public static final int SLOT_COFFEE_BEANS = 0; public static final int SLOT_INPUT = 1; @@ -142,8 +140,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); this.coffeeCacheAmount = compound.getInteger("Cache"); @@ -151,8 +149,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); compound.setInteger("Cache", this.coffeeCacheAmount); @@ -230,27 +228,4 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements public FluidTankInfo[] getTankInfo(ForgeDirection from){ return new FluidTankInfo[]{this.tank.getInfo()}; } - - @Override - public int[] getValues(){ - return new int[]{this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID(), this.storage.getEnergyStored(), this.brewTime, this.coffeeCacheAmount}; - } - - @Override - public void setValues(int[] values){ - if(values[1] != -1){ - this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[1]), values[0])); - } - else{ - this.tank.setFluid(null); - } - this.storage.setEnergyStored(values[2]); - this.brewTime = values[3]; - this.coffeeCacheAmount = values[4]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java index 40938be36..0f50b356f 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityCompost.java @@ -57,14 +57,14 @@ public class TileEntityCompost extends TileEntityInventoryBase{ } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.conversionTime = compound.getInteger("ConversionTime"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); compound.setInteger("ConversionTime", this.conversionTime); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java index ab2c4cbbc..b2631cc68 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDirectionalBreaker.java @@ -15,8 +15,6 @@ import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; @@ -27,7 +25,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; -public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{ +public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver{ public EnergyStorage storage = new EnergyStorage(10000); private int lastEnergy; @@ -91,15 +89,15 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.storage.readFromNBT(compound); this.currentTime = compound.getInteger("CurrentTime"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); this.storage.writeToNBT(compound); compound.setInteger("CurrentTime", this.currentTime); } @@ -138,19 +136,4 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem public boolean canConnectEnergy(ForgeDirection from){ return true; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored()}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java index a5881c8f9..ca19c24cb 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityDropper.java @@ -63,14 +63,14 @@ public class TileEntityDropper extends TileEntityInventoryBase{ } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.currentTime = compound.getInteger("CurrentTime"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("CurrentTime", this.currentTime); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java index c88118a70..5a071482b 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnergizer.java @@ -15,13 +15,11 @@ import cofh.api.energy.IEnergyContainerItem; import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{ +public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver{ public EnergyStorage storage = new EnergyStorage(500000); private int lastEnergy; @@ -56,15 +54,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.readFromNBT(compound); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.writeToNBT(compound); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -106,19 +104,4 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne public boolean canConnectEnergy(ForgeDirection from){ return true; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored()}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java index eacb8d48f..0eb9b7dd3 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityEnervator.java @@ -15,14 +15,12 @@ import cofh.api.energy.IEnergyContainerItem; import cofh.api.energy.IEnergyProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider, IPacketSyncerToClient{ +public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider{ public EnergyStorage storage = new EnergyStorage(500000); private int lastEnergy; @@ -66,15 +64,15 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.readFromNBT(compound); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.writeToNBT(compound); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -116,19 +114,4 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne public boolean canExtractItem(int slot, ItemStack stack, int side){ return slot == 1; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored()}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java index ed5a63596..5fb121b3d 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFeeder.java @@ -13,8 +13,6 @@ package ellpeck.actuallyadditions.tile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -23,7 +21,7 @@ import net.minecraft.util.AxisAlignedBB; import java.util.List; import java.util.Random; -public class TileEntityFeeder extends TileEntityInventoryBase implements IPacketSyncerToClient{ +public class TileEntityFeeder extends TileEntityInventoryBase{ public int currentTimer; public int currentAnimalAmount; @@ -101,14 +99,14 @@ public class TileEntityFeeder extends TileEntityInventoryBase implements IPacket } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.currentTimer = compound.getInteger("Timer"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("Timer", this.currentTimer); } @@ -126,20 +124,4 @@ public class TileEntityFeeder extends TileEntityInventoryBase implements IPacket public boolean canExtractItem(int slot, ItemStack stack, int side){ return false; } - - @Override - public int[] getValues(){ - return new int[]{this.currentAnimalAmount, this.currentTimer}; - } - - @Override - public void setValues(int[] values){ - this.currentAnimalAmount = values[0]; - this.currentTimer = values[1]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java index d3b29a431..5aa44eb7f 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFermentingBarrel.java @@ -14,8 +14,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -23,7 +21,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class TileEntityFermentingBarrel extends TileEntityInventoryBase implements IFluidHandler, IPacketSyncerToClient{ +public class TileEntityFermentingBarrel extends TileEntityInventoryBase implements IFluidHandler{ public FluidTank canolaTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); public FluidTank oilTank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); @@ -82,21 +80,21 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.currentProcessTime = compound.getInteger("ProcessTime"); this.canolaTank.readFromNBT(compound); this.oilTank.readFromNBT((NBTTagCompound)compound.getTag("OilTank")); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("ProcessTime", this.currentProcessTime); this.canolaTank.writeToNBT(compound); NBTTagCompound tag = new NBTTagCompound(); this.oilTank.writeToNBT(tag); compound.setTag("OilTank", tag); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -159,31 +157,4 @@ public class TileEntityFermentingBarrel extends TileEntityInventoryBase implemen public FluidTankInfo[] getTankInfo(ForgeDirection from){ return new FluidTankInfo[]{this.canolaTank.getInfo(), this.oilTank.getInfo()}; } - - @Override - public int[] getValues(){ - return new int[]{this.oilTank.getFluidAmount(), this.oilTank.getFluid() == null ? -1 : this.oilTank.getFluid().getFluidID(), this.canolaTank.getFluidAmount(), this.canolaTank.getFluid() == null ? -1 : this.canolaTank.getFluid().getFluidID(), this.currentProcessTime}; - } - - @Override - public void setValues(int[] values){ - if(values[1] != -1){ - this.oilTank.setFluid(new FluidStack(FluidRegistry.getFluid(values[1]), values[0])); - } - else{ - this.oilTank.setFluid(null); - } - if(values[3] != -1){ - this.canolaTank.setFluid(new FluidStack(FluidRegistry.getFluid(values[3]), values[2])); - } - else{ - this.canolaTank.setFluid(null); - } - this.currentProcessTime = values[4]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java index 04527a6f7..0c46ac9ba 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFishingNet.java @@ -28,13 +28,12 @@ public class TileEntityFishingNet extends TileEntityBase{ public int timeUntilNextDrop; @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ super.writeToNBT(compound); compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java index f35713d25..815e6d294 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFluidCollector.java @@ -13,8 +13,6 @@ package ellpeck.actuallyadditions.tile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; @@ -24,7 +22,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class TileEntityFluidCollector extends TileEntityInventoryBase implements IFluidHandler, IPacketSyncerToClient{ +public class TileEntityFluidCollector extends TileEntityInventoryBase implements IFluidHandler{ public FluidTank tank = new FluidTank(8*FluidContainerRegistry.BUCKET_VOLUME); public boolean isPlacer; @@ -79,26 +77,6 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements return new FluidTankInfo[]{this.tank.getInfo()}; } - @Override - public int[] getValues(){ - return new int[]{this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID()}; - } - - @Override - public void setValues(int[] values){ - if(values[1] != -1){ - this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[1]), values[0])); - } - else{ - this.tank.setFluid(null); - } - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } - @Override @SuppressWarnings("unchecked") public void updateEntity(){ @@ -181,15 +159,15 @@ public class TileEntityFluidCollector extends TileEntityInventoryBase implements } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.currentTime = compound.getInteger("CurrentTime"); this.tank.readFromNBT(compound); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("CurrentTime", this.currentTime); this.tank.writeToNBT(compound); } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java index e6b29dbc9..6d5b28297 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceDouble.java @@ -15,14 +15,12 @@ import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{ +public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int SLOT_INPUT_1 = 0; public static final int SLOT_OUTPUT_1 = 1; @@ -132,16 +130,16 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.firstSmeltTime = compound.getInteger("FirstSmeltTime"); this.secondSmeltTime = compound.getInteger("SecondSmeltTime"); this.storage.readFromNBT(compound); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("FirstSmeltTime", this.firstSmeltTime); compound.setInteger("SecondSmeltTime", this.secondSmeltTime); this.storage.writeToNBT(compound); @@ -196,21 +194,4 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements public boolean canConnectEnergy(ForgeDirection from){ return true; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored(), this.firstSmeltTime, this.secondSmeltTime}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - this.firstSmeltTime = values[1]; - this.secondSmeltTime = values[2]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java index fd77b2d4d..fe68c9475 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityFurnaceSolar.java @@ -42,15 +42,13 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.readFromNBT(compound); - super.readFromNBT(compound); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.writeToNBT(compound); - super.writeToNBT(compound); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java index 99b2bd1df..26d05b769 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGreenhouseGlass.java @@ -15,6 +15,7 @@ import ellpeck.actuallyadditions.util.WorldPos; import net.minecraft.block.Block; import net.minecraft.block.BlockGrass; import net.minecraft.block.IGrowable; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.IPlantable; import java.util.Random; @@ -63,4 +64,13 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{ return null; } + @Override + public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ + compound.setInteger("Time", this.timeUntilNextFert); + } + + @Override + public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ + this.timeUntilNextFert = compound.getInteger("Time"); + } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java index 59d37ebcd..67dea8c9a 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityGrinder.java @@ -16,8 +16,6 @@ import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.recipe.CrusherRecipeRegistry; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -26,7 +24,7 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; import java.util.Random; -public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{ +public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int SLOT_INPUT_1 = 0; public static final int SLOT_OUTPUT_1_1 = 1; @@ -71,23 +69,6 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg return true; } - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored(), this.firstCrushTime, this.secondCrushTime}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - this.firstCrushTime = values[1]; - this.secondCrushTime = values[2]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } - @Override @SuppressWarnings("unchecked") public void updateEntity(){ @@ -216,19 +197,19 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.firstCrushTime = compound.getInteger("FirstCrushTime"); this.secondCrushTime = compound.getInteger("SecondCrushTime"); this.storage.readFromNBT(compound); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("FirstCrushTime", this.firstCrushTime); compound.setInteger("SecondCrushTime", this.secondCrushTime); this.storage.writeToNBT(compound); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java index 76ff695e9..3fd506d92 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityHeatCollector.java @@ -17,6 +17,7 @@ import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; @@ -77,4 +78,14 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr public boolean canConnectEnergy(ForgeDirection from){ return from == ForgeDirection.UP; } + + @Override + public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ + this.storage.readFromNBT(compound); + } + + @Override + public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ + this.storage.writeToNBT(compound); + } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java index f01537669..ca9179606 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInputter.java @@ -12,8 +12,6 @@ package ellpeck.actuallyadditions.tile; import ellpeck.actuallyadditions.network.gui.IButtonReactor; import ellpeck.actuallyadditions.network.gui.INumberReactor; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; @@ -22,7 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor, IPacketSyncerToClient{ +public class TileEntityInputter extends TileEntityInventoryBase implements IButtonReactor, INumberReactor{ public static final int PUT_FILTER_START = 13; public static final int PULL_FILTER_START = 1; @@ -82,28 +80,6 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt this.markDirty(); } - @Override - public int[] getValues(){ - return new int[]{sideToPut, sideToPull, slotToPutStart, slotToPutEnd, slotToPullStart, slotToPullEnd, this.isPutWhitelist ? 1 : 0, this.isPullWhitelist ? 1 : 0}; - } - - @Override - public void setValues(int[] values){ - this.sideToPut = values[0]; - this.sideToPull = values[1]; - this.slotToPutStart = values[2]; - this.slotToPutEnd = values[3]; - this.slotToPullStart = values[4]; - this.slotToPullEnd = values[5]; - this.isPutWhitelist = values[6] == 1; - this.isPullWhitelist = values[7] == 1; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } - @Override public void updateEntity(){ if(!worldObj.isRemote){ @@ -425,7 +401,7 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.sideToPut = compound.getInteger("SideToPut"); this.slotToPutStart = compound.getInteger("SlotToPut"); this.slotToPutEnd = compound.getInteger("SlotToPutEnd"); @@ -434,12 +410,12 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt this.slotToPullEnd = compound.getInteger("SlotToPullEnd"); this.isPullWhitelist = compound.getBoolean("PullWhitelist"); this.isPutWhitelist = compound.getBoolean("PutWhitelist"); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("SideToPut", this.sideToPut); compound.setInteger("SlotToPut", this.slotToPutStart); compound.setInteger("SlotToPutEnd", this.slotToPutEnd); diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java index 287117205..068698e91 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityInventoryBase.java @@ -32,34 +32,36 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); - if(this.slots.length > 0){ - NBTTagList tagList = compound.getTagList("Items", 10); - for(int i = 0; i < tagList.tagCount(); i++){ - NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); - byte slotIndex = tagCompound.getByte("Slot"); - if(slotIndex >= 0 && slotIndex < slots.length){ - slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ + if(!isForSync){ + if(this.slots.length > 0){ + NBTTagList tagList = compound.getTagList("Items", 10); + for(int i = 0; i < tagList.tagCount(); i++){ + NBTTagCompound tagCompound = tagList.getCompoundTagAt(i); + byte slotIndex = tagCompound.getByte("Slot"); + if(slotIndex >= 0 && slotIndex < slots.length){ + slots[slotIndex] = ItemStack.loadItemStackFromNBT(tagCompound); + } } } } } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); - if(this.slots.length > 0){ - NBTTagList tagList = new NBTTagList(); - for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){ - if(slots[currentIndex] != null){ - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)currentIndex); - slots[currentIndex].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); + public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ + if(!isForSync){ + if(this.slots.length > 0){ + NBTTagList tagList = new NBTTagList(); + for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){ + if(slots[currentIndex] != null){ + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte)currentIndex); + slots[currentIndex].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } } + compound.setTag("Items", tagList); } - compound.setTag("Items", tagList); } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java index 4b8a34d6b..2ad362b49 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityItemRepairer.java @@ -15,13 +15,11 @@ import cofh.api.energy.IEnergyReceiver; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver, IPacketSyncerToClient{ +public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int SLOT_INPUT = 0; public static final int SLOT_OUTPUT = 1; @@ -71,16 +69,16 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.nextRepairTick = compound.getInteger("NextRepairTick"); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); this.storage.readFromNBT(compound); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("NextRepairTick", this.nextRepairTick); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); this.storage.writeToNBT(compound); } @@ -131,19 +129,4 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I public boolean canConnectEnergy(ForgeDirection from){ return true; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored()}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java index 6c6eb4bee..e0059f616 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLavaFactoryController.java @@ -31,17 +31,15 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I private int currentWorkTime; @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.readFromNBT(compound); this.currentWorkTime = compound.getInteger("WorkTime"); - super.readFromNBT(compound); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.writeToNBT(compound); compound.setInteger("WorkTime", this.currentWorkTime); - super.writeToNBT(compound); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java index 61eedfa31..4d0f5623c 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityLeafGenerator.java @@ -29,15 +29,13 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr private int nextUseCounter; @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.readFromNBT(compound); - super.readFromNBT(compound); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.writeToNBT(compound); - super.writeToNBT(compound); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java index 0ea01e1a2..ed977e317 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOilGenerator.java @@ -16,15 +16,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.*; -public class TileEntityOilGenerator extends TileEntityInventoryBase implements IEnergyProvider, IFluidHandler, IPacketSyncerToClient{ +public class TileEntityOilGenerator extends TileEntityInventoryBase implements IEnergyProvider, IFluidHandler{ public EnergyStorage storage = new EnergyStorage(50000); public FluidTank tank = new FluidTank(2*FluidContainerRegistry.BUCKET_VOLUME); @@ -104,19 +102,19 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.currentBurnTime = compound.getInteger("BurnTime"); this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ compound.setInteger("BurnTime", this.currentBurnTime); this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -186,26 +184,4 @@ public class TileEntityOilGenerator extends TileEntityInventoryBase implements I public FluidTankInfo[] getTankInfo(ForgeDirection from){ return new FluidTankInfo[]{this.tank.getInfo()}; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored(), this.currentBurnTime, this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID()}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - this.currentBurnTime = values[1]; - if(values[3] != -1){ - this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[3]), values[2])); - } - else{ - this.tank.setFluid(null); - } - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java index 87b0f02ea..af1a244c9 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityOreMagnet.java @@ -18,8 +18,6 @@ import ellpeck.actuallyadditions.blocks.InitBlocks; import ellpeck.actuallyadditions.blocks.metalists.TheMiscBlocks; import ellpeck.actuallyadditions.config.ConfigValues; import ellpeck.actuallyadditions.config.values.ConfigIntValues; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldPos; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.block.Block; @@ -32,7 +30,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.ArrayList; -public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler, IPacketSyncerToClient{ +public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEnergyReceiver, IFluidHandler{ public static final int SLOT_OIL_INPUT = 0; public static final int SLOT_OIL_OUTPUT = 1; @@ -182,19 +180,19 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne } @Override - public void readFromNBT(NBTTagCompound compound){ + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); this.currentWorkTimer = compound.getInteger("CurrentWorkTimer"); - super.readFromNBT(compound); + super.readSyncableNBT(compound, sync); } @Override - public void writeToNBT(NBTTagCompound compound){ + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); compound.setInteger("CurrentWorkTimer", this.currentWorkTimer); - super.writeToNBT(compound); + super.writeSyncableNBT(compound, sync); } @Override @@ -264,25 +262,4 @@ public class TileEntityOreMagnet extends TileEntityInventoryBase implements IEne public FluidTankInfo[] getTankInfo(ForgeDirection from){ return new FluidTankInfo[]{this.tank.getInfo()}; } - - @Override - public int[] getValues(){ - return new int[]{this.storage.getEnergyStored(), this.tank.getFluidAmount(), this.tank.getFluid() == null ? -1 : this.tank.getFluid().getFluidID()}; - } - - @Override - public void setValues(int[] values){ - this.storage.setEnergyStored(values[0]); - if(values[2] != -1){ - this.tank.setFluid(new FluidStack(FluidRegistry.getFluid(values[2]), values[1])); - } - else{ - this.tank.setFluid(null); - } - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java index ab5807107..473756527 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomBooster.java @@ -10,6 +10,8 @@ package ellpeck.actuallyadditions.tile; +import net.minecraft.nbt.NBTTagCompound; + public class TileEntityPhantomBooster extends TileEntityBase{ @Override @@ -17,4 +19,13 @@ public class TileEntityPhantomBooster extends TileEntityBase{ return false; } + @Override + public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ + + } + + @Override + public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ + + } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java index 994187102..260509f07 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomPlacer.java @@ -138,8 +138,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); int x = compound.getInteger("XCoordOfTileStored"); int y = compound.getInteger("YCoordOfTileStored"); int z = compound.getInteger("ZCoordOfTileStored"); @@ -151,8 +151,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setInteger("Time", currentTime); if(this.hasBoundPosition()){ compound.setInteger("XCoordOfTileStored", boundPosition.getX()); diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java index 40e1671ab..ca5402e86 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityPhantomface.java @@ -120,8 +120,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); int x = compound.getInteger("XCoordOfTileStored"); int y = compound.getInteger("YCoordOfTileStored"); int z = compound.getInteger("ZCoordOfTileStored"); @@ -133,8 +133,8 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); if(this.hasBoundPosition()){ compound.setInteger("XCoordOfTileStored", boundPosition.getX()); compound.setInteger("YCoordOfTileStored", boundPosition.getY()); diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java index cc8175fd7..2f1b643e4 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityRangedCollector.java @@ -12,8 +12,6 @@ package ellpeck.actuallyadditions.tile; import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.network.gui.IButtonReactor; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import ellpeck.actuallyadditions.util.WorldUtil; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; @@ -23,7 +21,7 @@ import net.minecraft.util.AxisAlignedBB; import java.util.ArrayList; -public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor, IPacketSyncerToClient{ +public class TileEntityRangedCollector extends TileEntityInventoryBase implements IButtonReactor{ public static final int WHITELIST_START = 6; @@ -77,14 +75,14 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.isWhitelist = compound.getBoolean("Whitelist"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setBoolean("Whitelist", this.isWhitelist); } @@ -107,19 +105,4 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement public void onButtonPressed(int buttonID, EntityPlayer player){ this.isWhitelist = !this.isWhitelist; } - - @Override - public int[] getValues(){ - return new int[]{this.isWhitelist ? 1 : 0}; - } - - @Override - public void setValues(int[] values){ - this.isWhitelist = values[0] == 1; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } } diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java index 1a916c5ec..6ff00943e 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntitySmileyCloud.java @@ -13,14 +13,12 @@ package ellpeck.actuallyadditions.tile; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.network.gui.IStringReactor; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import java.util.Objects; -public class TileEntitySmileyCloud extends TileEntityBase implements IPacketSyncerToClient, IStringReactor{ +public class TileEntitySmileyCloud extends TileEntityBase implements IStringReactor{ public String name; @SideOnly(Side.CLIENT) @@ -30,14 +28,12 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IPacketSync private String nameBefore; @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ this.name = compound.getString("Name"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ if(this.name != null){ compound.setString("Name", this.name); } @@ -54,38 +50,6 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IPacketSync } } - @Override - public int[] getValues(){ - if(this.name != null && !this.name.isEmpty()){ - int[] chars = new int[this.name.length()]; - for(int i = 0; i < this.name.length(); i++){ - char atPlace = this.name.charAt(i); - chars[i] = (int)atPlace; - } - return chars; - } - return new int[0]; - } - - @Override - public void setValues(int[] values){ - if(values != null && values.length > 0){ - String newName = ""; - for(int value : values){ - newName += (char)value; - } - this.name = newName; - } - else{ - this.name = null; - } - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } - @Override public void onTextReceived(String text, int textID, EntityPlayer player){ this.name = text; diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java index 392338b61..c441b3580 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java @@ -15,13 +15,11 @@ import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.ItemSpecialDrop; import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops; import ellpeck.actuallyadditions.network.gui.IButtonReactor; -import ellpeck.actuallyadditions.network.sync.IPacketSyncerToClient; -import ellpeck.actuallyadditions.network.sync.PacketSyncerToClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor, IPacketSyncerToClient{ +public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor{ public short amount; private short lastAmount; @@ -56,14 +54,14 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I } @Override - public void readFromNBT(NBTTagCompound compound){ - super.readFromNBT(compound); + public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + super.readSyncableNBT(compound, sync); this.amount = compound.getShort("Amount"); } @Override - public void writeToNBT(NBTTagCompound compound){ - super.writeToNBT(compound); + public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + super.writeSyncableNBT(compound, sync); compound.setShort("Amount", this.amount); } @@ -150,19 +148,4 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I } return 0; } - - @Override - public int[] getValues(){ - return new int[]{this.amount}; - } - - @Override - public void setValues(int[] values){ - this.amount = (short)values[0]; - } - - @Override - public void sendUpdate(){ - PacketSyncerToClient.sendPacket(this); - } }