Added IronChest, MetalChests, Roots and StorageDrawers compatibility
This commit is contained in:
parent
233b4a413c
commit
6055e3392a
6 changed files with 419 additions and 0 deletions
90
src/main/java/cr0s/warpdrive/compat/CompatIronChest.java
Normal file
90
src/main/java/cr0s/warpdrive/compat/CompatIronChest.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
package cr0s.warpdrive.compat;
|
||||
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.api.ITransformation;
|
||||
import cr0s.warpdrive.api.WarpDriveText;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
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 CompatIronChest implements IBlockTransformer {
|
||||
|
||||
private static Class<?> classBlockIronChest;
|
||||
private static Class<?> classBlockIronShulkerBox;
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
classBlockIronChest = Class.forName("cpw.mods.ironchest.common.blocks.chest.BlockIronChest");
|
||||
classBlockIronShulkerBox = Class.forName("cpw.mods.ironchest.common.blocks.shulker.BlockIronShulkerBox");
|
||||
|
||||
WarpDriveConfig.registerBlockTransformer("IronChests", new CompatIronChest());
|
||||
} catch(final ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||
return classBlockIronChest.isInstance(block)
|
||||
|| classBlockIronShulkerBox .isInstance(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJumpReady(final Block block, final int metadata, final TileEntity tileEntity, final WarpDriveText reason) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
}
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
private static final byte[] rotFacing = { 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();
|
||||
if (rotationSteps == 0 || nbtTileEntity == null) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// Iron chests and shulker boxes
|
||||
if (nbtTileEntity.hasKey("facing")) {
|
||||
final byte facing = nbtTileEntity.getByte("facing");
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
nbtTileEntity.setByte("facing", rotFacing[facing]);
|
||||
break;
|
||||
case 2:
|
||||
nbtTileEntity.setByte("facing", rotFacing[rotFacing[facing]]);
|
||||
break;
|
||||
case 3:
|
||||
nbtTileEntity.setByte("facing", rotFacing[rotFacing[rotFacing[facing]]]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@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) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
98
src/main/java/cr0s/warpdrive/compat/CompatMetalChests.java
Normal file
98
src/main/java/cr0s/warpdrive/compat/CompatMetalChests.java
Normal file
|
@ -0,0 +1,98 @@
|
|||
package cr0s.warpdrive.compat;
|
||||
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.api.ITransformation;
|
||||
import cr0s.warpdrive.api.WarpDriveText;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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 CompatMetalChests implements IBlockTransformer {
|
||||
|
||||
private static Class<?> classBlockMetalChest;
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
classBlockMetalChest = Class.forName("T145.metalchests.blocks.BlockMetalChest");
|
||||
|
||||
WarpDriveConfig.registerBlockTransformer("MetalChests", new CompatMetalChests());
|
||||
} catch(final ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||
return classBlockMetalChest.isInstance(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJumpReady(final Block block, final int metadata, final TileEntity tileEntity, final WarpDriveText reason) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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 Map<String, String> rotFacingNames;
|
||||
static {
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
map.put("north", "east");
|
||||
map.put("east", "south");
|
||||
map.put("south", "west");
|
||||
map.put("west", "north");
|
||||
rotFacingNames = Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int rotate(final Block block, final int metadata, final NBTTagCompound nbtTileEntity, final ITransformation transformation) {
|
||||
final byte rotationSteps = transformation.getRotationSteps();
|
||||
if (rotationSteps == 0 || nbtTileEntity == null) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// Metal chests (sorting are untested)
|
||||
if (nbtTileEntity.hasKey("Front")) {
|
||||
final String facing = nbtTileEntity.getString("Front");
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
nbtTileEntity.setString("Front", rotFacingNames.get(facing));
|
||||
break;
|
||||
case 2:
|
||||
nbtTileEntity.setString("Front", rotFacingNames.get(rotFacingNames.get(facing)));
|
||||
break;
|
||||
case 3:
|
||||
nbtTileEntity.setString("Front", rotFacingNames.get(rotFacingNames.get(rotFacingNames.get(facing))));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@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) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
83
src/main/java/cr0s/warpdrive/compat/CompatRoots.java
Normal file
83
src/main/java/cr0s/warpdrive/compat/CompatRoots.java
Normal file
|
@ -0,0 +1,83 @@
|
|||
package cr0s.warpdrive.compat;
|
||||
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.api.ITransformation;
|
||||
import cr0s.warpdrive.api.WarpDriveText;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
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 CompatRoots implements IBlockTransformer {
|
||||
|
||||
private static Class<?> classBlockOffertoryPlate;
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
classBlockOffertoryPlate = Class.forName("teamroots.roots.block.BlockOffertoryPlate");
|
||||
|
||||
WarpDriveConfig.registerBlockTransformer("Roots", new CompatRoots());
|
||||
} catch(final ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||
return classBlockOffertoryPlate.isInstance(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJumpReady(final Block block, final int metadata, final TileEntity tileEntity, final WarpDriveText reason) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
}
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
private static final int[] rotFacing = { 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();
|
||||
if (rotationSteps == 0) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// Offertory plate
|
||||
if (classBlockOffertoryPlate.isInstance(block)) {
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
return rotFacing[metadata];
|
||||
case 2:
|
||||
return rotFacing[rotFacing[metadata]];
|
||||
case 3:
|
||||
return rotFacing[rotFacing[rotFacing[metadata]]];
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@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) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
123
src/main/java/cr0s/warpdrive/compat/CompatStorageDrawers.java
Normal file
123
src/main/java/cr0s/warpdrive/compat/CompatStorageDrawers.java
Normal file
|
@ -0,0 +1,123 @@
|
|||
package cr0s.warpdrive.compat;
|
||||
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.api.ITransformation;
|
||||
import cr0s.warpdrive.api.WarpDriveText;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
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 CompatStorageDrawers implements IBlockTransformer {
|
||||
|
||||
private static Class<?> classBlockController; // controller = metadata rotation com.jaquadro.minecraft.storagedrawers.block.BlockController
|
||||
private static Class<?> classBlockDrawers; // basic/custom/compacting drawers = byte Dir com.jaquadro.minecraft.storagedrawers.block.BlockDrawers
|
||||
private static Class<?> classBlockFramingTable; // framing table = metadata rotation + side com.jaquadro.minecraft.storagedrawers.block.BlockFramingTable
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
classBlockController = Class.forName("com.jaquadro.minecraft.storagedrawers.block.BlockController");
|
||||
classBlockDrawers = Class.forName("com.jaquadro.minecraft.storagedrawers.block.BlockDrawers");
|
||||
classBlockFramingTable = Class.forName("com.jaquadro.minecraft.storagedrawers.block.BlockFramingTable");
|
||||
|
||||
WarpDriveConfig.registerBlockTransformer("StorageDrawers", new CompatStorageDrawers());
|
||||
} catch(final ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||
return classBlockController.isInstance(block)
|
||||
|| classBlockDrawers.isInstance(block)
|
||||
|| classBlockFramingTable.isInstance(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJumpReady(final Block block, final int metadata, final TileEntity tileEntity, final WarpDriveText reason) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
}
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
private static final byte[] rotFacing = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
private static final byte[] rotFramingTable = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 13, 12, 10, 11, 14, 15 };
|
||||
|
||||
@Override
|
||||
public int rotate(final Block block, final int metadata, final NBTTagCompound nbtTileEntity, final ITransformation transformation) {
|
||||
final byte rotationSteps = transformation.getRotationSteps();
|
||||
if (rotationSteps == 0 || nbtTileEntity == null) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// controller
|
||||
if (classBlockController.isInstance(block)) {
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
return rotFacing[metadata];
|
||||
case 2:
|
||||
return rotFacing[rotFacing[metadata]];
|
||||
case 3:
|
||||
return rotFacing[rotFacing[rotFacing[metadata]]];
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
// basic/custom/compacting drawers
|
||||
if (nbtTileEntity.hasKey("Dir")) {
|
||||
final byte facing = nbtTileEntity.getByte("Dir");
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
nbtTileEntity.setByte("Dir", rotFacing[facing]);
|
||||
break;
|
||||
case 2:
|
||||
nbtTileEntity.setByte("Dir", rotFacing[rotFacing[facing]]);
|
||||
break;
|
||||
case 3:
|
||||
nbtTileEntity.setByte("Dir", rotFacing[rotFacing[rotFacing[facing]]]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// framing table
|
||||
if (classBlockFramingTable.isInstance(block)) {
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
return rotFramingTable[metadata];
|
||||
case 2:
|
||||
return rotFramingTable[rotFramingTable[metadata]];
|
||||
case 3:
|
||||
return rotFramingTable[rotFramingTable[rotFramingTable[metadata]]];
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@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) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
|
@ -123,6 +123,7 @@ public class Dictionary {
|
|||
// @TODO MC1.12 config.get("block_tags", "ic2:blockPersonal" , "Anchor SkipMining").getString(); // IC2 personal chest, need property filtering
|
||||
// @TODO MC1.12 config.get("block_tags", "malisisdoors:null" , "Anchor").getString(); // improper registration of block causing NPE
|
||||
config.get("block_tags", "malisisdoors:rustyhatch" , "Anchor").getString();
|
||||
config.get("block_tags", "storagedrawers:framingtable" , "Anchor").getString(); // invalid metadata conversion, see https://github.com/jaquadro/StorageDrawers/issues/683
|
||||
config.get("block_tags", "warpdrive:bedrock_glass" , "Anchor StopMining NoBlink").getString();
|
||||
|
||||
// placement priorities
|
||||
|
|
|
@ -18,16 +18,20 @@ import cr0s.warpdrive.compat.CompatEvilCraft;
|
|||
import cr0s.warpdrive.compat.CompatForgeMultipart;
|
||||
import cr0s.warpdrive.compat.CompatImmersiveEngineering;
|
||||
import cr0s.warpdrive.compat.CompatIndustrialCraft2;
|
||||
import cr0s.warpdrive.compat.CompatIronChest;
|
||||
import cr0s.warpdrive.compat.CompatJABBA;
|
||||
import cr0s.warpdrive.compat.CompatMekanism;
|
||||
import cr0s.warpdrive.compat.CompatMetalChests;
|
||||
import cr0s.warpdrive.compat.CompatMetallurgy;
|
||||
import cr0s.warpdrive.compat.CompatNatura;
|
||||
import cr0s.warpdrive.compat.CompatOpenComputers;
|
||||
import cr0s.warpdrive.compat.CompatParziStarWars;
|
||||
import cr0s.warpdrive.compat.CompatPneumaticCraft;
|
||||
import cr0s.warpdrive.compat.CompatRedstonePaste;
|
||||
import cr0s.warpdrive.compat.CompatRoots;
|
||||
import cr0s.warpdrive.compat.CompatSGCraft;
|
||||
import cr0s.warpdrive.compat.CompatStargateTech2;
|
||||
import cr0s.warpdrive.compat.CompatStorageDrawers;
|
||||
import cr0s.warpdrive.compat.CompatTConstruct;
|
||||
import cr0s.warpdrive.compat.CompatTechguns;
|
||||
import cr0s.warpdrive.compat.CompatThaumcraft;
|
||||
|
@ -1265,6 +1269,11 @@ public class WarpDriveConfig {
|
|||
CompatEvilCraft.register();
|
||||
}
|
||||
|
||||
final boolean isIronChestLoaded = Loader.isModLoaded("ironchest");
|
||||
if (isIronChestLoaded) {
|
||||
CompatIronChest.register();
|
||||
}
|
||||
|
||||
final boolean isJABBAloaded = Loader.isModLoaded("JABBA");
|
||||
if (isJABBAloaded) {
|
||||
CompatJABBA.register();
|
||||
|
@ -1275,6 +1284,11 @@ public class WarpDriveConfig {
|
|||
CompatMekanism.register();
|
||||
}
|
||||
|
||||
final boolean isMetalChestsLoaded = Loader.isModLoaded("metalchests");
|
||||
if (isMetalChestsLoaded) {
|
||||
CompatMetalChests.register();
|
||||
}
|
||||
|
||||
final boolean isMetallurgyLoaded = Loader.isModLoaded("Metallurgy");
|
||||
if (isMetallurgyLoaded) {
|
||||
CompatMetallurgy.register();
|
||||
|
@ -1290,6 +1304,11 @@ public class WarpDriveConfig {
|
|||
CompatPneumaticCraft.register();
|
||||
}
|
||||
|
||||
final boolean isRootsLoaded = Loader.isModLoaded("roots");
|
||||
if (isRootsLoaded) {
|
||||
CompatRoots.register();
|
||||
}
|
||||
|
||||
final boolean isParziStarWarsLoaded = Loader.isModLoaded("starwarsmod");
|
||||
if (isParziStarWarsLoaded) {
|
||||
CompatParziStarWars.register();
|
||||
|
@ -1310,6 +1329,11 @@ public class WarpDriveConfig {
|
|||
CompatStargateTech2.register();
|
||||
}
|
||||
|
||||
final boolean isStorageDrawersLoaded = Loader.isModLoaded("storagedrawers");
|
||||
if (isStorageDrawersLoaded) {
|
||||
CompatStorageDrawers.register();
|
||||
}
|
||||
|
||||
final boolean isTConstructLoaded = Loader.isModLoaded("tconstruct");
|
||||
if (isTConstructLoaded) {
|
||||
CompatTConstruct.register();
|
||||
|
|
Loading…
Reference in a new issue