diff --git a/src/main/java/cr0s/warpdrive/api/IBlockTransformer.java b/src/main/java/cr0s/warpdrive/api/IBlockTransformer.java index b4ff542d..3a507539 100644 --- a/src/main/java/cr0s/warpdrive/api/IBlockTransformer.java +++ b/src/main/java/cr0s/warpdrive/api/IBlockTransformer.java @@ -21,11 +21,12 @@ public interface IBlockTransformer { NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity); - // Called when removing the original ship structure. + // Called when removing the original ship structure, if saveExternals() returned non-null for that block. // Use this to prevents drops, clear energy networks, etc. // Block and TileEntity will be removed right after this call. // When moving, the new ship is placed first. - void remove(final TileEntity tileEntity); + void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity); // Called when restoring a ship in the world. // Use this to apply metadata & NBT rotation, right before block & tile entity placement. @@ -33,7 +34,7 @@ public interface IBlockTransformer { // Warning: do NOT place the block or tile entity! int rotate(final Block block, int metadata, final NBTTagCompound nbtTileEntity, final ITransformation transformation); - // Called when placing back a ship in the world. + // Called when placing back a ship in the world, if saveExternals() returned non-null for that block. // Use this to restore external data from the ship schematic, right after block & tile entity placement. // Use priority placement to ensure dependent blocks are placed first. // This is will be called whether saveExternals returned null or not. diff --git a/src/main/java/cr0s/warpdrive/compat/CompatAdvancedRepulsionSystems.java b/src/main/java/cr0s/warpdrive/compat/CompatAdvancedRepulsionSystems.java index d816b291..7b4d7003 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatAdvancedRepulsionSystems.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatAdvancedRepulsionSystems.java @@ -49,7 +49,8 @@ public class CompatAdvancedRepulsionSystems implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } @@ -115,7 +116,9 @@ public class CompatAdvancedRepulsionSystems implements IBlockTransformer { } @Override - public void restoreExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity, final ITransformation transformation, final NBTBase nbtBase) { + public void restoreExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity, + final ITransformation transformation, final NBTBase nbtBase) { // nothing to do } } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatAppliedEnergistics2.java b/src/main/java/cr0s/warpdrive/compat/CompatAppliedEnergistics2.java index d1ed648a..47ca9b14 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatAppliedEnergistics2.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatAppliedEnergistics2.java @@ -74,7 +74,8 @@ public class CompatAppliedEnergistics2 implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } @@ -187,7 +188,9 @@ public class CompatAppliedEnergistics2 implements IBlockTransformer { } @Override - public void restoreExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity, final ITransformation transformation, final NBTBase nbtBase) { + public void restoreExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity, + final ITransformation transformation, final NBTBase nbtBase) { // nothing to do } } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java b/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java index 287c8ccb..4b845f4c 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatArsMagica2.java @@ -66,7 +66,8 @@ public class CompatArsMagica2 implements IBlockTransformer { @Override @Optional.Method(modid = "arsmagica2") - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { if (tileEntity instanceof IPowerNode) { PowerNodeRegistry.For(tileEntity.getWorldObj()).removePowerNode((IPowerNode) tileEntity); } @@ -127,7 +128,9 @@ public class CompatArsMagica2 implements IBlockTransformer { @Override @Optional.Method(modid = "arsmagica2") - public void restoreExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity, final ITransformation transformation, final NBTBase nbtBase) { + public void restoreExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity, + final ITransformation transformation, final NBTBase nbtBase) { if (!(tileEntity instanceof IPowerNode) || nbtBase == null) { return; } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatBiblioCraft.java b/src/main/java/cr0s/warpdrive/compat/CompatBiblioCraft.java index 9bf1ea6d..621a6b61 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatBiblioCraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatBiblioCraft.java @@ -46,7 +46,8 @@ public class CompatBiblioCraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatBotania.java b/src/main/java/cr0s/warpdrive/compat/CompatBotania.java index 07d3aca0..6c6df182 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatBotania.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatBotania.java @@ -49,7 +49,8 @@ public class CompatBotania implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } @@ -116,7 +117,9 @@ public class CompatBotania implements IBlockTransformer { } @Override - public void restoreExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity, final ITransformation transformation, final NBTBase nbtBase) { + public void restoreExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity, + final ITransformation transformation, final NBTBase nbtBase) { // nothing to do } } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatBuildCraft.java b/src/main/java/cr0s/warpdrive/compat/CompatBuildCraft.java index 10a9862f..fd85764a 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatBuildCraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatBuildCraft.java @@ -66,7 +66,8 @@ public class CompatBuildCraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } @@ -241,7 +242,9 @@ public class CompatBuildCraft implements IBlockTransformer { } @Override - public void restoreExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity, final ITransformation transformation, final NBTBase nbtBase) { + public void restoreExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity, + final ITransformation transformation, final NBTBase nbtBase) { // nothing to do } } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatCarpentersBlocks.java b/src/main/java/cr0s/warpdrive/compat/CompatCarpentersBlocks.java index 756f75a2..dd292d88 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatCarpentersBlocks.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatCarpentersBlocks.java @@ -78,7 +78,8 @@ public class CompatCarpentersBlocks implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatComputerCraft.java b/src/main/java/cr0s/warpdrive/compat/CompatComputerCraft.java index ab24e3f2..0609b81d 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatComputerCraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatComputerCraft.java @@ -49,7 +49,8 @@ public class CompatComputerCraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatCustomNpcs.java b/src/main/java/cr0s/warpdrive/compat/CompatCustomNpcs.java index 7d07317b..e0ea6ffc 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatCustomNpcs.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatCustomNpcs.java @@ -55,7 +55,8 @@ public class CompatCustomNpcs implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatEnderIO.java b/src/main/java/cr0s/warpdrive/compat/CompatEnderIO.java index 86ba23ec..c60ed6d4 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatEnderIO.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatEnderIO.java @@ -52,7 +52,8 @@ public class CompatEnderIO implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatEvilCraft.java b/src/main/java/cr0s/warpdrive/compat/CompatEvilCraft.java index d06b4ff6..19c8a5be 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatEvilCraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatEvilCraft.java @@ -40,7 +40,8 @@ public class CompatEvilCraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatForgeMultipart.java b/src/main/java/cr0s/warpdrive/compat/CompatForgeMultipart.java index cbf2f98a..476249f2 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatForgeMultipart.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatForgeMultipart.java @@ -58,7 +58,8 @@ public class CompatForgeMultipart implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatImmersiveEngineering.java b/src/main/java/cr0s/warpdrive/compat/CompatImmersiveEngineering.java index 810d9cbc..7b60f8f2 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatImmersiveEngineering.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatImmersiveEngineering.java @@ -61,8 +61,8 @@ public class CompatImmersiveEngineering implements IBlockTransformer { } @Override - @Optional.Method(modid = "ImmersiveEngineering") - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatIndustrialCraft2.java b/src/main/java/cr0s/warpdrive/compat/CompatIndustrialCraft2.java index fd6628de..33a179ba 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatIndustrialCraft2.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatIndustrialCraft2.java @@ -41,10 +41,13 @@ public class CompatIndustrialCraft2 implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } + private static final short[] mrotFacing = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + @Override public int rotate(final Block block, final int metadata, final NBTTagCompound nbtTileEntity, final ITransformation transformation) { final byte rotationSteps = transformation.getRotationSteps(); @@ -66,17 +69,16 @@ public class CompatIndustrialCraft2 implements IBlockTransformer { return metadata; } - short facing = nbtTileEntity.getShort("facing"); - final short[] mrot = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; + final short facing = nbtTileEntity.getShort("facing"); switch (rotationSteps) { case 1: - nbtTileEntity.setShort("facing", mrot[facing]); + nbtTileEntity.setShort("facing", mrotFacing[facing]); return metadata; case 2: - nbtTileEntity.setShort("facing", mrot[mrot[facing]]); + nbtTileEntity.setShort("facing", mrotFacing[mrotFacing[facing]]); return metadata; case 3: - nbtTileEntity.setShort("facing", mrot[mrot[mrot[facing]]]); + nbtTileEntity.setShort("facing", mrotFacing[mrotFacing[mrotFacing[facing]]]); return metadata; default: return metadata; diff --git a/src/main/java/cr0s/warpdrive/compat/CompatJABBA.java b/src/main/java/cr0s/warpdrive/compat/CompatJABBA.java index 1cc78f27..94de017e 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatJABBA.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatJABBA.java @@ -40,7 +40,8 @@ public class CompatJABBA implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatMekanism.java b/src/main/java/cr0s/warpdrive/compat/CompatMekanism.java index dd178c96..d9068e43 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatMekanism.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatMekanism.java @@ -45,7 +45,8 @@ public class CompatMekanism implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatMetallurgy.java b/src/main/java/cr0s/warpdrive/compat/CompatMetallurgy.java index a37c2380..5f3acd19 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatMetallurgy.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatMetallurgy.java @@ -40,7 +40,8 @@ public class CompatMetallurgy implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatNatura.java b/src/main/java/cr0s/warpdrive/compat/CompatNatura.java index d690c49f..716ea308 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatNatura.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatNatura.java @@ -40,7 +40,8 @@ public class CompatNatura implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatOpenComputers.java b/src/main/java/cr0s/warpdrive/compat/CompatOpenComputers.java index 4d5f6bb1..3ca69308 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatOpenComputers.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatOpenComputers.java @@ -40,7 +40,8 @@ public class CompatOpenComputers implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatPneumaticCraft.java b/src/main/java/cr0s/warpdrive/compat/CompatPneumaticCraft.java index adb8ea2c..23802964 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatPneumaticCraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatPneumaticCraft.java @@ -42,7 +42,8 @@ public class CompatPneumaticCraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatRedstonePaste.java b/src/main/java/cr0s/warpdrive/compat/CompatRedstonePaste.java index e243147a..a2bec5d0 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatRedstonePaste.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatRedstonePaste.java @@ -40,7 +40,8 @@ public class CompatRedstonePaste implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatSGCraft.java b/src/main/java/cr0s/warpdrive/compat/CompatSGCraft.java index 43e67ee8..dbe93790 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatSGCraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatSGCraft.java @@ -65,7 +65,8 @@ public class CompatSGCraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java b/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java index abcfa135..cb15022a 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatStargateTech2.java @@ -59,7 +59,8 @@ public class CompatStargateTech2 implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatTConstruct.java b/src/main/java/cr0s/warpdrive/compat/CompatTConstruct.java index e819b45c..cdb1c82d 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatTConstruct.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatTConstruct.java @@ -52,7 +52,8 @@ public class CompatTConstruct implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatTechguns.java b/src/main/java/cr0s/warpdrive/compat/CompatTechguns.java index 15d242a4..beda5605 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatTechguns.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatTechguns.java @@ -50,7 +50,8 @@ public class CompatTechguns implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatThaumcraft.java b/src/main/java/cr0s/warpdrive/compat/CompatThaumcraft.java index 1e9db15e..3547aac6 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatThaumcraft.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatThaumcraft.java @@ -67,7 +67,8 @@ public class CompatThaumcraft implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatThermalDynamics.java b/src/main/java/cr0s/warpdrive/compat/CompatThermalDynamics.java index 63160833..8604d0dd 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatThermalDynamics.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatThermalDynamics.java @@ -45,7 +45,8 @@ public class CompatThermalDynamics implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatThermalExpansion.java b/src/main/java/cr0s/warpdrive/compat/CompatThermalExpansion.java index c5b94295..c60eb63c 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatThermalExpansion.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatThermalExpansion.java @@ -41,7 +41,8 @@ public class CompatThermalExpansion implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { // nothing to do } diff --git a/src/main/java/cr0s/warpdrive/compat/CompatWarpDrive.java b/src/main/java/cr0s/warpdrive/compat/CompatWarpDrive.java index 6288e304..9f09d8fc 100644 --- a/src/main/java/cr0s/warpdrive/compat/CompatWarpDrive.java +++ b/src/main/java/cr0s/warpdrive/compat/CompatWarpDrive.java @@ -28,6 +28,8 @@ public class CompatWarpDrive implements IBlockTransformer { @Override public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) { return block instanceof BlockHullSlab + || block instanceof BlockAirFlow + || block instanceof BlockAirSource || tileEntity instanceof TileEntityEnergyBank; } @@ -59,8 +61,18 @@ public class CompatWarpDrive implements IBlockTransformer { } @Override - public void remove(TileEntity tileEntity) { - // nothing to do + public void removeExternals(final World world, final int x, final int y, final int z, + final Block block, final int blockMeta, final TileEntity tileEntity) { + if (block instanceof BlockAirFlow || block instanceof BlockAirSource) { + final ChunkData chunkData = ChunkHandler.getChunkData(world, x, y, z, false); + if (chunkData == null) { + WarpDrive.logger.error(String.format("CompatWarpDrive trying to get data from an non-loaded chunk in %s @ (%d %d %d)", + world.provider.getDimensionName(), x, y, z)); + assert(false); + return; + } + chunkData.setDataAir(x, y, z, StateAir.AIR_DEFAULT); + } } private static final short[] mrotDirection = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; diff --git a/src/main/java/cr0s/warpdrive/data/JumpBlock.java b/src/main/java/cr0s/warpdrive/data/JumpBlock.java index 98d3888e..2c302198 100644 --- a/src/main/java/cr0s/warpdrive/data/JumpBlock.java +++ b/src/main/java/cr0s/warpdrive/data/JumpBlock.java @@ -82,7 +82,8 @@ public class JumpBlock { // save externals for (Entry entryBlockTransformer : WarpDriveConfig.blockTransformers.entrySet()) { if (entryBlockTransformer.getValue().isApplicable(block, blockMeta, tileEntity)) { - NBTBase nbtBase = entryBlockTransformer.getValue().saveExternals(world, x, y, z, block, blockMeta, tileEntity); + final NBTBase nbtBase = entryBlockTransformer.getValue().saveExternals(world, x, y, z, block, blockMeta, tileEntity); + // (we always save, even if null as a reminder on which transformer applies to this block) setExternal(entryBlockTransformer.getKey(), nbtBase); } } @@ -107,7 +108,7 @@ public class JumpBlock { } NBTBase nbtExternal = externals.get(modId); if (WarpDriveConfig.LOGGING_JUMPBLOCKS) { - WarpDrive.logger.info("Restoring " + modId + " externals at " + x + " " + y + " " + z + " " + nbtExternal); + WarpDrive.logger.info("Returning " + modId + " externals at " + x + " " + y + " " + z + " " + nbtExternal); } if (nbtExternal == null) { return null; diff --git a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java index af3153eb..222e1f5c 100644 --- a/src/main/java/cr0s/warpdrive/event/JumpSequencer.java +++ b/src/main/java/cr0s/warpdrive/event/JumpSequencer.java @@ -898,7 +898,7 @@ public class JumpSequencer extends AbstractSequencer { } int index = 0; while (index < blocksToMove && actualIndexInShip < ship.jumpBlocks.length) { - JumpBlock jumpBlock = ship.jumpBlocks[ship.jumpBlocks.length - actualIndexInShip - 1]; + final JumpBlock jumpBlock = ship.jumpBlocks[ship.jumpBlocks.length - actualIndexInShip - 1]; if (jumpBlock == null) { if (WarpDriveConfig.LOGGING_JUMP) { WarpDrive.logger.info(this + " Moving ship externals: unexpected null found at ship[" + actualIndexInShip + "]"); @@ -907,17 +907,18 @@ public class JumpSequencer extends AbstractSequencer { continue; } - if (jumpBlock.blockTileEntity != null && jumpBlock.externals != null) { + if (jumpBlock.externals != null) { if (WarpDriveConfig.LOGGING_JUMPBLOCKS) { WarpDrive.logger.info("Moving externals for block " + jumpBlock.block + "@" + jumpBlock.blockMeta + " at " + jumpBlock.x + " " + jumpBlock.y + " " + jumpBlock.z); } for (Entry external : jumpBlock.externals.entrySet()) { - IBlockTransformer blockTransformer = WarpDriveConfig.blockTransformers.get(external.getKey()); + final IBlockTransformer blockTransformer = WarpDriveConfig.blockTransformers.get(external.getKey()); if (blockTransformer != null) { - blockTransformer.remove(jumpBlock.blockTileEntity); + blockTransformer.removeExternals(sourceWorld, jumpBlock.x, jumpBlock.y, jumpBlock.z, + jumpBlock.block, jumpBlock.blockMeta, jumpBlock.blockTileEntity); - ChunkCoordinates target = transformation.apply(jumpBlock.x, jumpBlock.y, jumpBlock.z); - TileEntity newTileEntity = targetWorld.getTileEntity(target.posX, target.posY, target.posZ); + final ChunkCoordinates target = transformation.apply(jumpBlock.x, jumpBlock.y, jumpBlock.z); + final TileEntity newTileEntity = jumpBlock.blockTileEntity == null ? null : targetWorld.getTileEntity(target.posX, target.posY, target.posZ); blockTransformer.restoreExternals(targetWorld, target.posX, target.posY, target.posZ, jumpBlock.block, jumpBlock.blockMeta, newTileEntity, transformation, external.getValue()); }