mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Add automatic migration API to BlockDummyable
This commit is contained in:
parent
41d62c49db
commit
4a869ae2ea
@ -77,27 +77,20 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
|
|||||||
|
|
||||||
super.onNeighborBlockChange(world, x, y, z, block);
|
super.onNeighborBlockChange(world, x, y, z, block);
|
||||||
|
|
||||||
if(world.isRemote || safeRem)
|
if(safeRem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int metadata = world.getBlockMetadata(x, y, z);
|
destroyIfOrphan(world, x, y, z);
|
||||||
|
|
||||||
// if it's an extra, remove the extra-ness
|
|
||||||
if(metadata >= extra)
|
|
||||||
metadata -= extra;
|
|
||||||
|
|
||||||
ForgeDirection dir = ForgeDirection.getOrientation(metadata).getOpposite();
|
|
||||||
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
|
||||||
|
|
||||||
if(b != this) {
|
|
||||||
world.setBlockToAir(x, y, z);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTick(World world, int x, int y, int z, Random rand) {
|
public void updateTick(World world, int x, int y, int z, Random rand) {
|
||||||
|
|
||||||
super.updateTick(world, x, y, z, rand);
|
super.updateTick(world, x, y, z, rand);
|
||||||
|
|
||||||
|
destroyIfOrphan(world, x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destroyIfOrphan(World world, int x, int y, int z) {
|
||||||
if(world.isRemote)
|
if(world.isRemote)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -111,9 +104,26 @@ public abstract class BlockDummyable extends BlockContainer implements ICustomBl
|
|||||||
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
Block b = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||||
|
|
||||||
if(b != this) {
|
if(b != this) {
|
||||||
world.setBlockToAir(x, y, z);
|
if (isLegacyMonoblock(world, x, y, z)) {
|
||||||
|
fixLegacyMonoblock(world, x, y, z);
|
||||||
|
} else {
|
||||||
|
world.setBlockToAir(x, y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override this when turning a single block into a pseudo-multiblock.
|
||||||
|
// If this returns true, instead of being deleted as an orphan, the block
|
||||||
|
// will be promoted to a core of a dummyable, however without any dummies.
|
||||||
|
// This is only called if the block is presumed an orphan, so you don't
|
||||||
|
// need to check that here.
|
||||||
|
protected boolean isLegacyMonoblock(World world, int x, int y, int z) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void fixLegacyMonoblock(World world, int x, int y, int z) {
|
||||||
|
// Promote to a lone core block with the same effective rotation as before the change
|
||||||
|
world.setBlockMetadataWithNotify(x, y, z, offset + world.getBlockMetadata(x, y, z), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] findCore(World world, int x, int y, int z) {
|
public int[] findCore(World world, int x, int y, int z) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user