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.
This commit is contained in:
SenseiKiwi 2014-07-11 04:10:12 -04:00
parent 29c8a09218
commit 1bf1f4f78c
4 changed files with 25 additions and 6 deletions

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -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
{