Added EvilCraft rotation support
This commit is contained in:
parent
4ea98ab545
commit
6718764aaa
2 changed files with 87 additions and 0 deletions
82
src/main/java/cr0s/warpdrive/compat/CompatEvilCraft.java
Normal file
82
src/main/java/cr0s/warpdrive/compat/CompatEvilCraft.java
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
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 CompatEvilCraft implements IBlockTransformer {
|
||||||
|
|
||||||
|
private static Class<?> classBlockConfigurableBlockContainer;
|
||||||
|
|
||||||
|
public static void register() {
|
||||||
|
try {
|
||||||
|
classBlockConfigurableBlockContainer = Class.forName("evilcraft.core.config.configurable.ConfigurableBlockContainer");
|
||||||
|
WarpDriveConfig.registerBlockTransformer("evilcraft", new CompatEvilCraft());
|
||||||
|
} catch(ClassNotFoundException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
|
||||||
|
return classBlockConfigurableBlockContainer.isInstance(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isJumpReady(final Block block, final int metadata, final TileEntity tileEntity, StringBuilder reason) {
|
||||||
|
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 int[] rotRotation = { 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 ITransformation transformation) {
|
||||||
|
byte rotationSteps = transformation.getRotationSteps();
|
||||||
|
if (rotationSteps == 0 || nbtTileEntity == null) {
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tile entity rotations
|
||||||
|
if (nbtTileEntity.hasKey("rotatable")) {
|
||||||
|
if (!nbtTileEntity.getBoolean("rotatable")) {
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
int rotation = nbtTileEntity.getInteger("rotation");
|
||||||
|
switch (rotationSteps) {
|
||||||
|
case 1:
|
||||||
|
nbtTileEntity.setInteger("rotation", rotRotation[rotation]);
|
||||||
|
return metadata;
|
||||||
|
case 2:
|
||||||
|
nbtTileEntity.setInteger("rotation", rotRotation[rotRotation[rotation]]);
|
||||||
|
return metadata;
|
||||||
|
case 3:
|
||||||
|
nbtTileEntity.setInteger("rotation", rotRotation[rotRotation[rotRotation[rotation]]]);
|
||||||
|
return metadata;
|
||||||
|
default:
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreExternals(TileEntity tileEntity, ITransformation transformation, NBTBase nbtBase) {
|
||||||
|
// nothing to do
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import cr0s.warpdrive.compat.CompatArsMagica2;
|
||||||
import cr0s.warpdrive.compat.CompatBiblioCraft;
|
import cr0s.warpdrive.compat.CompatBiblioCraft;
|
||||||
import cr0s.warpdrive.compat.CompatComputerCraft;
|
import cr0s.warpdrive.compat.CompatComputerCraft;
|
||||||
import cr0s.warpdrive.compat.CompatEnderIO;
|
import cr0s.warpdrive.compat.CompatEnderIO;
|
||||||
|
import cr0s.warpdrive.compat.CompatEvilCraft;
|
||||||
import cr0s.warpdrive.compat.CompatImmersiveEngineering;
|
import cr0s.warpdrive.compat.CompatImmersiveEngineering;
|
||||||
import cr0s.warpdrive.compat.CompatIndustrialCraft2;
|
import cr0s.warpdrive.compat.CompatIndustrialCraft2;
|
||||||
import cr0s.warpdrive.compat.CompatJABBA;
|
import cr0s.warpdrive.compat.CompatJABBA;
|
||||||
|
@ -832,6 +833,10 @@ public class WarpDriveConfig {
|
||||||
if (isThaumcraftLoaded) {
|
if (isThaumcraftLoaded) {
|
||||||
CompatThaumcraft.register();
|
CompatThaumcraft.register();
|
||||||
}
|
}
|
||||||
|
boolean isEvilCraftLoaded = Loader.isModLoaded("evilcraft");
|
||||||
|
if (isEvilCraftLoaded) {
|
||||||
|
CompatEvilCraft.register();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onFMLPostInitialization() {
|
public static void onFMLPostInitialization() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue