Added BiblioCraft compatibility
Improved Tinker's Construct drying rack compatibility
This commit is contained in:
parent
7f1bbcbda8
commit
ef5828ecba
3 changed files with 164 additions and 9 deletions
132
src/main/java/cr0s/warpdrive/compat/CompatBiblioCraft.java
Normal file
132
src/main/java/cr0s/warpdrive/compat/CompatBiblioCraft.java
Normal file
|
@ -0,0 +1,132 @@
|
|||
package cr0s.warpdrive.compat;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.api.ITransformation;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
public class CompatBiblioCraft implements IBlockTransformer {
|
||||
|
||||
private static Class<?> classBlockArmorStand;
|
||||
private static Class<?> classBlockPrintingPress;
|
||||
|
||||
public static void register() {
|
||||
try {
|
||||
classBlockArmorStand = Class.forName("jds.bibliocraft.blocks.BlockArmorStand");
|
||||
classBlockPrintingPress = Class.forName("jds.bibliocraft.blocks.BlockPrintPress");
|
||||
WarpDriveConfig.registerBlockTransformer("BiblioCraft", new CompatBiblioCraft());
|
||||
} catch(ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||
return block != null && block.getClass().getCanonicalName().startsWith("jds.bibliocraft.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isJumpReady(TileEntity tileEntity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTBase saveExternals(final TileEntity tileEntity) {
|
||||
// nothing to do
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(TileEntity tileEntity) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
private static final byte[] mrotArmorStand = { 1, 2, 3, 0, 5, 6, 7, 4, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
private static final int[] rotAngle = { 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
private static final int[] rotCaseAngle = { 0, 1, 2, 3, 5, 6, 7, 4, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
|
||||
@Override
|
||||
public int rotate(final Block block, final int metadata, NBTTagCompound nbtTileEntity, final byte rotationSteps, final float rotationYaw) {
|
||||
if (rotationSteps == 0) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
// metadata rotations
|
||||
if (classBlockArmorStand.isInstance(block) || classBlockPrintingPress.isInstance(block)) {
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
return mrotArmorStand[metadata];
|
||||
case 2:
|
||||
return mrotArmorStand[mrotArmorStand[metadata]];
|
||||
case 3:
|
||||
return mrotArmorStand[mrotArmorStand[mrotArmorStand[metadata]]];
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
// tile entity rotations
|
||||
String key = null;
|
||||
if (nbtTileEntity.hasKey("angle")) {
|
||||
key = "angle";
|
||||
} else if (nbtTileEntity.hasKey("Angle")) {
|
||||
key = "Angle";
|
||||
} else if (nbtTileEntity.hasKey("deskAngle")) {
|
||||
key = "deskAngle";
|
||||
} else if (nbtTileEntity.hasKey("labelAngle")) {
|
||||
key = "labelAngle";
|
||||
} else if (nbtTileEntity.hasKey("bookcaseAngle")) {
|
||||
key = "bookcaseAngle";
|
||||
} else if (nbtTileEntity.hasKey("rackAngle")) {
|
||||
key = "rackAngle";
|
||||
} else if (nbtTileEntity.hasKey("genericShelfAngle")) {
|
||||
key = "genericShelfAngle";
|
||||
} else if (nbtTileEntity.hasKey("potionshelfAngle")) {
|
||||
key = "potionshelfAngle";
|
||||
}
|
||||
if (key != null) {
|
||||
int angle = nbtTileEntity.getInteger(key);
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
nbtTileEntity.setInteger(key, rotAngle[angle]);
|
||||
return metadata;
|
||||
case 2:
|
||||
nbtTileEntity.setInteger(key, rotAngle[rotAngle[angle]]);
|
||||
return metadata;
|
||||
case 3:
|
||||
nbtTileEntity.setInteger(key, rotAngle[rotAngle[rotAngle[angle]]]);
|
||||
return metadata;
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (nbtTileEntity.hasKey("caseAngle")) {
|
||||
int angle = nbtTileEntity.getInteger("caseAngle");
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
nbtTileEntity.setInteger("caseAngle", rotCaseAngle[angle]);
|
||||
return metadata;
|
||||
case 2:
|
||||
nbtTileEntity.setInteger("caseAngle", rotCaseAngle[rotCaseAngle[angle]]);
|
||||
return metadata;
|
||||
case 3:
|
||||
nbtTileEntity.setInteger("caseAngle", rotCaseAngle[rotCaseAngle[rotCaseAngle[angle]]]);
|
||||
return metadata;
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, NBTBase nbtBase) {
|
||||
// nothing to do
|
||||
}
|
||||
}
|
|
@ -4,13 +4,13 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.api.ITransformation;
|
||||
import cr0s.warpdrive.config.WarpDriveConfig;
|
||||
|
||||
public class CompatTConstruct implements IBlockTransformer {
|
||||
|
||||
private static Class<?> classBlockDryingRack;
|
||||
private static Class<?> classTileFurnaceLogic;
|
||||
private static Class<?> classTileFaucetLogic;
|
||||
private static Class<?> classTileSmelteryDrainLogic;
|
||||
|
@ -18,11 +18,12 @@ public class CompatTConstruct implements IBlockTransformer {
|
|||
|
||||
public static void register() {
|
||||
try {
|
||||
classBlockDryingRack = Class.forName("tconstruct.armor.blocks.DryingRack");
|
||||
classTileFurnaceLogic = Class.forName("tconstruct.tools.logic.FurnaceLogic");
|
||||
classTileFaucetLogic = Class.forName("tconstruct.smeltery.logic.FaucetLogic");
|
||||
classTileSmelteryDrainLogic = Class.forName("tconstruct.smeltery.logic.SmelteryDrainLogic");
|
||||
classTileSmelteryLogic = Class.forName("tconstruct.smeltery.logic.SmelteryLogic");
|
||||
WarpDriveConfig.registerBlockTransformer("TinkersConstruct", new CompatTConstruct());
|
||||
WarpDriveConfig.registerBlockTransformer("TConstruct", new CompatTConstruct());
|
||||
} catch(ClassNotFoundException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
@ -30,7 +31,8 @@ public class CompatTConstruct implements IBlockTransformer {
|
|||
|
||||
@Override
|
||||
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||
return classTileFurnaceLogic.isInstance(tileEntity)
|
||||
return classBlockDryingRack.isInstance(block)
|
||||
|| classTileFurnaceLogic.isInstance(tileEntity)
|
||||
|| classTileFaucetLogic.isInstance(tileEntity)
|
||||
|| classTileSmelteryDrainLogic.isInstance(tileEntity)
|
||||
|| classTileSmelteryLogic.isInstance(tileEntity);
|
||||
|
@ -52,7 +54,8 @@ public class CompatTConstruct implements IBlockTransformer {
|
|||
// nothing to do
|
||||
}
|
||||
|
||||
private static final byte[] mrot = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
private static final int[] mrotDryingRack = { 0, 1, 5, 4, 2, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
private static final byte[] rotDirection = { 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, NBTTagCompound nbtTileEntity, final byte rotationSteps, final float rotationYaw) {
|
||||
|
@ -60,22 +63,37 @@ public class CompatTConstruct implements IBlockTransformer {
|
|||
return metadata;
|
||||
}
|
||||
|
||||
// metadata = 2 5 3 4 Drying rack
|
||||
if (classBlockDryingRack.isInstance(block)) {
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
return mrotDryingRack[metadata];
|
||||
case 2:
|
||||
return mrotDryingRack[mrotDryingRack[metadata]];
|
||||
case 3:
|
||||
return mrotDryingRack[mrotDryingRack[mrotDryingRack[metadata]]];
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
if (nbtTileEntity.hasKey("Direction")) {
|
||||
short direction = nbtTileEntity.getByte("Direction");
|
||||
switch (rotationSteps) {
|
||||
case 1:
|
||||
nbtTileEntity.setByte("Direction", mrot[direction]);
|
||||
nbtTileEntity.setByte("Direction", rotDirection[direction]);
|
||||
return metadata;
|
||||
case 2:
|
||||
nbtTileEntity.setByte("Direction", mrot[mrot[direction]]);
|
||||
nbtTileEntity.setByte("Direction", rotDirection[rotDirection[direction]]);
|
||||
return metadata;
|
||||
case 3:
|
||||
nbtTileEntity.setByte("Direction", mrot[mrot[mrot[direction]]]);
|
||||
nbtTileEntity.setByte("Direction", rotDirection[rotDirection[rotDirection[direction]]]);
|
||||
return metadata;
|
||||
default:
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
|||
import cr0s.warpdrive.WarpDrive;
|
||||
import cr0s.warpdrive.api.IBlockTransformer;
|
||||
import cr0s.warpdrive.compat.CompatArsMagica2;
|
||||
import cr0s.warpdrive.compat.CompatBiblioCraft;
|
||||
import cr0s.warpdrive.compat.CompatComputerCraft;
|
||||
import cr0s.warpdrive.compat.CompatEnderIO;
|
||||
import cr0s.warpdrive.compat.CompatImmersiveEngineering;
|
||||
|
@ -768,10 +769,14 @@ public class WarpDriveConfig {
|
|||
CompatEnderIO.register();
|
||||
}
|
||||
isAdvancedRepulsionSystemLoaded = Loader.isModLoaded("AdvancedRepulsionSystems");
|
||||
boolean isTConstructloaded = Loader.isModLoaded("TConstruct");
|
||||
if (isTConstructloaded) {
|
||||
boolean isTConstructLoaded = Loader.isModLoaded("TConstruct");
|
||||
if (isTConstructLoaded) {
|
||||
CompatTConstruct.register();
|
||||
}
|
||||
boolean isBibliocraftLoaded = Loader.isModLoaded("BiblioCraft");
|
||||
if (isBibliocraftLoaded) {
|
||||
CompatBiblioCraft.register();
|
||||
}
|
||||
}
|
||||
|
||||
public static void onFMLPostInitialization() {
|
||||
|
|
Loading…
Reference in a new issue