Updated transformation API

Fixed vanilla lever rotation
This commit is contained in:
LemADEC 2017-08-06 15:38:01 +02:00
parent 73343649d6
commit cf19a2f729
35 changed files with 177 additions and 74 deletions

View file

@ -4,9 +4,10 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public interface IBlockTransformer {
// Return true if this transformer is applicable to that TileEntity.
// Return true if this transformer is applicable to that block.
boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity);
// Called when preparing to save a ship structure.
@ -17,23 +18,26 @@ public interface IBlockTransformer {
// Use this to save external data in the ship schematic.
// You don't need to save Block and TileEntity data here, it's already covered.
// Warning: do NOT assume that the ship will be removed!
NBTBase saveExternals(final TileEntity tileEntity);
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.
// 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(TileEntity tileEntity);
void remove(final TileEntity tileEntity);
// Called when restoring a ship in the world.
// Use this to apply metadata & NBT rotation, right before block & tile entity placement.
// Use priority placement to ensure dependent blocks are placed first.
// Warning: do NOT place the block or tile entity!
int rotate(final Block block, int metadata, NBTTagCompound nbtTileEntity, ITransformation transformation);
int rotate(final Block block, int metadata, final NBTTagCompound nbtTileEntity, final ITransformation transformation);
// Called when placing back a ship in the world.
// 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.
void restoreExternals(TileEntity tileEntity, ITransformation transformation, NBTBase nbtBase);
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);
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatAdvancedRepulsionSystems implements IBlockTransformer {
@ -42,7 +43,7 @@ public class CompatAdvancedRepulsionSystems implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -114,7 +115,7 @@ public class CompatAdvancedRepulsionSystems implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -16,6 +16,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatAppliedEnergistics2 implements IBlockTransformer {
@ -67,7 +68,7 @@ public class CompatAppliedEnergistics2 implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -186,7 +187,7 @@ public class CompatAppliedEnergistics2 implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -57,7 +57,7 @@ public class CompatArsMagica2 implements IBlockTransformer {
@Override
@Optional.Method(modid = "arsmagica2")
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(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) {
return PowerNodeRegistry.For(tileEntity.getWorldObj()).getDataCompoundForNode((IPowerNode) tileEntity);
}
@ -127,7 +127,7 @@ public class CompatArsMagica2 implements IBlockTransformer {
@Override
@Optional.Method(modid = "arsmagica2")
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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;
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatBiblioCraft implements IBlockTransformer {
@ -39,7 +40,7 @@ public class CompatBiblioCraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -132,7 +133,9 @@ public class CompatBiblioCraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
public class CompatBotania implements IBlockTransformer {
@ -42,7 +43,7 @@ public class CompatBotania implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -111,7 +112,7 @@ public class CompatBotania implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -13,6 +13,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatBuildCraft implements IBlockTransformer {
@ -59,7 +60,7 @@ public class CompatBuildCraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -240,7 +241,7 @@ public class CompatBuildCraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatCarpentersBlocks implements IBlockTransformer {
@ -71,7 +72,7 @@ public class CompatCarpentersBlocks implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -341,7 +342,9 @@ public class CompatCarpentersBlocks implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatComputerCraft implements IBlockTransformer {
@ -42,7 +43,7 @@ public class CompatComputerCraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -132,7 +133,9 @@ public class CompatComputerCraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatCustomNpcs implements IBlockTransformer {
@ -48,7 +49,7 @@ public class CompatCustomNpcs implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -162,7 +163,9 @@ public class CompatCustomNpcs implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -16,6 +16,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
@ -45,7 +46,7 @@ public class CompatEnderIO implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -306,7 +307,9 @@ public class CompatEnderIO implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatEvilCraft implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatEvilCraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -77,7 +78,9 @@ public class CompatEvilCraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -52,7 +52,7 @@ public class CompatForgeMultipart implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -176,7 +176,9 @@ public class CompatForgeMultipart implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -44,7 +44,7 @@ public class CompatImmersiveEngineering implements IBlockTransformer {
@Override
@Optional.Method(modid = "ImmersiveEngineering")
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
if (tileEntity instanceof IImmersiveConnectable) {
ChunkCoordinates node = new ChunkCoordinates(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
Collection<Connection> connections = ImmersiveNetHandler.INSTANCE.getConnections(tileEntity.getWorldObj(), node);
@ -92,7 +92,9 @@ public class CompatImmersiveEngineering implements IBlockTransformer {
@Override
@Optional.Method(modid = "ImmersiveEngineering")
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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) {
NBTTagList nbtImmersiveEngineering = (NBTTagList) nbtBase;
if (nbtImmersiveEngineering == null) {
return;

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatIndustrialCraft2 implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatIndustrialCraft2 implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -68,7 +69,9 @@ public class CompatIndustrialCraft2 implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatJABBA implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatJABBA implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -118,7 +119,9 @@ public class CompatJABBA implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -12,6 +12,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatMekanism implements IBlockTransformer {
@ -38,7 +39,7 @@ public class CompatMekanism implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -119,7 +120,9 @@ public class CompatMekanism implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatMetallurgy implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatMetallurgy implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -70,7 +71,9 @@ public class CompatMetallurgy implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatNatura implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatNatura implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -71,7 +72,9 @@ public class CompatNatura implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatOpenComputers implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatOpenComputers implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -68,7 +69,9 @@ public class CompatOpenComputers implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -10,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
public class CompatPneumaticCraft implements IBlockTransformer {
@ -35,7 +36,8 @@ public class CompatPneumaticCraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -187,7 +189,9 @@ public class CompatPneumaticCraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatRedstonePaste implements IBlockTransformer {
@ -33,7 +34,7 @@ public class CompatRedstonePaste implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -198,7 +199,9 @@ public class CompatRedstonePaste implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -12,6 +12,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
public class CompatSGCraft implements IBlockTransformer {
@ -58,7 +59,7 @@ public class CompatSGCraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -113,7 +114,9 @@ public class CompatSGCraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
public class CompatStargateTech2 implements IBlockTransformer {
@ -52,7 +53,7 @@ public class CompatStargateTech2 implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -149,7 +150,9 @@ public class CompatStargateTech2 implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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 (classTileTransportRing.isInstance(tileEntity)) {
try {
methodTileTransportRing_link.invoke(tileEntity);

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatTConstruct implements IBlockTransformer {
@ -45,7 +46,7 @@ public class CompatTConstruct implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -100,7 +101,9 @@ public class CompatTConstruct implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
public class CompatTechguns implements IBlockTransformer {
@ -43,7 +44,7 @@ public class CompatTechguns implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -214,7 +215,9 @@ public class CompatTechguns implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
@ -60,7 +61,7 @@ public class CompatThaumcraft implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -337,7 +338,9 @@ public class CompatThaumcraft implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -12,6 +12,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatThermalDynamics implements IBlockTransformer {
@ -38,7 +39,7 @@ public class CompatThermalDynamics implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -103,7 +104,9 @@ public class CompatThermalDynamics implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -8,6 +8,7 @@ import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class CompatThermalExpansion implements IBlockTransformer {
@ -34,7 +35,7 @@ public class CompatThermalExpansion implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
public NBTBase saveExternals(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
// nothing to do
return null;
}
@ -140,7 +141,9 @@ public class CompatThermalExpansion implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, 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
}
}

View file

@ -3,14 +3,20 @@ package cr0s.warpdrive.compat;
import cr0s.warpdrive.api.IBlockTransformer;
import cr0s.warpdrive.api.ITransformation;
import cr0s.warpdrive.block.breathing.BlockAirFlow;
import cr0s.warpdrive.block.breathing.BlockAirSource;
import cr0s.warpdrive.block.energy.TileEntityEnergyBank;
import cr0s.warpdrive.block.hull.BlockHullSlab;
import cr0s.warpdrive.config.WarpDriveConfig;
import cr0s.warpdrive.data.StateAir;
import cr0s.warpdrive.event.ChunkHandler;
import net.minecraft.block.Block;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IWorldAccess;
import net.minecraft.world.World;
public class CompatWarpDrive implements IBlockTransformer {
@ -30,8 +36,17 @@ public class CompatWarpDrive implements IBlockTransformer {
}
@Override
public NBTBase saveExternals(final TileEntity tileEntity) {
// nothing to do
public NBTBase saveExternals(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 int dataAir = ChunkHandler.getChunkData(world, x, y, z).getDataAir(x, y, z);
if (dataAir == StateAir.AIR_DEFAULT) {
return null;
}
final NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setInteger("dataAir", dataAir);
return tagCompound;
}
return null;
}
@ -89,7 +104,18 @@ public class CompatWarpDrive implements IBlockTransformer {
}
@Override
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, NBTBase nbtBase) {
// nothing to do
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 (nbtBase == null) {
return;
}
if (!(nbtBase instanceof NBTTagCompound)) {
return;
}
if (((NBTTagCompound) nbtBase).hasKey("dataAir")) {
final int dataAir = ((NBTTagCompound) nbtBase).getInteger("dataAir");
ChunkHandler.getChunkData(world, x, y, z).setDataAir(x, y, z, dataAir);
}
}
}

View file

@ -339,7 +339,7 @@ public class ChunkData {
return dataAirSegment[indexData & 0xFFF];
}
protected void setDataAir(final int x, final int y, final int z, final int dataAirBlock) {
public void setDataAir(final int x, final int y, final int z, final int dataAirBlock) {
final int indexData = getDataIndex(x, y, z);
// get segment

View file

@ -71,7 +71,7 @@ public class JumpBlock {
public JumpBlock() {
}
public JumpBlock(Block block, int blockMeta, TileEntity tileEntity, int x, int y, int z) {
public JumpBlock(final World world, final int x, final int y, final int z, final Block block, final int blockMeta, final TileEntity tileEntity) {
this.block = block;
this.blockMeta = blockMeta;
blockTileEntity = tileEntity;
@ -82,7 +82,7 @@ public class JumpBlock {
// save externals
for (Entry<String, IBlockTransformer> entryBlockTransformer : WarpDriveConfig.blockTransformers.entrySet()) {
if (entryBlockTransformer.getValue().isApplicable(block, blockMeta, tileEntity)) {
NBTBase nbtBase = entryBlockTransformer.getValue().saveExternals(tileEntity);
NBTBase nbtBase = entryBlockTransformer.getValue().saveExternals(world, x, y, z, block, blockMeta, tileEntity);
setExternal(entryBlockTransformer.getKey(), nbtBase);
}
}
@ -137,7 +137,7 @@ public class JumpBlock {
private static final byte[] mrotStair = { 2, 3, 1, 0, 6, 7, 5, 4, 8, 9, 10, 11, 12, 13, 14, 15 };
private static final byte[] mrotSign = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3 }; // Sign, Skull
private static final byte[] mrotTrapDoor = { 3, 2, 0, 1, 7, 6, 4, 5, 11, 10, 8, 9, 15, 14, 12, 13 };
private static final byte[] mrotLever = { 7, 2, 3, 4, 1, 6, 5, 0, 15, 11, 12, 10, 9, 14, 13, 8 };
private static final byte[] mrotLever = { 7, 3, 4, 2, 1, 6, 5, 0, 15, 11, 12, 10, 9, 14, 13, 8 };
private static final byte[] mrotNetherPortal = { 0, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
private static final byte[] mrotVine = { 0, 2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15 };
private static final byte[] mrotButton = { 0, 3, 4, 2, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; // Button, torch (normal, redstone lit/unlit)

View file

@ -316,9 +316,9 @@ public class JumpShip {
return false;
}
int blockMeta = worldObj.getBlockMetadata(x, y, z);
TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
JumpBlock jumpBlock = new JumpBlock(block, blockMeta, tileEntity, x, y, z);
final int blockMeta = worldObj.getBlockMetadata(x, y, z);
final TileEntity tileEntity = worldObj.getTileEntity(x, y, z);
JumpBlock jumpBlock = new JumpBlock(worldObj, x, y, z, block, blockMeta, tileEntity);
if (jumpBlock.blockTileEntity != null && jumpBlock.externals != null) {
for (Entry<String, NBTBase> external : jumpBlock.externals.entrySet()) {

View file

@ -25,7 +25,7 @@ import net.minecraftforge.fluids.BlockFluidBase;
public class StateAir {
static final int AIR_DEFAULT = 0x060000C0; // default is the unknown state
public static final int AIR_DEFAULT = 0x060000C0; // default is the unknown state
// highest bit is unusable since Java only supports signed primitives (mostly)
static final int USED_MASK = 0b01110111111111111111111100001111;

View file

@ -918,7 +918,8 @@ public class JumpSequencer extends AbstractSequencer {
ChunkCoordinates target = transformation.apply(jumpBlock.x, jumpBlock.y, jumpBlock.z);
TileEntity newTileEntity = targetWorld.getTileEntity(target.posX, target.posY, target.posZ);
blockTransformer.restoreExternals(newTileEntity, transformation, external.getValue());
blockTransformer.restoreExternals(targetWorld, target.posX, target.posY, target.posZ,
jumpBlock.block, jumpBlock.blockMeta, newTileEntity, transformation, external.getValue());
}
}
index++;