Skip to content

Commit

Permalink
Merge pull request #44 from ganymedes01/master
Browse files Browse the repository at this point in the history
Bunch of fixes and cleanups. See description for details
  • Loading branch information
progwml6 committed Jun 15, 2015
2 parents f64fb40 + f5b98a4 commit c55603a
Show file tree
Hide file tree
Showing 42 changed files with 480 additions and 513 deletions.
52 changes: 0 additions & 52 deletions 18 Mappings.txt

This file was deleted.

62 changes: 29 additions & 33 deletions src/main/java/cpw/mods/ironchest/BlockIronChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public class BlockIronChest extends BlockContainer
public BlockIronChest()
{
super(Material.iron);

this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT_PROP, IronChestType.IRON));

this.setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
this.setHardness(3.0F);
this.setUnlocalizedName("IronChest");
Expand All @@ -69,13 +69,7 @@ public boolean isFullCube()
{
return false;
}

@Override
public int getRenderType()
{
return 2;
}


@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState blockState, EntityPlayer player, EnumFacing direction, float p_180639_6_, float p_180639_7_, float p_180639_8_)
{
Expand All @@ -99,13 +93,13 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState blockStat
player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
return true;
}

@Override
public TileEntity createNewTileEntity(World world, int metadata)
{
return IronChestType.makeEntity(metadata);
}

@Override
@SideOnly(Side.CLIENT)
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list)
Expand All @@ -118,7 +112,7 @@ public void getSubBlocks(Item itemIn, CreativeTabs tab, List list)
}
}
}

