From b6ee1cacc50dec9ee65d30d8d62f0fbe1591bdc7 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 21 Mar 2016 02:46:32 +1000 Subject: Final version of safes for now. Cleaned up some handler code and left some new classes in for future use. Also, skipped a build and brought a fresh one along. --- .../base/GregtechMetaSafeBlockBase.java | 28 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java') diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java index 76b87b0b9b..7e6eb1d9cf 100644 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java @@ -7,6 +7,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import miscutil.core.handler.UnbreakableBlockManager; import miscutil.core.util.PlayerCache; import miscutil.core.util.Utils; import net.minecraft.entity.player.EntityPlayer; @@ -17,6 +18,8 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; public int mSuccess = 0, mTargetStackSize = 0; public String ownerUUID = ""; + UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + private boolean value_last = false, value_current = false; public GregtechMetaSafeBlockBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); @@ -198,7 +201,7 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered Utils.LOG_WARNING("OwnerUUID is Null, let's set it."); Utils.LOG_WARNING("Accessing Players UUID is: "+tempUUID); ownerUUID = tempUUID; - Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again."); + //Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again."); Utils.LOG_WARNING("Block Owner is now set to: "+ownerUUID); } Utils.LOG_WARNING("No, it is not."); @@ -273,13 +276,28 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered /*if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) { */ if (aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) { - - if (bUnbreakable = true){ - + value_last = value_current; + value_current = bUnbreakable; + if (value_last != value_current){ + Utils.LOG_WARNING("VALUE CHANGE - Ticking for a moment."); + if (bUnbreakable == true){ + //Xasda.setmTileEntity((BaseMetaTileEntity) aBaseMetaTileEntity); + //Utils.LOG_ERROR("Safe is Indestructible."); + this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setResistance(Float.MAX_VALUE); + this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setBlockUnbreakable(); + } + else { + //Xasda.setmTileEntity((BaseMetaTileEntity) aBaseMetaTileEntity); + //Utils.LOG_ERROR("Safe is not Indestructible."); + this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setResistance(1F); + this.getBaseMetaTileEntity().getBlock(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()).setHardness(2); + + } } else { - + } + -- cgit