From 1bf1f4f78c7db0e410dec147bedb0b50780af138 Mon Sep 17 00:00:00 2001 From: SenseiKiwi Date: Fri, 11 Jul 2014 04:10:12 -0400 Subject: [PATCH] Improved Regeneration Code 1. Added code so that Transdimensional Trapdoors detect that they have been broken and schedule rift regeneration at their location. This had previously been neglected. Trapdoors deserve a little more attention. 2. Tweaked the breakBlock() code for BlockRift and BaseDimDoor so that rift regeneration is only scheduled if the underlying block was removed. We don't want that to happen if the only change was for metadata. --- .../mod_pocketDim/blocks/BaseDimDoor.java | 7 +++++-- .../mod_pocketDim/blocks/BlockRift.java | 7 +++++-- .../mod_pocketDim/blocks/TransTrapdoor.java | 14 ++++++++++++++ .../tileentities/TileEntityTransTrapdoor.java | 3 +-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java index 782acfa7..de8db5bc 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BaseDimDoor.java @@ -441,7 +441,10 @@ public abstract class BaseDimDoor extends BlockDoor implements IDimDoor, ITileEn // We MUST call super.breakBlock() since it involves removing tile entities super.breakBlock(world, x, y, z, oldBlockID, oldMeta); - // Schedule rift regeneration for this block - mod_pocketDim.riftRegenerator.scheduleFastRegeneration(x, y, z, world); + // Schedule rift regeneration for this block if it was replaced + if (world.getBlockId(x, y, z) != oldBlockID) + { + mod_pocketDim.riftRegenerator.scheduleFastRegeneration(x, y, z, world); + } } } \ No newline at end of file diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java index c7f85085..64009782 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/BlockRift.java @@ -466,7 +466,10 @@ public class BlockRift extends Block implements ITileEntityProvider // We MUST call super.breakBlock() since it involves removing tile entities super.breakBlock(world, x, y, z, oldBlockID, oldMeta); - // Schedule rift regeneration for this block - mod_pocketDim.riftRegenerator.scheduleSlowRegeneration(x, y, z, world); + // Schedule rift regeneration for this block if it was changed + if (world.getBlockId(x, y, z) != oldBlockID) + { + mod_pocketDim.riftRegenerator.scheduleSlowRegeneration(x, y, z, world); + } } } \ No newline at end of file diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java index 4a1df0d3..aefb2772 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/blocks/TransTrapdoor.java @@ -140,4 +140,18 @@ public class TransTrapdoor extends BlockTrapDoor implements IDimDoor, ITileEntit world.setBlockTileEntity(x, y, z, te); return te; } + + @Override + public void breakBlock(World world, int x, int y, int z, int oldBlockID, int oldMeta) + { + // This function runs on the server side after a block is replaced + // We MUST call super.breakBlock() since it involves removing tile entities + super.breakBlock(world, x, y, z, oldBlockID, oldMeta); + + // Schedule rift regeneration for this block if it was replaced + if (world.getBlockId(x, y, z) != oldBlockID) + { + mod_pocketDim.riftRegenerator.scheduleFastRegeneration(x, y, z, world); + } + } } \ No newline at end of file diff --git a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java index d26b46fd..25cc3b4c 100644 --- a/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java +++ b/src/main/java/StevenDimDoors/mod_pocketDim/tileentities/TileEntityTransTrapdoor.java @@ -1,9 +1,8 @@ package StevenDimDoors.mod_pocketDim.tileentities; import java.util.Random; + import StevenDimDoors.mod_pocketDim.mod_pocketDim; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; public class TileEntityTransTrapdoor extends DDTileEntityBase {