From 794032870ab26ee5170eb8cbf1bb0405ac68935b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 2 Jul 2016 15:01:46 +0200 Subject: [PATCH] Changed NBT saving system and thus removing some unnecessary interfaces --- .../mod/blocks/base/BlockContainerBase.java | 104 ++++++++---------- .../actuallyadditions/mod/event/HudEvent.java | 23 ++-- .../mod/tile/IEnergySaver.java | 18 --- .../mod/tile/IFluidSaver.java | 20 ---- .../mod/tile/IRedstoneToggle.java | 20 ---- .../tile/TileEntityAtomicReconstructor.java | 39 +++---- .../mod/tile/TileEntityBase.java | 39 +++++-- .../mod/tile/TileEntityBookletStand.java | 22 ++-- .../mod/tile/TileEntityBreaker.java | 30 +++-- .../mod/tile/TileEntityCanolaPress.java | 38 ++----- .../mod/tile/TileEntityCoalGenerator.java | 32 +++--- .../mod/tile/TileEntityCoffeeMachine.java | 42 +++---- .../mod/tile/TileEntityCompost.java | 16 ++- .../tile/TileEntityDirectionalBreaker.java | 39 +++---- .../mod/tile/TileEntityDisplayStand.java | 8 +- .../mod/tile/TileEntityDropper.java | 30 +++-- .../mod/tile/TileEntityEnergizer.java | 20 +--- .../mod/tile/TileEntityEnervator.java | 20 +--- .../mod/tile/TileEntityFeeder.java | 12 +- .../mod/tile/TileEntityFermentingBarrel.java | 22 +--- .../mod/tile/TileEntityFireworkBox.java | 27 ++--- .../mod/tile/TileEntityFishingNet.java | 16 ++- .../mod/tile/TileEntityFluidCollector.java | 40 +++---- .../mod/tile/TileEntityFurnaceDouble.java | 32 +++--- .../mod/tile/TileEntityFurnaceSolar.java | 15 +-- .../mod/tile/TileEntityGreenhouseGlass.java | 16 ++- .../mod/tile/TileEntityGrinder.java | 32 +++--- .../mod/tile/TileEntityHeatCollector.java | 15 +-- .../mod/tile/TileEntityInputter.java | 44 ++++---- .../mod/tile/TileEntityInventoryBase.java | 12 +- .../mod/tile/TileEntityItemRepairer.java | 28 ++--- .../TileEntityLaserRelayItemWhitelist.java | 12 +- .../tile/TileEntityLavaFactoryController.java | 23 ++-- .../mod/tile/TileEntityLeafGenerator.java | 15 +-- .../mod/tile/TileEntityMiner.java | 29 ++--- .../mod/tile/TileEntityOilGenerator.java | 38 ++----- .../mod/tile/TileEntityPhantomPlacer.java | 50 ++++----- .../mod/tile/TileEntityPhantomface.java | 36 +++--- .../mod/tile/TileEntityPlayerInterface.java | 8 +- .../mod/tile/TileEntityRangedCollector.java | 16 ++- .../mod/tile/TileEntitySmileyCloud.java | 14 ++- .../mod/tile/TileEntityXPSolidifier.java | 8 +- 42 files changed, 464 insertions(+), 656 deletions(-) delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergySaver.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/tile/IFluidSaver.java delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/tile/IRedstoneToggle.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java index c6fc11f5a..8c65b55a5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/base/BlockContainerBase.java @@ -11,7 +11,8 @@ package de.ellpeck.actuallyadditions.mod.blocks.base; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.tile.*; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.Util; import net.minecraft.block.Block; @@ -28,17 +29,19 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagInt; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidUtil; import java.util.ArrayList; +import java.util.List; import java.util.Random; public abstract class BlockContainerBase extends BlockContainer implements ItemBlockBase.ICustomRarity{ @@ -112,9 +115,10 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB ItemStack stack = player.getHeldItemMainhand(); if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){ TileEntity tile = world.getTileEntity(pos); - if(tile instanceof IRedstoneToggle){ - if(!world.isRemote){ - ((IRedstoneToggle)tile).toggle(!((IRedstoneToggle)tile).isPulseMode()); + if(tile instanceof TileEntityBase){ + TileEntityBase base = (TileEntityBase)tile; + if(!world.isRemote && base.isRedstoneToggle()){ + base.isPulseMode = !base.isPulseMode; tile.markDirty(); if(tile instanceof TileEntityBase){ @@ -141,8 +145,11 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB public void updateTick(World world, BlockPos pos, IBlockState state, Random random){ if(!world.isRemote){ TileEntity tile = world.getTileEntity(pos); - if(tile instanceof IRedstoneToggle && ((IRedstoneToggle)tile).isPulseMode()){ - ((IRedstoneToggle)tile).activateOnPulse(); + if(tile instanceof TileEntityBase){ + TileEntityBase base = (TileEntityBase)tile; + if(base.isRedstoneToggle() && base.isPulseMode){ + base.activateOnPulse(); + } } } } @@ -156,16 +163,17 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB if(!world.isRemote){ TileEntity tile = world.getTileEntity(pos); if(tile instanceof TileEntityBase){ + TileEntityBase base = (TileEntityBase)tile; boolean powered = world.isBlockIndirectlyGettingPowered(pos) > 0; - boolean wasPowered = ((TileEntityBase)tile).isRedstonePowered; + boolean wasPowered = base.isRedstonePowered; if(powered && !wasPowered){ - if(tile instanceof IRedstoneToggle && ((IRedstoneToggle)tile).isPulseMode()){ + if(base.isRedstoneToggle() && base.isPulseMode){ world.scheduleUpdate(pos, this, this.tickRate(world)); } - ((TileEntityBase)tile).setRedstonePowered(true); + base.setRedstonePowered(true); } else if(!powered && wasPowered){ - ((TileEntityBase)tile).setRedstonePowered(false); + base.setRedstonePowered(false); } } } @@ -182,31 +190,12 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){ - if(stack.getTagCompound() != null){ + if(stack.hasTagCompound()){ TileEntity tile = world.getTileEntity(pos); - - if(tile instanceof IEnergySaver){ - ((IEnergySaver)tile).setEnergy(stack.getTagCompound().getInteger("Energy")); - stack.getTagCompound().removeTag("Energy"); - } - - if(tile instanceof IFluidSaver){ - int amount = stack.getTagCompound().getInteger("FluidAmount"); - stack.getTagCompound().removeTag("FluidAmount"); - - if(amount > 0){ - FluidStack[] fluids = new FluidStack[amount]; - - for(int i = 0; i < amount; i++){ - NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Fluid"+i); - stack.getTagCompound().removeTag("Fluid"+i); - if(compound != null){ - fluids[i] = FluidStack.loadFluidStackFromNBT(compound); - } - } - - ((IFluidSaver)tile).setFluids(fluids); - } + if(tile instanceof TileEntityBase){ + TileEntityBase base = (TileEntityBase)tile; + NBTTagCompound compound = stack.getTagCompound().getCompoundTag("Data"); + base.readSyncableNBT(compound, TileEntityBase.NBTType.SAVE_BLOCK); } } } @@ -246,36 +235,31 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB ArrayList drops = new ArrayList(); TileEntity tile = world.getTileEntity(pos); - if(tile != null){ - ItemStack stack = new ItemStack(this.getItemDropped(state, Util.RANDOM, fortune), 1, this.damageDropped(state)); + if(tile instanceof TileEntityBase){ + TileEntityBase base = (TileEntityBase)tile; + NBTTagCompound data = new NBTTagCompound(); + base.writeSyncableNBT(data, TileEntityBase.NBTType.SAVE_BLOCK); - if(tile instanceof IEnergySaver){ - int energy = ((IEnergySaver)tile).getEnergy(); - if(energy > 0){ - if(stack.getTagCompound() == null){ - stack.setTagCompound(new NBTTagCompound()); + //Remove unnecessarily saved default values to avoid unstackability + List keysToRemove = new ArrayList(); + for(String key : data.getKeySet()){ + NBTBase tag = data.getTag(key); + //Remove only ints because they are the most common ones + //Add else if below here to remove more types + if(tag instanceof NBTTagInt){ + if(((NBTTagInt)tag).getInt() == 0){ + keysToRemove.add(key); } - stack.getTagCompound().setInteger("Energy", energy); } } + for(String key : keysToRemove){ + data.removeTag(key); + } - if(tile instanceof IFluidSaver){ - FluidStack[] fluids = ((IFluidSaver)tile).getFluids(); - - if(fluids != null && fluids.length > 0){ - if(stack.getTagCompound() == null){ - stack.setTagCompound(new NBTTagCompound()); - } - - stack.getTagCompound().setInteger("FluidAmount", fluids.length); - for(int i = 0; i < fluids.length; i++){ - if(fluids[i] != null && fluids[i].amount > 0){ - NBTTagCompound compound = new NBTTagCompound(); - fluids[i].writeToNBT(compound); - stack.getTagCompound().setTag("Fluid"+i, compound); - } - } - } + ItemStack stack = new ItemStack(this.getItemDropped(state, Util.RANDOM, fortune), 1, this.damageDropped(state)); + if(!data.hasNoTags()){ + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound().setTag("Data", data); } drops.add(stack); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/HudEvent.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/HudEvent.java index 2333e9b75..e448e7747 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/HudEvent.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/HudEvent.java @@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.event; import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay; -import de.ellpeck.actuallyadditions.mod.tile.IRedstoneToggle; +import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.PosUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; @@ -61,18 +61,21 @@ public class HudEvent{ profiler.endSection(); } - if(tileHit instanceof IRedstoneToggle){ - profiler.startSection("RedstoneToggleHudDisplay"); + if(tileHit instanceof TileEntityBase){ + TileEntityBase base = (TileEntityBase)tileHit; + if(base.isRedstoneToggle()){ + profiler.startSection("RedstoneToggleHudDisplay"); - String strg = "Redstone Mode: "+TextFormatting.DARK_RED+(((IRedstoneToggle)tileHit).isPulseMode() ? "Pulse" : "Deactivation")+TextFormatting.RESET; - font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); + String strg = "Redstone Mode: "+TextFormatting.DARK_RED+(base.isPulseMode ? "Pulse" : "Deactivation")+TextFormatting.RESET; + font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); - if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){ - String expl = TextFormatting.GREEN+"Right-Click to toggle!"; - font.drawStringWithShadow(expl, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE); + if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){ + String expl = TextFormatting.GREEN+"Right-Click to toggle!"; + font.drawStringWithShadow(expl, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+15, StringUtil.DECIMAL_COLOR_WHITE); + } + + profiler.endSection(); } - - profiler.endSection(); } if(tileHit instanceof IEnergyDisplay){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergySaver.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergySaver.java deleted file mode 100644 index bf36a147c..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IEnergySaver.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * This file ("IEnergySaver.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://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public interface IEnergySaver{ - - int getEnergy(); - - void setEnergy(int energy); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IFluidSaver.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IFluidSaver.java deleted file mode 100644 index 90a706d69..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IFluidSaver.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file ("IFluidSaver.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://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -import net.minecraftforge.fluids.FluidStack; - -public interface IFluidSaver{ - - FluidStack[] getFluids(); - - void setFluids(FluidStack[] fluids); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IRedstoneToggle.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IRedstoneToggle.java deleted file mode 100644 index 60a877c26..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/IRedstoneToggle.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * This file ("IRedstoneToggle.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://ellpeck.de/actaddlicense - * View the source code at https://github.com/Ellpeck/ActuallyAdditions - * - * © 2015-2016 Ellpeck - */ - -package de.ellpeck.actuallyadditions.mod.tile; - -public interface IRedstoneToggle{ - - void toggle(boolean to); - - boolean isPulseMode(); - - void activateOnPulse(); -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java index bdf0ff9ba..7e8a8c353 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityAtomicReconstructor.java @@ -30,13 +30,12 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IRedstoneToggle, IEnergyDisplay, IAtomicReconstructor{ +public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyReceiver, IEnergyDisplay, IAtomicReconstructor{ public static final int ENERGY_USE = 1000; public final EnergyStorage storage = new EnergyStorage(300000); public int counter; private int currentTime; - private boolean activateOnceWithSignal; private int oldEnergy; public TileEntityAtomicReconstructor(){ @@ -51,10 +50,12 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("CurrentTime", this.currentTime); - compound.setInteger("Counter", this.counter); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("CurrentTime", this.currentTime); + compound.setInteger("Counter", this.counter); + } this.storage.writeToNBT(compound); } @@ -64,10 +65,12 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.currentTime = compound.getInteger("CurrentTime"); - this.counter = compound.getInteger("Counter"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.currentTime = compound.getInteger("CurrentTime"); + this.counter = compound.getInteger("Counter"); + } this.storage.readFromNBT(compound); } @@ -75,7 +78,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ @@ -198,11 +201,6 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ @@ -210,13 +208,8 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple } @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java index 84ebc3ed8..16aa41169 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBase.java @@ -40,6 +40,7 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ public static boolean teslaLoaded; public final String name; public boolean isRedstonePowered; + public boolean isPulseMode; protected int ticksElapsed; public TileEntityBase(String name){ @@ -113,14 +114,14 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); - this.readSyncableNBT(compound, false); + this.readSyncableNBT(compound, NBTType.SAVE_TILE); } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound){ compound = super.writeToNBT(compound); - this.writeSyncableNBT(compound, false); + this.writeSyncableNBT(compound, NBTType.SAVE_TILE); return compound; } @@ -148,13 +149,13 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ } public void receiveSyncCompound(NBTTagCompound compound){ - this.readSyncableNBT(compound, true); + this.readSyncableNBT(compound, NBTType.SYNC); } @Override public NBTTagCompound getUpdateTag(){ NBTTagCompound tag = super.getUpdateTag(); - this.writeSyncableNBT(tag, true); + this.writeSyncableNBT(tag, NBTType.SYNC); return tag; } @@ -163,21 +164,21 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ this.receiveSyncCompound(compound); } - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - if(!isForSync){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type == NBTType.SAVE_TILE){ compound.setBoolean("Redstone", this.isRedstonePowered); } - if(this instanceof IRedstoneToggle){ - compound.setBoolean("IsPulseMode", ((IRedstoneToggle)this).isPulseMode()); + if(this.isRedstoneToggle() && (type != NBTType.SAVE_BLOCK || this.isPulseMode)){ + compound.setBoolean("IsPulseMode", this.isPulseMode); } } - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - if(!isForSync){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type == NBTType.SAVE_TILE){ this.isRedstonePowered = compound.getBoolean("Redstone"); } - if(this instanceof IRedstoneToggle){ - ((IRedstoneToggle)this).toggle(compound.getBoolean("IsPulseMode")); + if(this.isRedstoneToggle()){ + this.isPulseMode = compound.getBoolean("IsPulseMode"); } } @@ -258,4 +259,18 @@ public abstract class TileEntityBase extends TileEntity implements ITickable{ public IFluidHandler getFluidHandler(EnumFacing facing){ return null; } + + public boolean isRedstoneToggle(){ + return false; + } + + public void activateOnPulse(){ + + } + + public enum NBTType{ + SAVE_TILE, + SYNC, + SAVE_BLOCK + } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBookletStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBookletStand.java index 4605cd892..390edccbe 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBookletStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBookletStand.java @@ -23,19 +23,23 @@ public class TileEntityBookletStand extends TileEntityBase{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.writeSyncableNBT(compound, isForSync); - compound.setTag("SavedEntry", this.assignedEntry.writeToNBT()); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setTag("SavedEntry", this.assignedEntry.writeToNBT()); - if(this.assignedPlayer != null){ - compound.setString("Player", this.assignedPlayer); + if(this.assignedPlayer != null){ + compound.setString("Player", this.assignedPlayer); + } } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.readSyncableNBT(compound, isForSync); - this.assignedEntry = EntrySet.readFromNBT(compound.getCompoundTag("SavedEntry")); - this.assignedPlayer = compound.getString("Player"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.assignedEntry = EntrySet.readFromNBT(compound.getCompoundTag("SavedEntry")); + this.assignedPlayer = compound.getString("Player"); + } } } \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java index 188bd8c3b..95d8d0a3b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityBreaker.java @@ -26,11 +26,10 @@ import net.minecraftforge.event.ForgeEventFactory; import java.util.List; -public class TileEntityBreaker extends TileEntityInventoryBase implements IRedstoneToggle{ +public class TileEntityBreaker extends TileEntityInventoryBase{ public boolean isPlacer; private int currentTime; - private boolean activateOnceWithSignal; public TileEntityBreaker(int slots, String name){ super(slots, name); @@ -42,22 +41,26 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("CurrentTime", this.currentTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("CurrentTime", this.currentTime); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.currentTime = compound.getInteger("CurrentTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.currentTime = compound.getInteger("CurrentTime"); + } } @Override public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ @@ -117,13 +120,8 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements IRedst } @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java index 5e6bbfd03..e87cb1b6c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCanolaPress.java @@ -25,7 +25,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IFluidSaver, net.minecraftforge.fluids.IFluidHandler{ +public class TileEntityCanolaPress extends TileEntityInventoryBase implements IEnergyReceiver, net.minecraftforge.fluids.IFluidHandler{ public static final int PRODUCE = 80; public static final int ENERGY_USE = 35; @@ -62,19 +62,23 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - compound.setInteger("ProcessTime", this.currentProcessTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("ProcessTime", this.currentProcessTime); + } this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - this.currentProcessTime = compound.getInteger("ProcessTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + this.currentProcessTime = compound.getInteger("ProcessTime"); + } this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -149,26 +153,6 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IE return true; } - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - - @Override - public FluidStack[] getFluids(){ - return new FluidStack[]{this.tank.getFluid()}; - } - - @Override - public void setFluids(FluidStack[] fluids){ - this.tank.setFluid(fluids[0]); - } - @Override public FluidTank getFluidHandler(EnumFacing facing){ return facing != EnumFacing.UP ? this.tank : null; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java index a9aa91d9f..8a721f8eb 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoalGenerator.java @@ -19,7 +19,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider, IEnergySaver{ +public class TileEntityCoalGenerator extends TileEntityInventoryBase implements IEnergyProvider{ public static final int PRODUCE = 30; public final EnergyStorage storage = new EnergyStorage(60000); @@ -44,19 +44,23 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - compound.setInteger("BurnTime", this.currentBurnTime); - compound.setInteger("MaxBurnTime", this.maxBurnTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("BurnTime", this.currentBurnTime); + compound.setInteger("MaxBurnTime", this.maxBurnTime); + } this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - this.currentBurnTime = compound.getInteger("BurnTime"); - this.maxBurnTime = compound.getInteger("MaxBurnTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + this.currentBurnTime = compound.getInteger("BurnTime"); + this.maxBurnTime = compound.getInteger("MaxBurnTime"); + } this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -127,14 +131,4 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements public boolean canConnectEnergy(EnumFacing from){ return true; } - - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java index 0ecf07b9d..4d9962f43 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCoffeeMachine.java @@ -31,7 +31,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, IFluidSaver, IEnergySaver, net.minecraftforge.fluids.IFluidHandler{ +public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements IButtonReactor, IEnergyReceiver, net.minecraftforge.fluids.IFluidHandler{ public static final int SLOT_COFFEE_BEANS = 0; public static final int SLOT_INPUT = 1; @@ -85,21 +85,25 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); - compound.setInteger("Cache", this.coffeeCacheAmount); - compound.setInteger("Time", this.brewTime); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("Cache", this.coffeeCacheAmount); + compound.setInteger("Time", this.brewTime); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); - this.coffeeCacheAmount = compound.getInteger("Cache"); - this.brewTime = compound.getInteger("Time"); + if(type != NBTType.SAVE_BLOCK){ + this.coffeeCacheAmount = compound.getInteger("Cache"); + this.brewTime = compound.getInteger("Time"); + } } @Override @@ -218,26 +222,6 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements return true; } - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - - @Override - public FluidStack[] getFluids(){ - return new FluidStack[]{this.tank.getFluid()}; - } - - @Override - public void setFluids(FluidStack[] fluids){ - this.tank.setFluid(fluids[0]); - } - @Override public FluidTank getFluidHandler(EnumFacing facing){ return facing != EnumFacing.DOWN ? this.tank : null; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java index c97aae9e3..b309a9fd3 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityCompost.java @@ -36,9 +36,11 @@ public class TileEntityCompost extends TileEntityInventoryBase{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("ConversionTime", this.conversionTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("ConversionTime", this.conversionTime); + } } @Override @@ -47,9 +49,11 @@ public class TileEntityCompost extends TileEntityInventoryBase{ } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.conversionTime = compound.getInteger("ConversionTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.conversionTime = compound.getInteger("ConversionTime"); + } } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java index 7e04cd372..d99148ad7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDirectionalBreaker.java @@ -28,38 +28,41 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver, IRedstoneToggle{ +public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int RANGE = 8; public static final int ENERGY_USE = 5; public final EnergyStorage storage = new EnergyStorage(10000); private int lastEnergy; private int currentTime; - private boolean activateOnceWithSignal; public TileEntityDirectionalBreaker(){ super(9, "directionalBreaker"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - compound.setInteger("CurrentTime", this.currentTime); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("CurrentTime", this.currentTime); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - this.currentTime = compound.getInteger("CurrentTime"); + if(type != NBTType.SAVE_BLOCK){ + this.currentTime = compound.getInteger("CurrentTime"); + } } @Override public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ @@ -144,24 +147,10 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase implem return true; } - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - - @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java index d6c9ef76d..d1769dce5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDisplayStand.java @@ -74,14 +74,14 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.writeSyncableNBT(compound, isForSync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.readSyncableNBT(compound, isForSync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java index f0af92a6c..c0fc0e9c0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityDropper.java @@ -16,32 +16,35 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; -public class TileEntityDropper extends TileEntityInventoryBase implements IRedstoneToggle{ +public class TileEntityDropper extends TileEntityInventoryBase{ private int currentTime; - private boolean activateOnceWithSignal; public TileEntityDropper(){ super(9, "dropper"); } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("CurrentTime", this.currentTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("CurrentTime", this.currentTime); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.currentTime = compound.getInteger("CurrentTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.currentTime = compound.getInteger("CurrentTime"); + } } @Override public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ @@ -95,13 +98,8 @@ public class TileEntityDropper extends TileEntityInventoryBase implements IRedst } @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java index be8b561ce..aec10a9e7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnergizer.java @@ -19,7 +19,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver{ +public class TileEntityEnergizer extends TileEntityInventoryBase implements IEnergyReceiver{ public final EnergyStorage storage = new EnergyStorage(500000); private int lastEnergy; @@ -29,15 +29,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -104,14 +104,4 @@ public class TileEntityEnergizer extends TileEntityInventoryBase implements IEne public boolean canConnectEnergy(EnumFacing from){ return true; } - - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java index d040975ff..526c968f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityEnervator.java @@ -19,7 +19,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider, IEnergySaver{ +public class TileEntityEnervator extends TileEntityInventoryBase implements IEnergyProvider{ public final EnergyStorage storage = new EnergyStorage(500000); private int lastEnergy; @@ -29,15 +29,15 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -104,14 +104,4 @@ public class TileEntityEnervator extends TileEntityInventoryBase implements IEne public boolean canExtractItem(int slot, ItemStack stack, EnumFacing side){ return slot == 1; } - - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java index b8cf54224..59c47d9ae 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFeeder.java @@ -41,19 +41,19 @@ public class TileEntityFeeder extends TileEntityInventoryBase{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); compound.setInteger("Timer", this.currentTimer); - if(sync){ + if(type == NBTType.SYNC){ compound.setInteger("Animals", this.currentAnimalAmount); } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.currentTimer = compound.getInteger("Timer"); - if(sync){ + if(type == NBTType.SYNC){ this.currentAnimalAmount = compound.getInteger("Animals"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java index 1919c1f60..490690db6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFermentingBarrel.java @@ -21,7 +21,7 @@ import net.minecraftforge.fluids.capability.templates.FluidHandlerFluidMap; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityFermentingBarrel extends TileEntityBase implements IFluidSaver, net.minecraftforge.fluids.IFluidHandler{ +public class TileEntityFermentingBarrel extends TileEntityBase implements net.minecraftforge.fluids.IFluidHandler{ private static final int PROCESS_TIME = 100; public final FluidTank canolaTank = new FluidTank(2*Util.BUCKET){ @@ -51,21 +51,21 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IFluid } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ compound.setInteger("ProcessTime", this.currentProcessTime); this.canolaTank.writeToNBT(compound); NBTTagCompound tag = new NBTTagCompound(); this.oilTank.writeToNBT(tag); compound.setTag("OilTank", tag); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ this.currentProcessTime = compound.getInteger("ProcessTime"); this.canolaTank.readFromNBT(compound); this.oilTank.readFromNBT((NBTTagCompound)compound.getTag("OilTank")); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -122,18 +122,6 @@ public class TileEntityFermentingBarrel extends TileEntityBase implements IFluid return map; } - @Override - public FluidStack[] getFluids(){ - return new FluidStack[]{this.oilTank.getFluid(), this.canolaTank.getFluid()}; - } - - @Override - public void setFluids(FluidStack[] fluids){ - this.oilTank.setFluid(fluids[0]); - this.canolaTank.setFluid(fluids[1]); - } - - @Override public int fill(EnumFacing from, FluidStack resource, boolean doFill){ IFluidHandler handler = this.getFluidHandler(from); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java index 3158917d6..7d9792b6f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFireworkBox.java @@ -25,12 +25,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IRedstoneToggle, IEnergyDisplay, IEnergySaver{ +public class TileEntityFireworkBox extends TileEntityBase implements IEnergyReceiver, IEnergyDisplay{ public static final int USE_PER_SHOT = 300; public final EnergyStorage storage = new EnergyStorage(20000); private int timeUntilNextFirework; - private boolean activateOnceWithSignal; private int oldEnergy; public TileEntityFireworkBox(){ @@ -94,21 +93,21 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @Override public void updateEntity(){ if(!this.worldObj.isRemote){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.timeUntilNextFirework > 0){ this.timeUntilNextFirework--; if(this.timeUntilNextFirework <= 0){ @@ -155,13 +154,8 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece } @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override @@ -174,11 +168,6 @@ public class TileEntityFireworkBox extends TileEntityBase implements IEnergyRece return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java index 9b41dc36c..31708fe00 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFishingNet.java @@ -37,15 +37,19 @@ public class TileEntityFishingNet extends TileEntityBase{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("TimeUntilNextDrop", this.timeUntilNextDrop); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.timeUntilNextDrop = compound.getInteger("TimeUntilNextDrop"); + } } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java index a4290361f..4bf35d1c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFluidCollector.java @@ -26,7 +26,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityFluidCollector extends TileEntityBase implements IFluidSaver, IRedstoneToggle, net.minecraftforge.fluids.IFluidHandler{ +public class TileEntityFluidCollector extends TileEntityBase implements net.minecraftforge.fluids.IFluidHandler{ public final FluidTank tank = new FluidTank(8*Util.BUCKET){ @Override @@ -42,7 +42,6 @@ public class TileEntityFluidCollector extends TileEntityBase implements IFluidSa public boolean isPlacer; private int lastTankAmount; private int currentTime; - private boolean activateOnceWithSignal; public TileEntityFluidCollector(String name){ super(name); @@ -54,13 +53,8 @@ public class TileEntityFluidCollector extends TileEntityBase implements IFluidSa } @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override @@ -115,16 +109,20 @@ public class TileEntityFluidCollector extends TileEntityBase implements IFluidSa } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("CurrentTime", this.currentTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("CurrentTime", this.currentTime); + } this.tank.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.currentTime = compound.getInteger("CurrentTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.currentTime = compound.getInteger("CurrentTime"); + } this.tank.readFromNBT(compound); } @@ -132,7 +130,7 @@ public class TileEntityFluidCollector extends TileEntityBase implements IFluidSa public void updateEntity(){ super.updateEntity(); if(!this.worldObj.isRemote){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ @@ -155,16 +153,6 @@ public class TileEntityFluidCollector extends TileEntityBase implements IFluidSa return this.tank.getFluidAmount()*i/this.tank.getCapacity(); } - @Override - public FluidStack[] getFluids(){ - return new FluidStack[]{this.tank.getFluid()}; - } - - @Override - public void setFluids(FluidStack[] fluids){ - this.tank.setFluid(fluids[0]); - } - @Override public int fill(EnumFacing from, FluidStack resource, boolean doFill){ IFluidHandler handler = this.getFluidHandler(from); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java index 2c413edd4..be082c394 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceDouble.java @@ -20,7 +20,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver{ +public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int SLOT_INPUT_1 = 0; public static final int SLOT_OUTPUT_1 = 1; @@ -40,18 +40,22 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("FirstSmeltTime", this.firstSmeltTime); - compound.setInteger("SecondSmeltTime", this.secondSmeltTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("FirstSmeltTime", this.firstSmeltTime); + compound.setInteger("SecondSmeltTime", this.secondSmeltTime); + } this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.firstSmeltTime = compound.getInteger("FirstSmeltTime"); - this.secondSmeltTime = compound.getInteger("SecondSmeltTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.firstSmeltTime = compound.getInteger("FirstSmeltTime"); + this.secondSmeltTime = compound.getInteger("SecondSmeltTime"); + } this.storage.readFromNBT(compound); } @@ -191,14 +195,4 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements public boolean canConnectEnergy(EnumFacing from){ return true; } - - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java index 93a66acfc..9410bdd33 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityFurnaceSolar.java @@ -19,7 +19,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider, IEnergySaver, IEnergyDisplay{ +public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyProvider, IEnergyDisplay{ public static final int PRODUCE = 8; public final EnergyStorage storage = new EnergyStorage(30000); @@ -50,14 +50,14 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @@ -93,11 +93,6 @@ public class TileEntityFurnaceSolar extends TileEntityBase implements IEnergyPro return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGreenhouseGlass.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGreenhouseGlass.java index baa7033e4..f459950c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGreenhouseGlass.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGreenhouseGlass.java @@ -29,15 +29,19 @@ public class TileEntityGreenhouseGlass extends TileEntityBase{ } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.writeSyncableNBT(compound, isForSync); - this.timeUntilNextFert = compound.getInteger("Time"); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.timeUntilNextFert = compound.getInteger("Time"); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.readSyncableNBT(compound, isForSync); - compound.setInteger("Time", this.timeUntilNextFert); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("Time", this.timeUntilNextFert); + } } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java index 2ac70128e..0c7ebacef 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityGrinder.java @@ -27,7 +27,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.List; -public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver{ +public class TileEntityGrinder extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int SLOT_INPUT_1 = 0; public static final int SLOT_OUTPUT_1_1 = 1; @@ -74,19 +74,23 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - compound.setInteger("FirstCrushTime", this.firstCrushTime); - compound.setInteger("SecondCrushTime", this.secondCrushTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("FirstCrushTime", this.firstCrushTime); + compound.setInteger("SecondCrushTime", this.secondCrushTime); + } this.storage.writeToNBT(compound); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - this.firstCrushTime = compound.getInteger("FirstCrushTime"); - this.secondCrushTime = compound.getInteger("SecondCrushTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + this.firstCrushTime = compound.getInteger("FirstCrushTime"); + this.secondCrushTime = compound.getInteger("SecondCrushTime"); + } this.storage.readFromNBT(compound); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -263,14 +267,4 @@ public class TileEntityGrinder extends TileEntityInventoryBase implements IEnerg return slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2; } - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java index ce2b3ae11..14200ac28 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityHeatCollector.java @@ -25,7 +25,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; -public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider, IEnergySaver, IEnergyDisplay{ +public class TileEntityHeatCollector extends TileEntityBase implements IEnergyProvider, IEnergyDisplay{ public static final int ENERGY_PRODUCE = 40; public static final int BLOCKS_NEEDED = 4; @@ -37,14 +37,14 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.writeSyncableNBT(compound, isForSync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.readSyncableNBT(compound, isForSync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @@ -104,11 +104,6 @@ public class TileEntityHeatCollector extends TileEntityBase implements IEnergyPr return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java index 22b592c75..c9a6ca733 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInputter.java @@ -354,29 +354,33 @@ public class TileEntityInputter extends TileEntityInventoryBase implements IButt } @Override - 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); - compound.setInteger("SideToPull", this.sideToPull); - compound.setInteger("SlotToPull", this.slotToPullStart); - compound.setInteger("SlotToPullEnd", this.slotToPullEnd); - compound.setBoolean("PullWhitelist", this.isPullWhitelist); - compound.setBoolean("PutWhitelist", this.isPutWhitelist); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("SideToPut", this.sideToPut); + compound.setInteger("SlotToPut", this.slotToPutStart); + compound.setInteger("SlotToPutEnd", this.slotToPutEnd); + compound.setInteger("SideToPull", this.sideToPull); + compound.setInteger("SlotToPull", this.slotToPullStart); + compound.setInteger("SlotToPullEnd", this.slotToPullEnd); + compound.setBoolean("PullWhitelist", this.isPullWhitelist); + compound.setBoolean("PutWhitelist", this.isPutWhitelist); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - this.sideToPut = compound.getInteger("SideToPut"); - this.slotToPutStart = compound.getInteger("SlotToPut"); - this.slotToPutEnd = compound.getInteger("SlotToPutEnd"); - this.sideToPull = compound.getInteger("SideToPull"); - this.slotToPullStart = compound.getInteger("SlotToPull"); - this.slotToPullEnd = compound.getInteger("SlotToPullEnd"); - this.isPullWhitelist = compound.getBoolean("PullWhitelist"); - this.isPutWhitelist = compound.getBoolean("PutWhitelist"); - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + this.sideToPut = compound.getInteger("SideToPut"); + this.slotToPutStart = compound.getInteger("SlotToPut"); + this.slotToPutEnd = compound.getInteger("SlotToPutEnd"); + this.sideToPull = compound.getInteger("SideToPull"); + this.slotToPullStart = compound.getInteger("SlotToPull"); + this.slotToPullEnd = compound.getInteger("SlotToPullEnd"); + this.isPullWhitelist = compound.getBoolean("PullWhitelist"); + this.isPutWhitelist = compound.getBoolean("PutWhitelist"); + } + super.readSyncableNBT(compound, type); } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java index fc5e1bfff..758f83c92 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityInventoryBase.java @@ -68,9 +68,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.writeSyncableNBT(compound, isForSync); - if(!isForSync || this.shouldSyncSlots()){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type == NBTType.SAVE_TILE || (type == NBTType.SYNC && this.shouldSyncSlots())){ saveSlots(this.slots, compound); } } @@ -80,9 +80,9 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.readSyncableNBT(compound, isForSync); - if(!isForSync || this.shouldSyncSlots()){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type == NBTType.SAVE_TILE || (type == NBTType.SYNC && this.shouldSyncSlots())){ loadSlots(this.slots, compound); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java index eb626dfe6..4b9c8fb5c 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityItemRepairer.java @@ -20,7 +20,7 @@ import net.minecraft.util.EnumFacing; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver, IEnergySaver{ +public class TileEntityItemRepairer extends TileEntityInventoryBase implements IEnergyReceiver{ public static final int SLOT_INPUT = 0; public static final int SLOT_OUTPUT = 1; @@ -56,16 +56,20 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - compound.setInteger("NextRepairTick", this.nextRepairTick); - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("NextRepairTick", this.nextRepairTick); + } + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - this.nextRepairTick = compound.getInteger("NextRepairTick"); - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + this.nextRepairTick = compound.getInteger("NextRepairTick"); + } + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @@ -147,14 +151,4 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I public boolean canConnectEnergy(EnumFacing from){ return true; } - - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java index 65eb218e9..0391f274e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLaserRelayItemWhitelist.java @@ -194,9 +194,9 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.writeSyncableNBT(compound, isForSync); - if(!isForSync){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type == NBTType.SAVE_TILE){ TileEntityInventoryBase.saveSlots(this.slots, compound); } compound.setBoolean("LeftWhitelist", this.isLeftWhitelist); @@ -204,9 +204,9 @@ public class TileEntityLaserRelayItemWhitelist extends TileEntityLaserRelayItem } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ - super.readSyncableNBT(compound, isForSync); - if(!isForSync){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type == NBTType.SAVE_TILE){ TileEntityInventoryBase.loadSlots(this.slots, compound); } this.isLeftWhitelist = compound.getBoolean("LeftWhitelist"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java index 3654c5778..8b36fa650 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLavaFactoryController.java @@ -23,7 +23,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyReceiver, IEnergySaver, IEnergyDisplay{ +public class TileEntityLavaFactoryController extends TileEntityBase implements IEnergyReceiver, IEnergyDisplay{ public static final int NOT_MULTI = 0; public static final int HAS_LAVA = 1; @@ -38,17 +38,21 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - compound.setInteger("WorkTime", this.currentWorkTime); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("WorkTime", this.currentWorkTime); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - this.currentWorkTime = compound.getInteger("WorkTime"); + if(type != NBTType.SAVE_BLOCK){ + this.currentWorkTime = compound.getInteger("WorkTime"); + } } @Override @@ -119,11 +123,6 @@ public class TileEntityLavaFactoryController extends TileEntityBase implements I return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java index 29447fa9a..7ba2f2805 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityLeafGenerator.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyProvider, IEnergySaver, IEnergyDisplay{ +public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyProvider, IEnergyDisplay{ public static final int RANGE = 7; public static final int ENERGY_PRODUCED = 300; @@ -39,14 +39,14 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); } @@ -128,11 +128,6 @@ public class TileEntityLeafGenerator extends TileEntityBase implements IEnergyPr return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java index 097791f9e..5518d04b7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityMiner.java @@ -35,13 +35,13 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.List; -public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergySaver, IEnergyDisplay{ +public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyReceiver, IButtonReactor, IEnergyDisplay{ public static final int ENERGY_USE_PER_BLOCK = 1000; public static final int DEFAULT_RANGE = 2; public final EnergyStorage storage = new EnergyStorage(200000); public int layerAt = -1; - public boolean onlyMineOres = true; + public boolean onlyMineOres; private int oldLayerAt; private int oldEnergy; @@ -50,18 +50,24 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); this.storage.writeToNBT(compound); - compound.setInteger("Layer", this.layerAt); - compound.setBoolean("OnlyOres", this.onlyMineOres); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("Layer", this.layerAt); + } + if(type != NBTType.SAVE_BLOCK || this.onlyMineOres){ + compound.setBoolean("OnlyOres", this.onlyMineOres); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.storage.readFromNBT(compound); - this.layerAt = compound.getInteger("Layer"); + if(type != NBTType.SAVE_BLOCK){ + this.layerAt = compound.getInteger("Layer"); + } this.onlyMineOres = compound.getBoolean("OnlyOres"); } @@ -232,11 +238,6 @@ public class TileEntityMiner extends TileEntityInventoryBase implements IEnergyR return this.storage.getEnergyStored(); } - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - @Override @SideOnly(Side.CLIENT) public int getMaxEnergy(){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java index d4621656d..b5f040978 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityOilGenerator.java @@ -22,7 +22,7 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public class TileEntityOilGenerator extends TileEntityBase implements IEnergyProvider, IEnergySaver, IFluidSaver, net.minecraftforge.fluids.IFluidHandler{ +public class TileEntityOilGenerator extends TileEntityBase implements IEnergyProvider, net.minecraftforge.fluids.IFluidHandler{ public static final int ENERGY_PRODUCED = 76; private static final int BURN_TIME = 100; @@ -63,19 +63,23 @@ public class TileEntityOilGenerator extends TileEntityBase implements IEnergyPro } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - compound.setInteger("BurnTime", this.currentBurnTime); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("BurnTime", this.currentBurnTime); + } this.storage.writeToNBT(compound); this.tank.writeToNBT(compound); - super.writeSyncableNBT(compound, sync); + super.writeSyncableNBT(compound, type); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - this.currentBurnTime = compound.getInteger("BurnTime"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + if(type != NBTType.SAVE_BLOCK){ + this.currentBurnTime = compound.getInteger("BurnTime"); + } this.storage.readFromNBT(compound); this.tank.readFromNBT(compound); - super.readSyncableNBT(compound, sync); + super.readSyncableNBT(compound, type); } @Override @@ -134,26 +138,6 @@ public class TileEntityOilGenerator extends TileEntityBase implements IEnergyPro return facing != EnumFacing.DOWN ? this.tank : null; } - @Override - public int getEnergy(){ - return this.storage.getEnergyStored(); - } - - @Override - public void setEnergy(int energy){ - this.storage.setEnergyStored(energy); - } - - @Override - public FluidStack[] getFluids(){ - return new FluidStack[]{this.tank.getFluid()}; - } - - @Override - public void setFluids(FluidStack[] fluids){ - this.tank.setFluid(fluids[0]); - } - @Override public int fill(EnumFacing from, FluidStack resource, boolean doFill){ IFluidHandler handler = this.getFluidHandler(from); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java index 439742590..d0f7a930d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomPlacer.java @@ -29,14 +29,13 @@ import net.minecraftforge.fml.relauncher.SideOnly; import java.util.ArrayList; -public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile, IRedstoneToggle{ +public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements IPhantomTile{ public static final int RANGE = 3; public BlockPos boundPosition; public int currentTime; public int range; public boolean isBreaker; - private boolean activateOnceWithSignal; private int oldRange; public TileEntityPhantomPlacer(int slots, String name){ @@ -49,26 +48,30 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("Range", this.range); - if(this.boundPosition != null){ - compound.setInteger("XCoordOfTileStored", this.boundPosition.getX()); - compound.setInteger("YCoordOfTileStored", this.boundPosition.getY()); - compound.setInteger("ZCoordOfTileStored", this.boundPosition.getZ()); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("Range", this.range); + if(this.boundPosition != null){ + compound.setInteger("XCoordOfTileStored", this.boundPosition.getX()); + compound.setInteger("YCoordOfTileStored", this.boundPosition.getY()); + compound.setInteger("ZCoordOfTileStored", this.boundPosition.getZ()); + } } } @Override - 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"); - this.range = compound.getInteger("Range"); - if(!(x == 0 && y == 0 && z == 0)){ - this.boundPosition = new BlockPos(x, y, z); - this.markDirty(); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + int x = compound.getInteger("XCoordOfTileStored"); + int y = compound.getInteger("YCoordOfTileStored"); + int z = compound.getInteger("ZCoordOfTileStored"); + this.range = compound.getInteger("Range"); + if(!(x == 0 && y == 0 && z == 0)){ + this.boundPosition = new BlockPos(x, y, z); + this.markDirty(); + } } } @@ -83,7 +86,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } if(this.isBoundThingInRange()){ - if(!this.isRedstonePowered && !this.activateOnceWithSignal){ + if(!this.isRedstonePowered && !this.isPulseMode){ if(this.currentTime > 0){ this.currentTime--; if(this.currentTime <= 0){ @@ -207,13 +210,8 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements } @Override - public void toggle(boolean to){ - this.activateOnceWithSignal = to; - } - - @Override - public boolean isPulseMode(){ - return this.activateOnceWithSignal; + public boolean isRedstoneToggle(){ + return true; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java index 18718d2f4..55d0991fd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPhantomface.java @@ -57,26 +57,30 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setInteger("Range", this.range); - if(this.boundPosition != null){ - compound.setInteger("XCoordOfTileStored", this.boundPosition.getX()); - compound.setInteger("YCoordOfTileStored", this.boundPosition.getY()); - compound.setInteger("ZCoordOfTileStored", this.boundPosition.getZ()); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setInteger("Range", this.range); + if(this.boundPosition != null){ + compound.setInteger("XCoordOfTileStored", this.boundPosition.getX()); + compound.setInteger("YCoordOfTileStored", this.boundPosition.getY()); + compound.setInteger("ZCoordOfTileStored", this.boundPosition.getZ()); + } } } @Override - 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"); - this.range = compound.getInteger("Range"); - if(!(x == 0 && y == 0 && z == 0)){ - this.boundPosition = new BlockPos(x, y, z); - this.markDirty(); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + int x = compound.getInteger("XCoordOfTileStored"); + int y = compound.getInteger("YCoordOfTileStored"); + int z = compound.getInteger("ZCoordOfTileStored"); + this.range = compound.getInteger("Range"); + if(!(x == 0 && y == 0 && z == 0)){ + this.boundPosition = new BlockPos(x, y, z); + this.markDirty(); + } } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java index e386e9c6e..524cd1af6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityPlayerInterface.java @@ -76,17 +76,17 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ this.storage.writeToNBT(compound); - if(this.connectedPlayer != null){ + if(this.connectedPlayer != null && type != NBTType.SAVE_BLOCK){ compound.setUniqueId("Player", this.connectedPlayer); } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){ + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ this.storage.readFromNBT(compound); - if(compound.hasKey("PlayerLeast")){ + if(compound.hasKey("PlayerLeast") && type != NBTType.SAVE_BLOCK){ this.connectedPlayer = compound.getUniqueId("Player"); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java index 34eb9fff8..caedbe252 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityRangedCollector.java @@ -33,15 +33,19 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - compound.setBoolean("Whitelist", this.isWhitelist); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + compound.setBoolean("Whitelist", this.isWhitelist); + } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.isWhitelist = compound.getBoolean("Whitelist"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.isWhitelist = compound.getBoolean("Whitelist"); + } } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java index 820b0b8f9..155508cf0 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntitySmileyCloud.java @@ -25,17 +25,19 @@ public class TileEntitySmileyCloud extends TileEntityBase implements IStringReac } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); - if(this.name != null){ + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); + if(this.name != null && type != NBTType.SAVE_BLOCK){ compound.setString("Name", this.name); } } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); - this.name = compound.getString("Name"); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); + if(type != NBTType.SAVE_BLOCK){ + this.name = compound.getString("Name"); + } } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java index 5cd50e63c..cf5190a36 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java @@ -98,14 +98,14 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I } @Override - public void writeSyncableNBT(NBTTagCompound compound, boolean sync){ - super.writeSyncableNBT(compound, sync); + public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ + super.writeSyncableNBT(compound, type); compound.setShort("Amount", this.amount); } @Override - public void readSyncableNBT(NBTTagCompound compound, boolean sync){ - super.readSyncableNBT(compound, sync); + public void readSyncableNBT(NBTTagCompound compound, NBTType type){ + super.readSyncableNBT(compound, type); this.amount = compound.getShort("Amount"); }