From 0bbe23bf6f12ca28ec217e3bd8a9243d4addb1c4 Mon Sep 17 00:00:00 2001 From: radfast Date: Sun, 26 Jan 2020 03:05:01 +0000 Subject: [PATCH] Refactor BlockMachines code for simpler code maintenance. --- .../core/blocks/BlockMachine.java | 9 +++- .../core/blocks/BlockMachine2.java | 28 ++++++++-- .../core/blocks/BlockMachine3.java | 10 +++- .../core/blocks/BlockMachineTiered.java | 26 ++++++++- .../core/blocks/IMachineBase.java | 21 ++++++++ .../core/items/ItemBlockMachine.java | 53 ++----------------- .../tile/TileEntityCircuitFabricator.java | 9 +--- .../core/tile/TileEntityCoalGenerator.java | 13 +---- .../core/tile/TileEntityDeconstructor.java | 11 +--- .../core/tile/TileEntityElectricFurnace.java | 10 +--- .../TileEntityElectricIngotCompressor.java | 9 +--- .../tile/TileEntityEnergyStorageModule.java | 16 +----- .../tile/TileEntityOxygenStorageModule.java | 12 +---- 13 files changed, 103 insertions(+), 124 deletions(-) create mode 100644 src/main/java/micdoodle8/mods/galacticraft/core/blocks/IMachineBase.java diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine.java b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine.java index 1d2e05cece..37b68998e0 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine.java @@ -26,12 +26,11 @@ import java.util.Random; -public class BlockMachine extends BlockTileGC implements IShiftDescription, ISortableBlock +public class BlockMachine extends BlockTileGC implements IShiftDescription, ISortableBlock, IMachineBase { public static final int COAL_GENERATOR_METADATA = 0; public static final int COMPRESSOR_METADATA = 12; - public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumMachineType.class); public enum EnumMachineType implements IStringSerializable @@ -262,4 +261,10 @@ public EnumSortCategoryBlock getCategory(int meta) { return EnumSortCategoryBlock.MACHINE; } + + @Override + public String getUnlocalizedName(int typenum) + { + return this.getUnlocalizedName() + "." + (typenum / 4); + } } diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine2.java b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine2.java index 4c539ddc1a..8600c5e6e9 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine2.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine2.java @@ -30,14 +30,13 @@ import java.util.Random; -public class BlockMachine2 extends BlockTileGC implements IShiftDescription, ISortableBlock +public class BlockMachine2 extends BlockTileGC implements IShiftDescription, ISortableBlock, IMachineBase { public static final int ELECTRIC_COMPRESSOR_METADATA = 0; public static final int CIRCUIT_FABRICATOR_METADATA = 4; public static final int OXYGEN_STORAGE_MODULE_METADATA = 8; public static final int DECONSTRUCTOR_METADATA = 12; - public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumMachineExtendedType.class); public static IMachineSidesProperties MACHINESIDES_RENDERTYPE = IMachineSidesProperties.TWOFACES_HORIZ; public static final PropertyEnum SIDES = MACHINESIDES_RENDERTYPE.asProperty; @@ -105,7 +104,7 @@ public boolean isFullCube(IBlockState state) @Override public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { - TileEntity tile = worldIn.getTileEntity(pos); +// TileEntity tile = worldIn.getTileEntity(pos); } @@ -268,4 +267,27 @@ public boolean onSneakUseWrench(World world, BlockPos pos, EntityPlayer entityPl } return false; } + + @Override + public String getUnlocalizedName(int typenum) + { + int index = 6; + if (typenum == BlockMachine2.OXYGEN_STORAGE_MODULE_METADATA) + { + index = 6; + } + else if (typenum == BlockMachine2.CIRCUIT_FABRICATOR_METADATA) + { + index = 5; + } + else if (typenum == BlockMachine2.ELECTRIC_COMPRESSOR_METADATA) + { + index = 4; + } + else if (typenum == BlockMachine2.DECONSTRUCTOR_METADATA) + { + index = 10; + } + return this.getUnlocalizedName() + "." + index; + } } diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine3.java b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine3.java index 487f3e4876..f48fddd269 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine3.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachine3.java @@ -32,13 +32,12 @@ * with a base building purpose - e.g. Painter * */ -public class BlockMachine3 extends BlockTileGC implements IShiftDescription, ISortableBlock +public class BlockMachine3 extends BlockTileGC implements IShiftDescription, ISortableBlock, IMachineBase { public static final int PAINTER_METADATA = 0; public static final int METADATA_MASK = 0x0c; //Used to select the machine type from metadata - public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumMachineBuildingType.class); public enum EnumMachineBuildingType implements IStringSerializable @@ -204,4 +203,11 @@ public EnumSortCategoryBlock getCategory(int meta) { return EnumSortCategoryBlock.MACHINE; } + + @Override + public String getUnlocalizedName(int typenum) + { + int index = 9; + return this.getUnlocalizedName() + "." + index; + } } diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachineTiered.java b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachineTiered.java index 87f0e64f9e..71e9eb4827 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachineTiered.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/BlockMachineTiered.java @@ -30,13 +30,12 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class BlockMachineTiered extends BlockTileGC implements IShiftDescription, ISortableBlock +public class BlockMachineTiered extends BlockTileGC implements IShiftDescription, ISortableBlock, IMachineBase { public static final int STORAGE_MODULE_METADATA = 0; public static final int ELECTRIC_FURNACE_METADATA = 4; public static IMachineSidesProperties MACHINESIDES_RENDERTYPE = IMachineSidesProperties.TWOFACES_HORIZ; - public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyEnum TYPE = PropertyEnum.create("type", EnumTieredMachineType.class); public static final PropertyInteger FILL_VALUE = PropertyInteger.create("fill_value", 0, 33); public static final PropertyEnum SIDES = MACHINESIDES_RENDERTYPE.asProperty; @@ -263,4 +262,27 @@ public boolean onSneakUseWrench(World world, BlockPos pos, EntityPlayer entityPl } return false; } + + @Override + public String getUnlocalizedName(int typenum) + { + if (typenum == BlockMachineTiered.ELECTRIC_FURNACE_METADATA) + { + return "tile.machine.2"; + } + else if (typenum == BlockMachineTiered.STORAGE_MODULE_METADATA) + { + return "tile.machine.1"; + } + + //Tier 2 versions of the same + if (typenum == 8 + BlockMachineTiered.ELECTRIC_FURNACE_METADATA) + { + return "tile.machine.7"; + } + else + { + return "tile.machine.8"; + } + } } diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/blocks/IMachineBase.java b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/IMachineBase.java new file mode 100644 index 0000000000..687156307d --- /dev/null +++ b/src/main/java/micdoodle8/mods/galacticraft/core/blocks/IMachineBase.java @@ -0,0 +1,21 @@ +package micdoodle8.mods.galacticraft.core.blocks; + +import net.minecraft.block.properties.PropertyDirection; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.EnumFacing; + +public interface IMachineBase +{ + public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); + + public String getUnlocalizedName(int typenum); + + public static EnumFacing getFront(IBlockState state) + { + if (state.getBlock() instanceof IMachineBase) + { + return (state.getValue(IMachineBase.FACING)); + } + return EnumFacing.NORTH; + } +} diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/items/ItemBlockMachine.java b/src/main/java/micdoodle8/mods/galacticraft/core/items/ItemBlockMachine.java index f9d44c82bd..303f6ed53b 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/items/ItemBlockMachine.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/items/ItemBlockMachine.java @@ -3,7 +3,7 @@ import micdoodle8.mods.galacticraft.core.GCBlocks; import micdoodle8.mods.galacticraft.core.blocks.BlockMachine; import micdoodle8.mods.galacticraft.core.blocks.BlockMachine2; -import micdoodle8.mods.galacticraft.core.blocks.BlockMachineTiered; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.proxy.ClientProxyCore; import net.minecraft.block.Block; import net.minecraft.client.entity.EntityPlayerSP; @@ -42,56 +42,11 @@ public String getUnlocalizedName(ItemStack itemstack) int index = 0; int typenum = itemstack.getItemDamage() & 12; - if (this.getBlock() == GCBlocks.machineBase) + if (this.getBlock() instanceof IMachineBase) { - index = typenum / 4; + return ((IMachineBase) this.getBlock()).getUnlocalizedName(typenum); } - else if (this.getBlock() == GCBlocks.machineTiered) - { - if (typenum == BlockMachineTiered.ELECTRIC_FURNACE_METADATA) - { - return "tile.machine.2"; - } - else if (typenum == BlockMachineTiered.STORAGE_MODULE_METADATA) - { - return "tile.machine.1"; - } - - //Tier 2 versions of the same - if (typenum == 8 + BlockMachineTiered.ELECTRIC_FURNACE_METADATA) - { - return "tile.machine.7"; - } - else if (typenum == 8 + BlockMachineTiered.STORAGE_MODULE_METADATA) - { - return "tile.machine.8"; - } - } - else if (this.getBlock() == GCBlocks.machineBase2) - { - if (typenum == BlockMachine2.OXYGEN_STORAGE_MODULE_METADATA) - { - index = 6; - } - else if (typenum == BlockMachine2.CIRCUIT_FABRICATOR_METADATA) - { - index = 5; - } - else if (typenum == BlockMachine2.ELECTRIC_COMPRESSOR_METADATA) - { - index = 4; - } - else if (typenum == BlockMachine2.DECONSTRUCTOR_METADATA) - { - index = 10; - } - } - else //machineBase3 - { - index = 9; - } - - return this.getBlock().getUnlocalizedName() + "." + index; + return "tile.machine.0"; } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCircuitFabricator.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCircuitFabricator.java index 5e87d05cc5..536b68d060 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCircuitFabricator.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCircuitFabricator.java @@ -4,13 +4,13 @@ import micdoodle8.mods.galacticraft.api.world.IZeroGDimension; import micdoodle8.mods.galacticraft.core.GCItems; import micdoodle8.mods.galacticraft.core.blocks.BlockMachine2; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.energy.item.ItemElectricBase; import micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlockWithInventory; import micdoodle8.mods.galacticraft.core.items.ItemBasic; import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; import micdoodle8.mods.miccore.Annotations.NetworkedField; -import net.minecraft.block.state.IBlockState; import net.minecraft.init.SoundEvents; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -241,12 +241,7 @@ public boolean shouldUseEnergy() @Override public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(getPos()); - if (state.getBlock() instanceof BlockMachine2) - { - return (state.getValue(BlockMachine2.FACING)); - } - return EnumFacing.NORTH; + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCoalGenerator.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCoalGenerator.java index b91a882c40..c2daa96875 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCoalGenerator.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityCoalGenerator.java @@ -2,17 +2,13 @@ import micdoodle8.mods.galacticraft.api.transmission.NetworkType; import micdoodle8.mods.galacticraft.api.transmission.tile.IConnector; -import micdoodle8.mods.galacticraft.core.blocks.BlockMachine; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectricalSource; import micdoodle8.mods.galacticraft.core.inventory.IInventoryDefaults; -import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; import micdoodle8.mods.miccore.Annotations.NetworkedField; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -189,12 +185,7 @@ public EnumSet getElectricalOutputDirections() public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(getPos()); - if (state.getBlock() instanceof BlockMachine) - { - return state.getValue(BlockMachine.FACING); - } - return EnumFacing.NORTH; + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityDeconstructor.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityDeconstructor.java index 7ed55f22a0..89c1d21f6b 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityDeconstructor.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityDeconstructor.java @@ -10,6 +10,7 @@ import micdoodle8.mods.galacticraft.core.GCItems; import micdoodle8.mods.galacticraft.core.GalacticraftCore; import micdoodle8.mods.galacticraft.core.blocks.BlockMachine2; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.client.sounds.GCSounds; import micdoodle8.mods.galacticraft.core.energy.item.ItemElectricBase; import micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock; @@ -20,8 +21,6 @@ import micdoodle8.mods.galacticraft.planets.asteroids.items.AsteroidsItems; import micdoodle8.mods.galacticraft.planets.mars.items.MarsItems; import micdoodle8.mods.miccore.Annotations.NetworkedField; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -31,7 +30,6 @@ import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapelessRecipes; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraft.util.SoundCategory; @@ -498,12 +496,7 @@ public boolean shouldUseEnergy() @Override public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(getPos()); - if (state.getBlock() instanceof BlockMachine2) - { - return state.getValue(BlockMachine2.FACING); - } - return EnumFacing.NORTH; + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricFurnace.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricFurnace.java index 855f3987be..454eb22fb4 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricFurnace.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricFurnace.java @@ -2,14 +2,13 @@ import micdoodle8.mods.galacticraft.core.GCBlocks; import micdoodle8.mods.galacticraft.core.blocks.BlockMachineTiered; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.energy.item.ItemElectricBase; import micdoodle8.mods.galacticraft.core.energy.tile.EnergyStorageTile; import micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlockWithInventory; import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; -import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; import micdoodle8.mods.miccore.Annotations.NetworkedField; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.inventory.ISidedInventory; @@ -340,12 +339,7 @@ public boolean hasCustomName() @Override public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(getPos()); - if (state.getBlock() instanceof BlockMachineTiered) - { - return state.getValue(BlockMachineTiered.FACING); - } - return EnumFacing.NORTH; + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricIngotCompressor.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricIngotCompressor.java index a54e1041f7..ebe93c36ae 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricIngotCompressor.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityElectricIngotCompressor.java @@ -4,6 +4,7 @@ import micdoodle8.mods.galacticraft.api.recipe.ShapedRecipesGC; import micdoodle8.mods.galacticraft.api.recipe.ShapelessOreRecipeGC; import micdoodle8.mods.galacticraft.core.blocks.BlockMachine2; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.energy.item.ItemElectricBase; import micdoodle8.mods.galacticraft.core.energy.tile.TileBaseElectricBlock; import micdoodle8.mods.galacticraft.core.inventory.IInventoryDefaults; @@ -11,7 +12,6 @@ import micdoodle8.mods.galacticraft.core.util.ConfigManagerCore; import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; import micdoodle8.mods.miccore.Annotations.NetworkedField; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; @@ -577,12 +577,7 @@ public boolean shouldUseEnergy() @Override public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(getPos()); - if (state.getBlock() instanceof BlockMachine2) - { - return state.getValue(BlockMachine2.FACING); - } - return EnumFacing.NORTH; + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityEnergyStorageModule.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityEnergyStorageModule.java index ee27bd6b51..d10def7260 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityEnergyStorageModule.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityEnergyStorageModule.java @@ -4,16 +4,13 @@ import micdoodle8.mods.galacticraft.api.transmission.NetworkType; import micdoodle8.mods.galacticraft.api.transmission.tile.IConnector; import micdoodle8.mods.galacticraft.core.GCBlocks; -import micdoodle8.mods.galacticraft.core.blocks.BlockMachine; import micdoodle8.mods.galacticraft.core.blocks.BlockMachineTiered; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.energy.item.ItemElectricBase; import micdoodle8.mods.galacticraft.core.energy.tile.TileBaseUniversalElectricalSource; import micdoodle8.mods.galacticraft.core.inventory.IInventoryDefaults; -import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -239,16 +236,7 @@ public boolean canConnect(EnumFacing direction, NetworkType type) @Override public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(getPos()); - if (state.getBlock() instanceof BlockMachineTiered) - { - return (state.getValue(BlockMachineTiered.FACING)); - } - else if (state.getBlock() instanceof BlockMachine) - { - return (state.getValue(BlockMachine.FACING)); - } - return EnumFacing.NORTH; + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override diff --git a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityOxygenStorageModule.java b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityOxygenStorageModule.java index 2bddbe4ecb..597fac4315 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityOxygenStorageModule.java +++ b/src/main/java/micdoodle8/mods/galacticraft/core/tile/TileEntityOxygenStorageModule.java @@ -1,15 +1,12 @@ package micdoodle8.mods.galacticraft.core.tile; import micdoodle8.mods.galacticraft.api.item.IItemOxygenSupply; -import micdoodle8.mods.galacticraft.core.GCBlocks; import micdoodle8.mods.galacticraft.core.blocks.BlockMachine2; +import micdoodle8.mods.galacticraft.core.blocks.IMachineBase; import micdoodle8.mods.galacticraft.core.inventory.IInventoryDefaults; import micdoodle8.mods.galacticraft.core.util.FluidUtil; -import micdoodle8.mods.galacticraft.core.util.GCCoreUtil; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; -import net.minecraft.inventory.ItemStackHelper; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -178,12 +175,7 @@ public int getOxygenProvide(EnumFacing direction) @Override public EnumFacing getFront() { - IBlockState state = this.world.getBlockState(this.getPos()); - if (state.getBlock() != GCBlocks.machineBase2) - { - return EnumFacing.NORTH; - } - return state.getValue(BlockMachine2.FACING); + return IMachineBase.getFront(this.world.getBlockState(getPos())); } @Override