@Override
public IBlockState getStateFromMeta(int meta)
{
Expand All @@ -128,9 +122,9 @@ public IBlockState getStateFromMeta(int meta)
@Override
public int getMetaFromState(IBlockState blockState)
{
return ((IronChestType)blockState.getValue(VARIANT_PROP)).ordinal();
return ((IronChestType) blockState.getValue(VARIANT_PROP)).ordinal();
}

@Override
protected BlockState createBlockState()
{
Expand All @@ -141,7 +135,7 @@ protected BlockState createBlockState()
public ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
{
ArrayList<ItemStack> items = Lists.newArrayList();
ItemStack stack = new ItemStack(this,1,getMetaFromState(state));
ItemStack stack = new ItemStack(this, 1, getMetaFromState(state));
IronChestType.values()[IronChestType.validateMeta(getMetaFromState(state))].adornItemDrop(stack);
items.add(stack);
return items;
Expand All @@ -158,7 +152,7 @@ public void onBlockAdded(World world, BlockPos pos, IBlockState blockState)
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState blockState, EntityLivingBase entityliving, ItemStack itemStack)
{
byte chestFacing = 0;
int facing = MathHelper.floor_double((double) ((entityliving.rotationYaw * 4F) / 360F) + 0.5D) & 3;
int facing = MathHelper.floor_double((entityliving.rotationYaw * 4F) / 360F + 0.5D) & 3;
if (facing == 0)
{
chestFacing = 2;
Expand Down Expand Up @@ -188,7 +182,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState blockState, E
@Override
public int damageDropped(IBlockState state)
{
return IronChestType.validateMeta(((IronChestType)state.getValue(VARIANT_PROP)).ordinal());
return IronChestType.validateMeta(((IronChestType) state.getValue(VARIANT_PROP)).ordinal());
}

@Override
Expand All @@ -206,7 +200,7 @@ public void breakBlock(World world, BlockPos pos, IBlockState blockState)
public void dropContent(int newSize, IInventory chest, World world, BlockPos pos)
{
Random random = world.rand;

for (int l = newSize; l < chest.getSizeInventory(); l++)
{
ItemStack itemstack = chest.getStackInSlot(l);
Expand All @@ -225,8 +219,7 @@ public void dropContent(int newSize, IInventory chest, World world, BlockPos pos
i1 = itemstack.stackSize;
}
itemstack.stackSize -= i1;
EntityItem entityitem = new EntityItem(world, (float) pos.getX() + f, (float) pos.getY() + (newSize > 0 ? 1 : 0) + f1, (float) pos.getZ() + f2,
new ItemStack(itemstack.getItem(), i1, itemstack.getMetadata()));
EntityItem entityitem = new EntityItem(world, pos.getX() + f, (float) pos.getY() + (newSize > 0 ? 1 : 0) + f1, pos.getZ() + f2, new ItemStack(itemstack.getItem(), i1, itemstack.getMetadata()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
Expand All @@ -243,20 +236,21 @@ public void dropContent(int newSize, IInventory chest, World world, BlockPos pos
@Override
public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion)
{
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityIronChest)
{
TileEntityIronChest teic = (TileEntityIronChest) te;
if (teic.getType().isExplosionResistant())
{
return 10000F;
}
}
return super.getExplosionResistance(world, pos, exploder, explosion);
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityIronChest)
{
TileEntityIronChest teic = (TileEntityIronChest) te;
if (teic.getType().isExplosionResistant())
{
return 10000F;
}
}
return super.getExplosionResistance(world, pos, exploder, explosion);
}

@Override
public boolean hasComparatorInputOverride() {
public boolean hasComparatorInputOverride()
{
return true;
}

Expand All @@ -266,12 +260,13 @@ public int getComparatorInputOverride(World world, BlockPos pos)
TileEntity te = world.getTileEntity(pos);
if (te instanceof IInventory)
{
return Container.calcRedstoneFromInventory((IInventory)te);
return Container.calcRedstoneFromInventory((IInventory) te);
}
return 0;
}

private static final EnumFacing[] validRotationAxes = new EnumFacing[] { EnumFacing.UP, EnumFacing.DOWN };

@Override
public EnumFacing[] getValidRotations(World worldObj, BlockPos pos)
{
Expand All @@ -288,7 +283,8 @@ public boolean rotateBlock(World worldObj, BlockPos pos, EnumFacing axis)
if (axis == EnumFacing.UP || axis == EnumFacing.DOWN)
{
TileEntity tileEntity = worldObj.getTileEntity(pos);
if (tileEntity instanceof TileEntityIronChest) {
if (tileEntity instanceof TileEntityIronChest)
{
TileEntityIronChest icte = (TileEntityIronChest) tileEntity;
icte.rotateAround();
}
Expand Down
20 changes: 5 additions & 15 deletions src/main/java/cpw/mods/ironchest/IronChest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
******************************************************************************/
package cpw.mods.ironchest;

import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
Expand All @@ -21,12 +19,9 @@
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.relauncher.Side;

@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:FML@[7.2,)")
public class IronChest
public class IronChest
{
public static BlockIronChest ironChestBlock;
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
Expand All @@ -39,27 +34,22 @@ public void preInit(FMLPreInitializationEvent event)
{
Version.init(event.getVersionProperties());
event.getModMetadata().version = Version.fullVersionString();

PacketHandler.INSTANCE.ordinal();
}

@EventHandler
public void load(FMLInitializationEvent evt)
{
//Registration has been moved to init to account for the registration of inventory models
//Minecraft.getRenderItem() returns null before this stage
// Registration has been moved to init to account for the registration of inventory models
// Minecraft.getRenderItem() returns null before this stage
ChestChangerType.buildItems();
ironChestBlock = new BlockIronChest();
RegistryHelper.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest");

if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getBlockModelShapes().registerBuiltInBlocks(ironChestBlock);

GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest");

for (IronChestType typ : IronChestType.values())
{
GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest." + typ.name(), typ.name());
proxy.registerTileEntitySpecialRenderer(typ);
}
OreDictionary.registerOre("chestWood", Blocks.chest);
IronChestType.registerBlocksAndRecipes(ironChestBlock);
ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
Expand Down
33 changes: 0 additions & 33 deletions src/main/java/cpw/mods/ironchest/MappableItemStackWrapper.java

This file was deleted.

Loading

0 comments on commit c55603a

Please sign in to comment.