More MekanismGenerators updating. I've done about everything other than rendering and jsonification

This commit is contained in:
aidancbrady committed 2016-05-13 23:50:45 -04:00
1 parent 3b0bcc1e01
commit 542b39c90b
10 files changed
+365 -255

No files matched your search

@@ -21,7 +21,6 @@ import mekanism.common.base.IFactory;
import mekanism.common.base.IFactory.RecipeType;
import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISideConfiguration;
import mekanism.common.base.ISpecialBounds;
import mekanism.common.base.ISustainedData;
import mekanism.common.base.ISustainedInventory;
import mekanism.common.base.ISustainedTank;
@@ -130,7 +129,7 @@ import buildcraft.api.tools.IToolWrench;
* @author AidanBrady
*
*/
public abstract class BlockMachine extends BlockContainer implements ISpecialBounds, ICTMBlock
public abstract class BlockMachine extends BlockContainer implements ICTMBlock
{
public CTMData[][] ctmData = new CTMData[16][4];
@@ -452,7 +451,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
}
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
int metadata = state.getBlock().getMetaFromState(state);
int metadata = getMetaFromState(state);
if(entityplayer.getCurrentEquippedItem() != null)
{
@@ -591,8 +590,8 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
if(SecurityUtils.canAccess(entityplayer, tileEntity))
{
entityplayer.openGui(Mekanism.instance, type.guiId, world, pos.getX(), pos.getY(), pos.getZ());
} else
{
}
else {
SecurityUtils.displayNoAccess(entityplayer);
}
@@ -662,7 +661,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion)
{
IBlockState state = world.getBlockState(pos);
if(MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)) != MachineType.PERSONAL_CHEST)
if(MachineType.get(getMachineBlock(), getMetaFromState(state)) != MachineType.PERSONAL_CHEST)
{
return blockResistance;
}
@@ -839,7 +838,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
{
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
IBlockState state = world.getBlockState(pos);
ItemStack itemStack = new ItemStack(this, 1, state.getBlock().getMetaFromState(state));
ItemStack itemStack = new ItemStack(this, 1, getMetaFromState(state));
if(itemStack.getTagCompound() == null)
{
@@ -941,7 +940,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
public boolean canConnectRedstone(IBlockAccess world, BlockPos pos, EnumFacing side)
{
IBlockState state = world.getBlockState(pos);
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
MachineType type = MachineType.get(getMachineBlock(), getMetaFromState(state));
switch(type)
{
@@ -977,7 +976,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
IBlockState state = world.getBlockState(pos);
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
MachineType type = MachineType.get(getMachineBlock(), getMetaFromState(state));
switch(type)
{
@@ -1016,7 +1015,7 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side)
{
IBlockState state = world.getBlockState(pos);
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
MachineType type = MachineType.get(getMachineBlock(), getMetaFromState(state));
switch(type)
{
@@ -1048,15 +1047,6 @@ public abstract class BlockMachine extends BlockContainer implements ISpecialBou
return getMachineBlock().getProperty();
}
@Override
public void setRenderBounds(Block block, int metadata) {}
@Override
public boolean doDefaultBoundSetting(int metadata)
{
return false;
}
@Override
public EnumFacing[] getValidRotations(World world, BlockPos pos)
{
@@ -27,7 +27,6 @@ import mekanism.common.base.ISustainedInventory;
import mekanism.common.base.ISustainedTank;
import mekanism.common.base.ITierItem;
import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.states.BlockStateMachine;
import mekanism.common.block.states.BlockStateMachine.MachineType;
import mekanism.common.integration.IC2ItemManager;
import mekanism.common.inventory.InventoryPersonalChest;
@@ -140,9 +139,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
if(BlockStateMachine.MachineType.get(itemstack) != null)
if(MachineType.get(itemstack) != null)
{
return getUnlocalizedName() + "." + BlockStateMachine.MachineType.get(itemstack).machineName;
return getUnlocalizedName() + "." + MachineType.get(itemstack).machineName;
}
return "null";
@@ -151,11 +150,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public String getItemStackDisplayName(ItemStack itemstack)
{
MachineType type = BlockStateMachine.MachineType.get(itemstack);
MachineType type = MachineType.get(itemstack);
if(type == BlockStateMachine.MachineType.BASIC_FACTORY || type == BlockStateMachine.MachineType.ADVANCED_FACTORY || type == BlockStateMachine.MachineType.ELITE_FACTORY)
if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY)
{
BaseTier tier = type == BlockStateMachine.MachineType.BASIC_FACTORY ? BaseTier.BASIC : (type == BlockStateMachine.MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE);
BaseTier tier = type == MachineType.BASIC_FACTORY ? BaseTier.BASIC : (type == MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE);
if(StatCollector.canTranslate("tile." + tier.getSimpleName() + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + "Factory"))
{
@@ -176,11 +175,11 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List<String> list, boolean flag)
{
MachineType type = BlockStateMachine.MachineType.get(itemstack);
MachineType type = MachineType.get(itemstack);
if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey))
{
if(type == BlockStateMachine.MachineType.FLUID_TANK)
if(type == MachineType.FLUID_TANK)
{
FluidStack fluidStack = getFluidStack(itemstack);
@@ -206,12 +205,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
}
}
if(type == BlockStateMachine.MachineType.BASIC_FACTORY || type == BlockStateMachine.MachineType.ADVANCED_FACTORY || type == BlockStateMachine.MachineType.ELITE_FACTORY)
if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY)
{
list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName());
}
if(type == BlockStateMachine.MachineType.FLUID_TANK)
if(type == MachineType.FLUID_TANK)
{
list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + EnumColor.GREY + LangUtils.transYesNo(getBucketMode(itemstack)));
}
@@ -221,7 +220,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)));
}
if(hasTank(itemstack) && type != BlockStateMachine.MachineType.FLUID_TANK)
if(hasTank(itemstack) && type != MachineType.FLUID_TANK)
{
FluidStack fluidStack = getFluidStack(itemstack);
@@ -231,7 +230,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
}
}
if(type != BlockStateMachine.MachineType.CHARGEPAD && type != BlockStateMachine.MachineType.LOGISTICAL_SORTER)
if(type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER)
{
list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0));
}
@@ -254,9 +253,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
MachineType type = BlockStateMachine.MachineType.get(stack);
MachineType type = MachineType.get(stack);
if(type == BlockStateMachine.MachineType.FLUID_TANK && getBucketMode(stack))
if(type == MachineType.FLUID_TANK && getBucketMode(stack))
{
return false;
}
@@ -269,9 +268,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
{
boolean place = true;
MachineType type = BlockStateMachine.MachineType.get(stack);
MachineType type = MachineType.get(stack);
if(type == BlockStateMachine.MachineType.DIGITAL_MINER)
if(type == MachineType.DIGITAL_MINER)
{
for(int xPos = -1; xPos <= +1; xPos++)
{
@@ -463,7 +462,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
else {
if(!world.isRemote && flag && !material.isLiquid())
{
//TODO: world.breakBlock(pos, true);
world.destroyBlock(pos, true);
}
world.setBlockState(pos, MekanismUtils.getFlowingBlock(getFluidStack(itemstack).getFluid()).getDefaultState(), 3);
@@ -477,7 +476,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
MachineType type = BlockStateMachine.MachineType.get(itemstack);
MachineType type = MachineType.get(itemstack);
if(MachineType.get(itemstack) == MachineType.PERSONAL_CHEST)
{
@@ -498,7 +497,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
}
}
}
else if(type == BlockStateMachine.MachineType.FLUID_TANK && getBucketMode(itemstack))
else if(type == MachineType.FLUID_TANK && getBucketMode(itemstack))
{
if(SecurityUtils.canAccess(entityplayer, itemstack))
{
@@ -692,9 +691,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
return false;
}
MachineType type = BlockStateMachine.MachineType.get((ItemStack)data[0]);
MachineType type = MachineType.get((ItemStack)data[0]);
return type == BlockStateMachine.MachineType.ELECTRIC_PUMP || type == BlockStateMachine.MachineType.FLUID_TANK || type == BlockStateMachine.MachineType.FLUIDIC_PLENISHER;
return type == MachineType.ELECTRIC_PUMP || type == MachineType.FLUID_TANK || type == MachineType.FLUIDIC_PLENISHER;
}
public void setBucketMode(ItemStack itemStack, boolean bucketMode)
@@ -720,7 +719,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public double getEnergy(ItemStack itemStack)
{
if(itemStack.getTagCompound() == null || !BlockStateMachine.MachineType.get(itemStack).isElectric)
if(itemStack.getTagCompound() == null || !MachineType.get(itemStack).isElectric)
{
return 0;
}
@@ -731,7 +730,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public void setEnergy(ItemStack itemStack, double amount)
{
if(!BlockStateMachine.MachineType.get(itemStack).isElectric)
if(!MachineType.get(itemStack).isElectric)
{
return;
}
@@ -748,7 +747,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public double getMaxEnergy(ItemStack itemStack)
{
return MekanismUtils.getMaxEnergy(itemStack, BlockStateMachine.MachineType.get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()).baseEnergy);
return MekanismUtils.getMaxEnergy(itemStack, MachineType.get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()).baseEnergy);
}
@Override
@@ -760,7 +759,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public boolean canReceive(ItemStack itemStack)
{
return BlockStateMachine.MachineType.get(itemStack).isElectric;
return MachineType.get(itemStack).isElectric;
}
@Override
@@ -855,7 +854,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
if(BlockStateMachine.MachineType.get(container) == BlockStateMachine.MachineType.FLUID_TANK && resource != null)
if(MachineType.get(container) == MachineType.FLUID_TANK && resource != null)
{
FluidStack stored = getFluidStack(container);
int toFill;
@@ -888,7 +887,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
if(BlockStateMachine.MachineType.get(container) == BlockStateMachine.MachineType.FLUID_TANK)
if(MachineType.get(container) == MachineType.FLUID_TANK)
{
FluidStack stored = getFluidStack(container);
@@ -10,7 +10,8 @@ import mekanism.generators.client.model.ModelHeatGenerator;
import mekanism.generators.client.model.ModelSolarGenerator;
import mekanism.generators.client.model.ModelWindGenerator;
import mekanism.generators.common.GeneratorsBlocks;
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import mekanism.generators.common.block.states.BlockStateGenerator;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorType;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
@@ -40,14 +41,14 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
if(block == GeneratorsBlocks.Generator)
{
if(metadata == GeneratorType.BIO_GENERATOR.meta)
if(metadata == BlockStateGenerator.GeneratorType.BIO_GENERATOR.meta)
{
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GL11.glTranslated(0.0F, -1.0F, 0.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png"));
bioGenerator.render(0.0625F);
}
else if(metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
else if(metadata == BlockStateGenerator.GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
{
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(90F, 0.0F, 1.0F, 0.0F);
@@ -55,7 +56,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png"));
advancedSolarGenerator.render(0.022F);
}
else if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
else if(metadata == BlockStateGenerator.GeneratorType.SOLAR_GENERATOR.meta)
{
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(90F, 0.0F, -1.0F, 0.0F);
@@ -63,14 +64,14 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png"));
solarGenerator.render(0.0625F);
}
else if(metadata == GeneratorType.HEAT_GENERATOR.meta)
else if(metadata == BlockStateGenerator.GeneratorType.HEAT_GENERATOR.meta)
{
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GL11.glTranslated(0.0F, -1.0F, 0.0F);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png"));
heatGenerator.render(0.0625F, false, mc.renderEngine);
}
else if(metadata == GeneratorType.GAS_GENERATOR.meta)
else if(metadata == BlockStateGenerator.GeneratorType.GAS_GENERATOR.meta)
{
GlStateManager.rotate(180F, 0.0F, 1.0F, 1.0F);
GlStateManager.rotate(90F, -1.0F, 0.0F, 0.0F);
@@ -79,7 +80,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasGenerator.png"));
gasGenerator.render(0.0625F);
}
else if(metadata == GeneratorType.WIND_GENERATOR.meta)
else if(metadata == BlockStateGenerator.GeneratorType.WIND_GENERATOR.meta)
{
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(180F, 0.0F, 1.0F, 0.0F);
@@ -1,5 +1,6 @@
package mekanism.generators.common;
import static mekanism.generators.common.block.states.BlockStateGenerator.GeneratorBlock.GENERATOR_BLOCK_1;
import static mekanism.generators.common.block.states.BlockStateReactor.ReactorBlock.REACTOR_BLOCK;
import static mekanism.generators.common.block.states.BlockStateReactor.ReactorBlock.REACTOR_GLASS;
import mekanism.generators.common.block.BlockGenerator;
@@ -13,7 +14,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
@ObjectHolder("MekanismGenerators")
public class GeneratorsBlocks
{
public static final Block Generator = new BlockGenerator().setUnlocalizedName("Generator");
public static final Block Generator = BlockGenerator.getGeneratorBlock(GENERATOR_BLOCK_1).setUnlocalizedName("Generator");
public static final Block Reactor = BlockReactor.getReactorBlock(REACTOR_BLOCK).setUnlocalizedName("Reactor");
public static final Block ReactorGlass = BlockReactor.getReactorBlock(REACTOR_GLASS).setUnlocalizedName("ReactorGlass");
@@ -5,44 +5,38 @@ import java.util.List;
import java.util.Random;
import mekanism.api.MekanismConfig.client;
import mekanism.api.MekanismConfig.general;
import mekanism.api.energy.IEnergizedItem;
import mekanism.client.render.ctm.CTMBlockRenderContext;
import mekanism.client.render.ctm.CTMData;
import mekanism.client.render.ctm.ICTMBlock;
import mekanism.common.Mekanism;
import mekanism.common.base.IActiveState;
import mekanism.common.base.IBoundingBlock;
import mekanism.common.base.ISpecialBounds;
import mekanism.common.base.ISustainedData;
import mekanism.common.base.ISustainedInventory;
import mekanism.common.base.ISustainedTank;
import mekanism.common.block.states.BlockStateBasic;
import mekanism.common.multiblock.IMultiblock;
import mekanism.common.security.ISecurityItem;
import mekanism.common.security.ISecurityTile;
import mekanism.common.tile.TileEntityBasicBlock;
import mekanism.common.tile.TileEntityContainerBlock;
import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.SecurityUtils;
import mekanism.generators.common.GeneratorsBlocks;
import mekanism.generators.common.GeneratorsItems;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator;
import mekanism.generators.common.tile.TileEntityBioGenerator;
import mekanism.generators.common.tile.TileEntityGasGenerator;
import mekanism.generators.common.tile.TileEntityHeatGenerator;
import mekanism.generators.common.block.states.BlockStateGenerator;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorBlock;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorType;
import mekanism.generators.common.tile.TileEntitySolarGenerator;
import mekanism.generators.common.tile.TileEntityWindGenerator;
import mekanism.generators.common.tile.turbine.TileEntityElectromagneticCoil;
import mekanism.generators.common.tile.turbine.TileEntityRotationalComplex;
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor;
import mekanism.generators.common.tile.turbine.TileEntityTurbineValve;
import mekanism.generators.common.tile.turbine.TileEntityTurbineVent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
@@ -60,6 +54,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import buildcraft.api.tools.IToolWrench;
@@ -82,12 +77,12 @@ import codechicken.lib.render.TextureUtils.IIconRegister;
* @author AidanBrady
*
*/
public class BlockGenerator extends BlockContainer implements ISpecialBounds, ICTMBlock
public abstract class BlockGenerator extends BlockContainer implements ICTMBlock
{
public CTMData[] ctms = new CTMData[16];
public Random machineRand = new Random();
public BlockGenerator()
{
super(Material.iron);
@@ -95,6 +90,56 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
setResistance(8F);
setCreativeTab(Mekanism.tabMekanism);
}
public static BlockGenerator getGeneratorBlock(GeneratorBlock block)
{
return new BlockGenerator()
{
@Override
public GeneratorBlock getGeneratorBlock()
{
return block;
}
};
}
public abstract GeneratorBlock getGeneratorBlock();
@SideOnly(Side.CLIENT)
@Override
public IBlockState getExtendedState(IBlockState stateIn, IBlockAccess w, BlockPos pos)
{
if(stateIn.getBlock() == null || stateIn.getBlock().getMaterial() == Material.air)
{
return stateIn;
}
IExtendedBlockState state = (IExtendedBlockState)stateIn;
CTMBlockRenderContext ctx = new CTMBlockRenderContext(w, pos);
return state.withProperty(BlockStateBasic.ctmProperty, ctx);
}
@Override
public BlockState createBlockState()
{
return new BlockStateGenerator(this, getTypeProperty());
}
@Override
public IBlockState getStateFromMeta(int meta)
{
GeneratorType type = GeneratorType.get(getGeneratorBlock(), meta & 0xF);
return getDefaultState().withProperty(getTypeProperty(), type);
}
@Override
public int getMetaFromState(IBlockState state)
{
GeneratorType type = state.getValue(getTypeProperty());
return type.meta;
}
@Override
@SideOnly(Side.CLIENT)
@@ -184,7 +229,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
int height = Math.round(entityliving.rotationPitch);
int change = 3;
if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1))
if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1))
{
if(height >= 65)
{
@@ -208,7 +253,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
tileEntity.setFacing((short)change);
tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z);
tileEntity.redstone = world.isBlockIndirectlyGettingPowered(pos) > 0;
if(tileEntity instanceof IBoundingBlock)
{
@@ -242,9 +287,9 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
@Override
public int damageDropped(int i)
public int damageDropped(IBlockState state)
{
return i;
return getMetaFromState(state);
}
@Override
@@ -269,7 +314,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
{
int metadata = world.getBlockMetadata(x, y, z);
GeneratorType type = GeneratorType.get(state.getBlock(), state.getBlock().getMetaFromState(state));
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
if(MekanismUtils.isActive(world, pos))
@@ -282,7 +327,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
if(tileEntity.facing == EnumFacing.WEST)
{
switch(GeneratorType.getFromMetadata(metadata))
switch(type)
{
case HEAT_GENERATOR:
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(xRandom + iRandom), (double)yRandom, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D);
@@ -297,7 +342,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
else if(tileEntity.facing == EnumFacing.EAST)
{
switch(GeneratorType.getFromMetadata(metadata))
switch(type)
{
case HEAT_GENERATOR:
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(xRandom + iRandom), (double)yRandom + 0.5F, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D);
@@ -312,7 +357,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
else if(tileEntity.facing == EnumFacing.NORTH)
{
switch(GeneratorType.getFromMetadata(metadata))
switch(type)
{
case HEAT_GENERATOR:
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D);
@@ -327,7 +372,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
else if(tileEntity.facing == EnumFacing.SOUTH)
{
switch(GeneratorType.getFromMetadata(metadata))
switch(type)
{
case HEAT_GENERATOR:
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D);
@@ -343,45 +388,6 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
}
@Override
public boolean canPlaceBlockAt(World world, BlockPos pos)
{
//This method doesn't actually seem to be used in MC code...
if(world.getBlockMetadata(x, y, z) == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta)
{
boolean canPlace = super.canPlaceBlockAt(world, pos);
boolean nonAir = false;
nonAir |= world.isAirBlock(pos);
nonAir |= world.isAirBlock(pos.add(0, 1, 0));
for(int xPos=-1;xPos<=1;xPos++)
{
for(int zPos=-1;zPos<=1;zPos++)
{
nonAir |= world.isAirBlock(pos.add(xPos, 2, zPos));
}
}
return (!nonAir) && canPlace;
}
else if(world.getBlockMetadata(x, y, z) == GeneratorType.WIND_GENERATOR.meta)
{
boolean canPlace = super.canPlaceBlockAt(world, pos);
boolean nonAir = false;
for(int yPos = pos.getY()+1; yPos <= pos.getY()+4; yPos++)
{
nonAir |= world.isAirBlock(pos.add(0, yPos, 0));
}
return (!nonAir) && canPlace;
}
return super.canPlaceBlockAt(world, pos);
}
@Override
public void breakBlock(World world, BlockPos pos, IBlockState state)
{
@@ -421,7 +427,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
int metadata = world.getBlockMetadata(x, y, z);
int metadata = getMetaFromState(state);
if(entityplayer.getCurrentEquippedItem() != null)
{
@@ -443,10 +449,10 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
((IToolWrench)tool).wrenchUsed(entityplayer, pos);
}
int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing];
int change = tileEntity.facing.rotateY().ordinal();
tileEntity.setFacing((short)change);
world.notifyBlocksOfNeighborChange(x, y, z, this);
world.notifyNeighborsOfStateChange(pos, this);
}
else {
SecurityUtils.displayNoAccess(entityplayer);
@@ -521,7 +527,7 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
return false;
}
int guiId = GeneratorType.getFromMetadata(metadata).guiId;
int guiId = GeneratorType.get(getGeneratorBlock(), metadata).guiId;
if(guiId != -1 && tileEntity != null)
{
@@ -549,20 +555,20 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
}
@Override
public TileEntity createTileEntity(World world, int metadata)
public TileEntity createTileEntity(World world, IBlockState state)
{
GeneratorType type = GeneratorType.getFromMetadata(metadata);
if(type != null)
int metadata = getMetaFromState(state);
if(GeneratorType.get(getGeneratorBlock(), metadata) == null)
{
return type.create();
return null;
}
return null;
return GeneratorType.get(getGeneratorBlock(), metadata).create();
}
@Override
public Item getItemDropped(int i, Random random, int j)
public Item getItemDropped(IBlockState state, Random random, int fortune)
{
return null;
}
@@ -589,13 +595,14 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos)
{
int metadata = world.getBlockMetadata(x, y, z);
IBlockState state = world.getBlockState(pos);
GeneratorType type = GeneratorType.get(getGeneratorBlock(), state.getBlock().getMetaFromState(state));
if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
if(type == GeneratorType.SOLAR_GENERATOR)
{
setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F);
}
else if(metadata == GeneratorType.TURBINE_ROTOR.meta)
else if(type == GeneratorType.TURBINE_ROTOR)
{
setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
}
@@ -626,7 +633,8 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos, EntityPlayer player)
{
TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(pos);
ItemStack itemStack = new ItemStack(GeneratorsBlocks.Generator, 1, world.getBlockMetadata(pos));
IBlockState state = world.getBlockState(pos);
ItemStack itemStack = new ItemStack(GeneratorsBlocks.Generator, 1, getMetaFromState(state));
if(itemStack.getTagCompound() == null)
{
@@ -704,112 +712,24 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IC
@Override
public boolean isSideSolid(IBlockAccess world, BlockPos pos, EnumFacing side)
{
int metadata = world.getBlockMetadata(pos);
IBlockState state = world.getBlockState(pos);
GeneratorType type = GeneratorType.get(getGeneratorBlock(), getMetaFromState(state));
if(metadata != GeneratorType.SOLAR_GENERATOR.meta &&
metadata != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta &&
metadata != GeneratorType.WIND_GENERATOR.meta &&
metadata != GeneratorType.TURBINE_ROTOR.meta)
if(type != GeneratorType.SOLAR_GENERATOR &&
type != GeneratorType.ADVANCED_SOLAR_GENERATOR &&
type != GeneratorType.WIND_GENERATOR &&
type != GeneratorType.TURBINE_ROTOR)
{
return true;
}
return false;
}
public static enum GeneratorType
{
HEAT_GENERATOR(0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true),
SOLAR_GENERATOR(1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true),
GAS_GENERATOR(3, "GasGenerator", 3, general.FROM_H2*100, TileEntityGasGenerator.class, true),
BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true),
ADVANCED_SOLAR_GENERATOR(5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true),
WIND_GENERATOR(6, "WindGenerator", 5, 200000, TileEntityWindGenerator.class, true),
TURBINE_ROTOR(7, "TurbineRotor", -1, -1, TileEntityTurbineRotor.class, false),
ROTATIONAL_COMPLEX(8, "RotationalComplex", -1, -1, TileEntityRotationalComplex.class, false),
ELECTROMAGNETIC_COIL(9, "ElectromagneticCoil", -1, -1, TileEntityElectromagneticCoil.class, false),
TURBINE_CASING(10, "TurbineCasing", -1, -1, TileEntityTurbineCasing.class, false),
TURBINE_VALVE(11, "TurbineValve", -1, -1, TileEntityTurbineValve.class, false),
TURBINE_VENT(12, "TurbineVent", -1, -1, TileEntityTurbineVent.class, false);
public int meta;
public String name;
public int guiId;
public double maxEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
private GeneratorType(int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
{
meta = i;
name = s;
guiId = j;
maxEnergy = k;
tileEntityClass = tileClass;
hasModel = model;
}
public static GeneratorType getFromMetadata(int meta)
{
for(GeneratorType type : values())
{
if(type.meta == meta)
{
return type;
}
}
return null;
}
public TileEntity create()
{
try {
return tileEntityClass.newInstance();
} catch(Exception e) {
Mekanism.logger.error("Unable to indirectly create tile entity.");
e.printStackTrace();
return null;
}
}
public String getDescription()
{
return LangUtils.localize("tooltip." + name);
}
public ItemStack getStack()
{
return new ItemStack(GeneratorsBlocks.Generator, 1, meta);
}
@Override
public String toString()
{
return Integer.toString(meta);
}
}
@Override
public void setRenderBounds(Block block, int metadata)
public PropertyEnum<GeneratorType> getTypeProperty()
{
if(metadata == GeneratorType.SOLAR_GENERATOR.meta)
{
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F);
}
else if(metadata == GeneratorType.TURBINE_ROTOR.meta)
{
block.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
}
else {
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@Override
public boolean doDefaultBoundSetting(int metadata)
{
return true;
return getGeneratorBlock().getProperty();
}
@Override
@@ -21,6 +21,7 @@ import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
@@ -164,9 +165,9 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock
}
@Override
public int damageDropped(int i)
public int damageDropped(IBlockState state)
{
return i;
return getMetaFromState(state);
}
@Override
@@ -368,6 +369,12 @@ public abstract class BlockReactor extends BlockContainer implements ICTMBlock
return false;
}
}
@Override
public PropertyEnum<ReactorBlockType> getTypeProperty()
{
return getReactorBlock().getProperty();
}
public ItemStack dismantleBlock(World world, BlockPos pos, boolean returnBlock)
{
@@ -1,6 +1,201 @@
package mekanism.generators.common.block.states;
public class BlockStateGenerator
{
import mekanism.api.MekanismConfig.general;
import mekanism.common.Mekanism;
import mekanism.common.block.states.BlockStateBasic;
import mekanism.common.block.states.BlockStateFacing;
import mekanism.common.util.LangUtils;
import mekanism.generators.common.GeneratorsBlocks;
import mekanism.generators.common.block.BlockGenerator;
import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator;
import mekanism.generators.common.tile.TileEntityBioGenerator;
import mekanism.generators.common.tile.TileEntityGasGenerator;
import mekanism.generators.common.tile.TileEntityHeatGenerator;
import mekanism.generators.common.tile.TileEntitySolarGenerator;
import mekanism.generators.common.tile.TileEntityWindGenerator;
import mekanism.generators.common.tile.turbine.TileEntityElectromagneticCoil;
import mekanism.generators.common.tile.turbine.TileEntityRotationalComplex;
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor;
import mekanism.generators.common.tile.turbine.TileEntityTurbineValve;
import mekanism.generators.common.tile.turbine.TileEntityTurbineVent;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumFacing.Plane;
import net.minecraft.util.IStringSerializable;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
public class BlockStateGenerator extends ExtendedBlockState
{
public static final PropertyBool activeProperty = PropertyBool.create("active");
public BlockStateGenerator(BlockGenerator block, PropertyEnum typeProperty)
{
super(block, new IProperty[] {BlockStateFacing.facingProperty, typeProperty, activeProperty}, new IUnlistedProperty[] {BlockStateBasic.ctmProperty});
}
public static enum GeneratorBlock
{
GENERATOR_BLOCK_1;
PropertyEnum<GeneratorType> generatorTypeProperty;
public PropertyEnum<GeneratorType> getProperty()
{
if(generatorTypeProperty == null)
{
generatorTypeProperty = PropertyEnum.create("generatorType", GeneratorType.class, new GeneratorBlockPredicate(this));
}
return generatorTypeProperty;
}
public Block getBlock()
{
switch(this)
{
case GENERATOR_BLOCK_1:
return GeneratorsBlocks.Generator;
default:
return null;
}
}
}
public static class GeneratorBlockPredicate implements Predicate<GeneratorType>
{
public GeneratorBlock GeneratorBlock;
public GeneratorBlockPredicate(GeneratorBlock type)
{
GeneratorBlock = type;
}
@Override
public boolean apply(GeneratorType input)
{
return input.blockType == GeneratorBlock;
}
}
public static enum GeneratorType implements IStringSerializable
{
HEAT_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true, Plane.HORIZONTAL, false),
SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true, Plane.HORIZONTAL, false),
GAS_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 3, "GasGenerator", 3, general.FROM_H2*100, TileEntityGasGenerator.class, true, Plane.HORIZONTAL, false),
BIO_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true, Plane.HORIZONTAL, false),
ADVANCED_SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true, Plane.HORIZONTAL, false),
WIND_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 6, "WindGenerator", 5, 200000, TileEntityWindGenerator.class, true, Plane.HORIZONTAL, false),
TURBINE_ROTOR(GeneratorBlock.GENERATOR_BLOCK_1, 7, "TurbineRotor", -1, -1, TileEntityTurbineRotor.class, false, Predicates.alwaysFalse(), false),
ROTATIONAL_COMPLEX(GeneratorBlock.GENERATOR_BLOCK_1, 8, "RotationalComplex", -1, -1, TileEntityRotationalComplex.class, false, Predicates.alwaysFalse(), false),
ELECTROMAGNETIC_COIL(GeneratorBlock.GENERATOR_BLOCK_1, 9, "ElectromagneticCoil", -1, -1, TileEntityElectromagneticCoil.class, false, Predicates.alwaysFalse(), false),
TURBINE_CASING(GeneratorBlock.GENERATOR_BLOCK_1, 10, "TurbineCasing", -1, -1, TileEntityTurbineCasing.class, false, Predicates.alwaysFalse(), false),
TURBINE_VALVE(GeneratorBlock.GENERATOR_BLOCK_1, 11, "TurbineValve", -1, -1, TileEntityTurbineValve.class, false, Predicates.alwaysFalse(), false),
TURBINE_VENT(GeneratorBlock.GENERATOR_BLOCK_1, 12, "TurbineVent", -1, -1, TileEntityTurbineVent.class, false, Predicates.alwaysFalse(), false);
public GeneratorBlock blockType;
public int meta;
public String name;
public int guiId;
public double maxEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
public Predicate<EnumFacing> facingPredicate;
public boolean activable;
private GeneratorType(GeneratorBlock block, int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean model, Predicate<EnumFacing> predicate, boolean hasActiveTexture)
{
blockType = block;
meta = i;
name = s;
guiId = j;
maxEnergy = k;
tileEntityClass = tileClass;
hasModel = model;
facingPredicate = predicate;
activable = hasActiveTexture;
}
public static GeneratorType get(IBlockState state)
{
if(state.getBlock() instanceof BlockGenerator)
{
return state.getValue(((BlockGenerator)state.getBlock()).getTypeProperty());
}
return null;
}
public static GeneratorType get(Block block, int meta)
{
if(block instanceof BlockGenerator)
{
return get(((BlockGenerator)block).getGeneratorBlock(), meta);
}
return null;
}
public static GeneratorType get(GeneratorBlock block, int meta)
{
for(GeneratorType type : values())
{
if(type.meta == meta && type.blockType == block)
{
return type;
}
}
return null;
}
public static GeneratorType get(ItemStack stack)
{
return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
}
public TileEntity create()
{
try {
return tileEntityClass.newInstance();
} catch(Exception e) {
Mekanism.logger.error("Unable to indirectly create tile entity.");
e.printStackTrace();
return null;
}
}
@Override
public String getName()
{
return name().toLowerCase();
}
public String getDescription()
{
return LangUtils.localize("tooltip." + name);
}
public ItemStack getStack()
{
return new ItemStack(GeneratorsBlocks.Generator, 1, meta);
}
@Override
public String toString()
{
return Integer.toString(meta);
}
}
}
@@ -10,9 +10,8 @@ import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.multiblock.UpdateProtocol;
import mekanism.common.tile.TileEntityPressureDisperser;
import mekanism.generators.common.GeneratorsBlocks;
import mekanism.generators.common.MekanismGenerators;
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorType;
import mekanism.generators.common.tile.turbine.TileEntityElectromagneticCoil;
import mekanism.generators.common.tile.turbine.TileEntityRotationalComplex;
import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing;
@@ -36,8 +35,7 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
@Override
protected boolean isValidFrame(int x, int y, int z)
{
return pointer.getWorld().getBlock(x, y, z) == GeneratorsBlocks.Generator &&
GeneratorType.getFromMetadata(pointer.getWorld().getBlockMetadata(x, y, z)) == GeneratorType.TURBINE_CASING;
return GeneratorType.get(pointer.getWorld().getBlockState(new BlockPos(x, y, z))) == GeneratorType.TURBINE_CASING;
}
@Override
@@ -48,7 +46,7 @@ public class TurbineUpdateProtocol extends UpdateProtocol<SynchronizedTurbineDat
return true;
}
TileEntity tile = pointer.getWorld().getTileEntity(x, y, z);
TileEntity tile = pointer.getWorld().getTileEntity(new BlockPos(x, y, z));
return tile instanceof TileEntityTurbineRotor || tile instanceof TileEntityRotationalComplex ||
tile instanceof TileEntityPressureDisperser || tile instanceof TileEntityElectromagneticCoil;
@@ -22,7 +22,7 @@ import mekanism.common.tile.TileEntityElectricBlock;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.SecurityUtils;
import mekanism.generators.common.block.BlockGenerator.GeneratorType;
import mekanism.generators.common.block.states.BlockStateGenerator.GeneratorType;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.settings.GameSettings;
@@ -79,7 +79,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
@Override
public int getItemStackLimit(ItemStack stack)
{
GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage());
GeneratorType type = GeneratorType.get(stack);
if(type.maxEnergy == -1)
{
@@ -99,19 +99,19 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
if(GeneratorType.getFromMetadata(itemstack.getItemDamage()) == null)
if(GeneratorType.get(itemstack) == null)
{
return "KillMe!";
}
return getUnlocalizedName() + "." + GeneratorType.getFromMetadata(itemstack.getItemDamage()).name;
return getUnlocalizedName() + "." + GeneratorType.get(itemstack).name;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
GeneratorType type = GeneratorType.getFromMetadata(itemstack.getItemDamage());
GeneratorType type = GeneratorType.get(itemstack);
if(type.maxEnergy > -1)
{
@@ -406,7 +406,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
@Override
public double getMaxEnergy(ItemStack itemStack)
{
return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy;
return GeneratorType.get(itemStack).maxEnergy;
}
@Override
@@ -424,7 +424,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
@Override
public boolean canSend(ItemStack itemStack)
{
return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy != -1;
return GeneratorType.get(itemStack).maxEnergy != -1;
}
@Override
@@ -433,14 +433,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
if(canReceive(theItem))
{
double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem);
double toReceive = Math.min(energy* general.FROM_TE, energyNeeded);
double toReceive = Math.min(energy*general.FROM_TE, energyNeeded);
if(!simulate)
{
setEnergy(theItem, getEnergy(theItem) + toReceive);
}
return (int)Math.round(toReceive* general.TO_TE);
return (int)Math.round(toReceive*general.TO_TE);
}
return 0;
@@ -452,14 +452,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
if(canSend(theItem))
{
double energyRemaining = getEnergy(theItem);
double toSend = Math.min((energy* general.FROM_TE), energyRemaining);
double toSend = Math.min((energy*general.FROM_TE), energyRemaining);
if(!simulate)
{
setEnergy(theItem, getEnergy(theItem) - toSend);
}
return (int)Math.round(toSend* general.TO_TE);
return (int)Math.round(toSend*general.TO_TE);
}
return 0;
@@ -468,13 +468,13 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
@Override
public int getEnergyStored(ItemStack theItem)
{
return (int)(getEnergy(theItem)* general.TO_TE);
return (int)(getEnergy(theItem)*general.TO_TE);
}
@Override
public int getMaxEnergyStored(ItemStack theItem)
{
return (int)(getMaxEnergy(theItem)* general.TO_TE);
return (int)(getMaxEnergy(theItem)*general.TO_TE);
}
@Override
@@ -537,7 +537,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp
@Override
public boolean hasSecurity(ItemStack stack)
{
GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage());
GeneratorType type = GeneratorType.get(stack);
return type.hasModel;
}
@@ -5,7 +5,6 @@ import java.util.List;
import mekanism.api.EnumColor;
import mekanism.common.util.LangUtils;
import mekanism.common.util.MekanismUtils;
import mekanism.generators.common.block.states.BlockStateReactor;
import mekanism.generators.common.block.states.BlockStateReactor.ReactorBlockType;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
@@ -36,14 +35,14 @@ public class ItemBlockReactor extends ItemBlock
@Override
public String getUnlocalizedName(ItemStack itemstack)
{
return getUnlocalizedName() + "." + BlockStateReactor.ReactorBlockType.get(itemstack).name;
return getUnlocalizedName() + "." + ReactorBlockType.get(itemstack).name;
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
BlockStateReactor.ReactorBlockType type = BlockStateReactor.ReactorBlockType.get(itemstack);
ReactorBlockType type = ReactorBlockType.get(itemstack);
if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
{