Added Woot compatibility to 1.12.2

This commit is contained in:
Unknown 2018-12-26 00:54:29 +01:00 committed by unknown
parent 35203cdae9
commit 5020e1833e
2 changed files with 118 additions and 9 deletions

View file

@ -0,0 +1,103 @@
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.block.state.IBlockState;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class CompatWoot implements IBlockTransformer {
private static Block blockFactory;
private static Block blockStygianAnvil;
public static void register() {
try {
blockFactory = IBlockTransformer.getBlockOrThrowException("woot:factory");
blockStygianAnvil = IBlockTransformer.getBlockOrThrowException("woot:anvil");
WarpDriveConfig.registerBlockTransformer("MysticalAgriculture", new CompatWoot());
} catch(final Exception exception) {
exception.printStackTrace();
}
}
@Override
public boolean isApplicable(final Block block, final int metadata, final TileEntity tileEntity) {
return block == blockFactory
|| block == blockStygianAnvil;
}
@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 int[] rotFacingHorizontal = { 1, 2, 3, 0, 4, 5, 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;
}
// factory heart is vanilla facing 2 5 3 4
if (block == blockFactory) {
switch (rotationSteps) {
case 1:
return rotFacing[metadata];
case 2:
return rotFacing[rotFacing[metadata]];
case 3:
return rotFacing[rotFacing[rotFacing[metadata]]];
default:
return metadata;
}
}
// anvil is horizontal facing 0 1 2 3
if (block == blockStygianAnvil) {
switch (rotationSteps) {
case 1:
return rotFacingHorizontal[metadata];
case 2:
return rotFacingHorizontal[rotFacingHorizontal[metadata]];
case 3:
return rotFacingHorizontal[rotFacingHorizontal[rotFacingHorizontal[metadata]]];
default:
return metadata;
}
}
return metadata;
}
@Override
public void restoreExternals(final World world, final BlockPos blockPos,
final IBlockState blockState, final TileEntity tileEntity,
final ITransformation transformation, final NBTBase nbtBase) {
// nothing to do
}
}

View file

@ -48,6 +48,7 @@ import cr0s.warpdrive.compat.CompatThermalDynamics;
import cr0s.warpdrive.compat.CompatThermalExpansion;
import cr0s.warpdrive.compat.CompatUndergroundBiomes;
import cr0s.warpdrive.compat.CompatWarpDrive;
import cr0s.warpdrive.compat.CompatWoot;
import cr0s.warpdrive.compat.CompatYABBA;
import cr0s.warpdrive.config.structures.StructureManager;
import cr0s.warpdrive.data.CelestialObject;
@ -652,13 +653,21 @@ public class WarpDriveConfig {
// unpack default schematic files if none are defined
unpackResourcesToFolder("default", ".schematic", defaultSchematics, "schematics", fileSchematicsDirectory);
// read mod dependencies
// read mod dependencies at runtime and for recipes
isRedstoneFluxLoaded = Loader.isModLoaded("redstoneflux");
isComputerCraftLoaded = Loader.isModLoaded("computercraft");
isEnderIOLoaded = Loader.isModLoaded("enderio");
isGregTechLoaded = Loader.isModLoaded("gregtech");
isIndustrialCraft2Loaded = Loader.isModLoaded("ic2");
isOpenComputersLoaded = Loader.isModLoaded("opencomputers");
// read mod dependencies for recipes
isAdvancedRepulsionSystemLoaded = Loader.isModLoaded("AdvancedRepulsionSystems");
isForgeMultipartLoaded = Loader.isModLoaded("forgemultipartcbe");
isICBMClassicLoaded = Loader.isModLoaded("icbmclassic");
isNotEnoughItemsLoaded = Loader.isModLoaded("NotEnoughItems");
isThermalExpansionLoaded = Loader.isModLoaded("thermalexpansion");
isThermalFoundationLoaded = Loader.isModLoaded("thermalfoundation");
}
public static void loadConfig(final File file) {
@ -1186,14 +1195,6 @@ public class WarpDriveConfig {
public static void onFMLInitialization() {
CompatWarpDrive.register();
// read non-explicit mod dependencies
isAdvancedRepulsionSystemLoaded = Loader.isModLoaded("AdvancedRepulsionSystems");
isForgeMultipartLoaded = Loader.isModLoaded("forgemultipartcbe");
isICBMClassicLoaded = Loader.isModLoaded("icbmclassic");
isNotEnoughItemsLoaded = Loader.isModLoaded("NotEnoughItems");
isThermalExpansionLoaded = Loader.isModLoaded("thermalexpansion");
isThermalFoundationLoaded = Loader.isModLoaded("thermalfoundation");
// apply compatibility modules
if (isAdvancedRepulsionSystemLoaded) {
CompatAdvancedRepulsionSystems.register();
@ -1410,6 +1411,11 @@ public class WarpDriveConfig {
CompatUndergroundBiomes.register();
}
final boolean isWootloaded = Loader.isModLoaded("woot");
if (isWootloaded) {
CompatWoot.register();
}
final boolean isYABBAloaded = Loader.isModLoaded("yabba");
if (isYABBAloaded) {
CompatYABBA.register();