This commit is contained in:
Taylor Shuler 2014-08-11 04:26:08 +00:00
commit cef38f6c39
105 changed files with 508 additions and 947 deletions

11
.gitattributes vendored Normal file
View File

@ -0,0 +1,11 @@
# Set default behaviour, in case users don't have core.autocrlf set.
* text=auto
# Explicitly declare text files we want to always be normalized and converted to native line endings on checkout.
*.md text
*.info text
*.txt text
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

30
.gitignore vendored
View File

@ -1,14 +1,28 @@
build/ gnore Gradle cache files & directories
.classpath
.project
.gradle/
eclipse/
bin/ bin/
build/
## Exclusive to IronChests
repo/ repo/
/run/ run/
## Forge
forge-*.txt
## Eclipse
eclipse/
.classpath
.gradle/
.project
.settings/ .settings/
#IDEA files from Gradle
.idea/ ## Idea
.idea
/*.iml /*.iml
/*.ipr /*.ipr
/*.iws /*.iws
# Ignore OS cache files & directories
*.DS_Store
_MACOSX
Thumbs.db

5
LICENSE.txt Normal file
View File

@ -0,0 +1,5 @@
Copyright (c) 2012-14 cpw
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Public License v3.0,
which are available at http://www.gnu.org/licenses/gpl.html

2
scripts/setup.bat Normal file
View File

@ -0,0 +1,2 @@
gradle setupDecompWorkspace
gradle eclipse

1
scripts/setup.sh Normal file
View File

@ -0,0 +1 @@
gradle setupDecompWorkspace && gradle eclipse

2
scripts/setupw.bat Normal file
View File

@ -0,0 +1,2 @@
gradlew setupDecompWorkspace
gradlew eclipse

1
scripts/setupw.sh Normal file
View File

@ -0,0 +1 @@
bash gradlew setupDecompWorkspace && bash gradlew eclipse

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import static net.minecraftforge.common.util.ForgeDirection.DOWN; import static net.minecraftforge.common.util.ForgeDirection.DOWN;
@ -17,8 +7,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.google.common.collect.Lists;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -38,15 +26,15 @@ import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import com.google.common.collect.Lists;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class BlockIronChest extends BlockContainer { public class BlockIronChest extends BlockContainer {
@SideOnly(Side.CLIENT)
private Random random; public static IIcon icon[] = new IIcon[IronChestType.values().length];
@SideOnly(Side.CLIENT)
private IIcon[][] icons;
public BlockIronChest() public BlockIronChest()
{ {
@ -54,17 +42,13 @@ public class BlockIronChest extends BlockContainer {
setBlockName("IronChest"); setBlockName("IronChest");
setHardness(3.0F); setHardness(3.0F);
setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F); setBlockBounds(0.0625F, 0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
random = new Random();
setCreativeTab(CreativeTabs.tabDecorations); setCreativeTab(CreativeTabs.tabDecorations);
} }
/**
* Overridden by {@link #createTileEntity(World, int)}
*/
@Override @Override
public TileEntity createNewTileEntity(World w, int i) public TileEntity createNewTileEntity(World world, int meta)
{ {
return null; return IronChestType.makeEntity(meta);
} }
@Override @Override
@ -86,21 +70,23 @@ public class BlockIronChest extends BlockContainer {
} }
@Override @Override
public TileEntity createTileEntity(World world, int metadata) @SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister r)
{ {
return IronChestType.makeEntity(metadata); for (IronChestType type : IronChestType.values())
{
if (type.isValidForCreativeMode())
{
icon[type.ordinal()] = r.registerIcon("ironchest:" + type.name().toLowerCase());
}
}
} }
@SideOnly(Side.CLIENT)
@Override @Override
public IIcon getIcon(int i, int j) @SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{ {
if (j < IronChestType.values().length) return icon[meta];
{
IronChestType type = IronChestType.values()[j];
return type.getIcon(i);
}
return null;
} }
@Override @Override
@ -112,22 +98,13 @@ public class BlockIronChest extends BlockContainer {
items.add(stack); items.add(stack);
return items; return items;
} }
@Override @Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3) public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3)
{ {
TileEntity te = world.getTileEntity(i, j, k); TileEntity te = world.getTileEntity(i, j, k);
if (te == null || !(te instanceof TileEntityIronChest)) if (te == null || !(te instanceof TileEntityIronChest) || world.isSideSolid(i, j + 1, k, ForgeDirection.DOWN) || world.isRemote)
{
return true;
}
if (world.isSideSolid(i, j + 1, k, ForgeDirection.DOWN))
{
return true;
}
if (world.isRemote)
{ {
return true; return true;
} }
@ -187,48 +164,48 @@ public class BlockIronChest extends BlockContainer {
if (tileentitychest != null) if (tileentitychest != null)
{ {
tileentitychest.removeAdornments(); tileentitychest.removeAdornments();
dropContent(0, tileentitychest, world, tileentitychest.xCoord, tileentitychest.yCoord, tileentitychest.zCoord); dropItems(0, tileentitychest, world, tileentitychest.xCoord, tileentitychest.yCoord, tileentitychest.zCoord);
} }
super.breakBlock(world, i, j, k, i1, i2); super.breakBlock(world, i, j, k, i1, i2);
} }
public void dropContent(int newSize, IInventory chest, World world, int xCoord, int yCoord, int zCoord) public void dropItems(int newSize, IInventory chest, World world, int i, int j, int k)
{ {
for (int l = newSize; l < chest.getSizeInventory(); l++) for (int i1 = 0; i1 < chest.getSizeInventory(); ++i1)
{ {
ItemStack itemstack = chest.getStackInSlot(l); Random rand = new Random();
if (itemstack == null) ItemStack is = chest.getStackInSlot(i1);
if (is != null)
{ {
continue; EntityItem entityitem;
}
float f = random.nextFloat() * 0.8F + 0.1F; for (float f = rand.nextFloat() * 0.8F + 0.1F; is.stackSize > 0; world.spawnEntityInWorld(entityitem))
float f1 = random.nextFloat() * 0.8F + 0.1F;
float f2 = random.nextFloat() * 0.8F + 0.1F;
while (itemstack.stackSize > 0)
{
int i1 = random.nextInt(21) + 10;
if (i1 > itemstack.stackSize)
{ {
i1 = itemstack.stackSize; int j1 = rand.nextInt(21) + 10;
if (j1 > is.stackSize)
{
j1 = is.stackSize;
}
is.stackSize -= j1;
entityitem = new EntityItem(world, (double)((float)i + f), (double)((float)j + f), (double)((float)k + f), new ItemStack(is.getItem(), j1, is.getItemDamage()));
float f2 = 0.05F;
entityitem.motionX = (double)((float)rand.nextGaussian() * f2);
entityitem.motionY = (double)((float)rand.nextGaussian() * f2 + 0.2F);
entityitem.motionZ = (double)((float)rand.nextGaussian() * f2);
if (is.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound)is.getTagCompound().copy());
}
} }
itemstack.stackSize -= i1;
EntityItem entityitem = new EntityItem(world, (float) xCoord + f, (float) yCoord + (newSize > 0 ? 1 : 0) + f1, (float) zCoord + f2,
new ItemStack(itemstack.getItem(), i1, itemstack.getItemDamage()));
float f3 = 0.05F;
entityitem.motionX = (float) random.nextGaussian() * f3;
entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) random.nextGaussian() * f3;
if (itemstack.hasTagCompound())
{
entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
}
world.spawnEntityInWorld(entityitem);
} }
} }
} }
@Override @Override
@SuppressWarnings({ "rawtypes", "unchecked" })
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{ {
@ -272,22 +249,10 @@ public class BlockIronChest extends BlockContainer {
return 0; return 0;
} }
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister par1IconRegister)
{
for (IronChestType typ: IronChestType.values())
{
typ.makeIcons(par1IconRegister);
}
}
private static final ForgeDirection[] validRotationAxes = new ForgeDirection[] { UP, DOWN };
@Override @Override
public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z) public ForgeDirection[] getValidRotations(World worldObj, int x, int y, int z)
{ {
return validRotationAxes; return new ForgeDirection[] { UP, DOWN };
} }
@Override @Override

View File

@ -1,9 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw. All rights reserved. This program and the accompanying materials are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at http://www.gnu.org/licenses/gpl.html
*
* Contributors: cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import static cpw.mods.ironchest.IronChestType.COPPER; import static cpw.mods.ironchest.IronChestType.COPPER;
@ -16,7 +10,6 @@ import static cpw.mods.ironchest.IronChestType.SILVER;
import static cpw.mods.ironchest.IronChestType.WOOD; import static cpw.mods.ironchest.IronChestType.WOOD;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
public enum ChestChangerType { public enum ChestChangerType {
@ -56,7 +49,7 @@ public enum ChestChangerType {
return this.target.ordinal(); return this.target.ordinal();
} }
public ItemChestChanger buildItem(Configuration cfg) public ItemChestChanger buildItem()
{ {
item = new ItemChestChanger(this); item = new ItemChestChanger(this);
GameRegistry.registerItem(item, itemName); GameRegistry.registerItem(item, itemName);
@ -76,14 +69,6 @@ public enum ChestChangerType {
} }
} }
public static void buildItems(Configuration cfg)
{
for (ChestChangerType type : values())
{
type.buildItem(cfg);
}
}
public static void generateRecipes() public static void generateRecipes()
{ {
for (ChestChangerType item : values()) for (ChestChangerType item : values())

View File

@ -1,55 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;
public class CommonProxy implements IGuiHandler {
public void registerRenderInformation()
{
}
public void registerTileEntitySpecialRenderer(IronChestType typ)
{
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
return null;
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z)
{
TileEntity te = world.getTileEntity(X, Y, Z);
if (te != null && te instanceof TileEntityIronChest)
{
TileEntityIronChest icte = (TileEntityIronChest) te;
return new ContainerIronChest(player.inventory, icte, icte.getType(), 0, 0);
}
else
{
return null;
}
}
public World getClientWorld()
{
return null;
}
}

View File

@ -1,22 +1,12 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import invtweaks.api.container.ChestContainer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot; import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import invtweaks.api.container.ChestContainer;
@ChestContainer(isLargeChest = true) @ChestContainer(isLargeChest = true)
public class ContainerIronChest extends Container { public class ContainerIronChest extends Container {
@ -85,13 +75,13 @@ public class ContainerIronChest extends Container {
protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize) protected void layoutContainer(IInventory playerInventory, IInventory chestInventory, IronChestType type, int xSize, int ySize)
{ {
if (type == IronChestType.DIRTCHEST9000) { if (type == IronChestType.DIRTCHEST9000) {
addSlotToContainer(type.makeSlot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18)); addSlotToContainer(new Slot(chestInventory, 0, 12 + 4 * 18, 8 + 2 * 18));
} else { } else {
for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++) for (int chestRow = 0; chestRow < type.getRowCount(); chestRow++)
{ {
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++) for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
{ {
addSlotToContainer(type.makeSlot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18)); addSlotToContainer(new Slot(chestInventory, chestCol + chestRow * type.getRowLength(), 12 + chestCol * 18, 8 + chestRow * 18));
} }
} }
} }
@ -101,8 +91,7 @@ public class ContainerIronChest extends Container {
{ {
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++) for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
{ {
addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
- 10));
} }
} }

View File

@ -1,88 +1,55 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import org.apache.logging.log4j.Level;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.ironchest.net.UniversalProxy;
@Mod(modid = "IronChest", name = "Iron Chests", dependencies = "required-after:Forge@[10.10,);required-after:FML@[7.2,)") @Mod(modid = IronChest.modid, name = IronChest.name)
public class IronChest { public class IronChest {
public static BlockIronChest ironChestBlock; public static final String modid = "IronChest", name = "Iron Chests", proxyPath = "cpw.mods.ironchest.net.UniversalProxy";
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.CommonProxy")
public static CommonProxy proxy; @Instance(modid)
@Instance("IronChest") public static IronChest instance;
public static IronChest instance;
public static boolean CACHE_RENDER = true; @SidedProxy(clientSide = proxyPath, serverSide = proxyPath)
public static boolean OCELOTS_SITONCHESTS = true; public static UniversalProxy proxy;
public static BlockIronChest ironChestBlock;
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event) public void preInit(FMLPreInitializationEvent e)
{ {
Version.init(event.getVersionProperties()); Version.init(e.getVersionProperties());
event.getModMetadata().version = Version.fullVersionString(); e.getModMetadata().version = Version.fullVersionString();
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
try for (ChestChangerType type : ChestChangerType.values())
{ type.buildItem();
cfg.load();
ChestChangerType.buildItems(cfg);
CACHE_RENDER = cfg.get(Configuration.CATEGORY_GENERAL, "cacheRenderingInformation", true).getBoolean(true);
OCELOTS_SITONCHESTS = cfg.get(Configuration.CATEGORY_GENERAL, "ocelotsSitOnChests", true).getBoolean(true);
}
catch (Exception e)
{
FMLLog.log(Level.ERROR, e, "IronChest has a problem loading its configuration");
}
finally
{
if (cfg.hasChanged())
cfg.save();
}
ironChestBlock = new BlockIronChest(); ironChestBlock = new BlockIronChest();
GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest"); GameRegistry.registerBlock(ironChestBlock, ItemIronChest.class, "BlockIronChest");
PacketHandler.INSTANCE.ordinal(); PacketHandler.INSTANCE.ordinal();
} }
@EventHandler @EventHandler
public void load(FMLInitializationEvent evt) public void init(FMLInitializationEvent e)
{ {
for (IronChestType typ : IronChestType.values()) for (IronChestType typ : IronChestType.values())
{ {
GameRegistry.registerTileEntityWithAlternatives(typ.clazz, "IronChest."+typ.name(), typ.name()); GameRegistry.registerTileEntityWithAlternatives(typ.clazz, modid + "." + typ.name(), typ.name());
proxy.registerTileEntitySpecialRenderer(typ); proxy.registerTileEntitySpecialRenderer(typ);
} }
IronChestType.registerBlocksAndRecipes(ironChestBlock); IronChestType.registerBlocksAndRecipes(ironChestBlock);
ChestChangerType.generateRecipes(); ChestChangerType.generateRecipes();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy); NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.registerRenderInformation(); proxy.registerRenderInformation();
// if (OCELOTS_SITONCHESTS)
// {
// MinecraftForge.EVENT_BUS.register(new OcelotsSitOnChestsHandler());
// }
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@EventHandler
public void modsLoaded(FMLPostInitializationEvent evt)
{
}
} }

View File

@ -1,22 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.world.World;
public class IronChestAIOcelotSit extends EntityAIOcelotSit {
public IronChestAIOcelotSit(EntityOcelot par1EntityOcelot, float par2)
{
super(par1EntityOcelot, par2);
}
/* @Override
protected boolean func_151486_a(World world, int x, int y, int z)
{
if (world.getBlock(x, y, z) == IronChest.ironChestBlock)
{
return true;
}
return super.func_151486_a(world, x, y, z);
}
*/}

View File

@ -1,41 +1,26 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagByte;
import net.minecraft.util.IIcon;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public enum IronChestType { public enum IronChestType {
IRON(54, 9, true, "Iron Chest", "ironchest.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"), IRON(54, 9, true, "Iron Chest", "chest_iron.png", 0, Arrays.asList("ingotIron", "ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"),
GOLD(81, 9, true, "Gold Chest", "goldchest.png", 1, Arrays.asList("ingotGold"), TileEntityGoldChest.class, "mmmmPmmmm", "mGmG4GmGm"), GOLD(81, 9, true, "Gold Chest", "chest_gold.png", 1, Arrays.asList("ingotGold"), TileEntityGoldChest.class, "mmmmPmmmm", "mGmG4GmGm"),
DIAMOND(108, 12, true, "Diamond Chest", "diamondchest.png", 2, Arrays.asList("gemDiamond"), TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"), DIAMOND(108, 12, true, "Diamond Chest", "chest_diamond.png", 2, Arrays.asList("gemDiamond"), TileEntityDiamondChest.class, "GGGmPmGGG", "GGGG4Gmmm"),
COPPER(45, 9, false, "Copper Chest", "copperchest.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"), COPPER(45, 9, false, "Copper Chest", "chest_copper.png", 3, Arrays.asList("ingotCopper"), TileEntityCopperChest.class, "mmmmCmmmm"),
SILVER(72, 9, false, "Silver Chest", "silverchest.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"), SILVER(72, 9, false, "Silver Chest", "chest_silver.png", 4, Arrays.asList("ingotSilver"), TileEntitySilverChest.class, "mmmm3mmmm", "mGmG0GmGm"),
CRYSTAL(108, 12, true, "Crystal Chest", "crystalchest.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"), CRYSTAL(108, 12, true, "Crystal Chest", "chest_crystal.png", 5, Arrays.asList("blockGlass"), TileEntityCrystalChest.class, "GGGGPGGGG"),
OBSIDIAN(108, 12, false, "Obsidian Chest", "obsidianchest.png", 6, Arrays.asList("obsidian"), TileEntityObsidianChest.class, "mmmm2mmmm"), OBSIDIAN(108, 12, false, "Obsidian Chest", "chest_obsidian.png", 6, Arrays.asList("obsidian"), TileEntityObsidianChest.class, "mmmm2mmmm"),
DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "dirtchest.png",7,Arrays.asList("dirt"), TileEntityDirtChest.class,Item.getItemFromBlock(Blocks.dirt),"mmmmCmmmm"), DIRTCHEST9000(1, 1, false, "Dirt Chest 9000", "chest_dirt.png", 7, Arrays.asList("dirt"), TileEntityDirtChest.class, Item.getItemFromBlock(Blocks.dirt), "mmmmCmmmm"),
WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null); WOOD(0, 0, false, "", "", -1, Arrays.asList("plankWood"), null);
int size; int size;
private int rowLength; private int rowLength;
@ -104,10 +89,6 @@ public enum IronChestType {
return null; return null;
} }
public static void registerTranslations()
{
}
public static void registerBlocksAndRecipes(BlockIronChest blockResult) public static void registerBlocksAndRecipes(BlockIronChest blockResult)
{ {
ItemStack previous = new ItemStack(Blocks.chest); ItemStack previous = new ItemStack(Blocks.chest);
@ -219,42 +200,11 @@ public enum IronChestType {
return this == OBSIDIAN; return this == OBSIDIAN;
} }
@SideOnly(Side.CLIENT)
private IIcon[] icons;
@SideOnly(Side.CLIENT)
public void makeIcons(IIconRegister par1IconRegister)
{
if (isValidForCreativeMode())
{
icons = new IIcon[3];
int i = 0;
for (String s : sideNames)
{
icons[i++] = par1IconRegister.registerIcon(String.format("ironchest:%s_%s",name().toLowerCase(),s));
}
}
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side)
{
return icons[sideMapping[side]];
}
private static String[] sideNames = { "top", "front", "side" };
private static int[] sideMapping = { 0, 0, 2, 1, 2, 2, 2 };
public Slot makeSlot(IInventory chestInventory, int index, int x, int y)
{
return new ValidatingSlot(chestInventory, index, x, y, this);
}
public boolean acceptsStack(ItemStack itemstack) public boolean acceptsStack(ItemStack itemstack)
{ {
return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter; return itemFilter == null || itemstack == null || itemstack.getItem() == itemFilter;
} }
public void adornItemDrop(ItemStack item) public void adornItemDrop(ItemStack item)
{ {
if (this == DIRTCHEST9000) if (this == DIRTCHEST9000)

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.client.renderer.texture.IIconRegister;
@ -24,7 +14,6 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class ItemChestChanger extends Item { public class ItemChestChanger extends Item {
private ChestChangerType type; private ChestChangerType type;
public ItemChestChanger(ChestChangerType type) public ItemChestChanger(ChestChangerType type)
@ -36,7 +25,6 @@ public class ItemChestChanger extends Item {
setCreativeTab(CreativeTabs.tabMisc); setCreativeTab(CreativeTabs.tabMisc);
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister) public void registerIcons(IIconRegister par1IconRegister)
@ -76,7 +64,7 @@ public class ItemChestChanger extends Item {
ItemStack[] chestContents = ObfuscationReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0); ItemStack[] chestContents = ObfuscationReflectionHelper.getPrivateValue(TileEntityChest.class, tec, 0);
System.arraycopy(chestContents, 0, newchest.chestContents, 0, Math.min(newSize, chestContents.length)); System.arraycopy(chestContents, 0, newchest.chestContents, 0, Math.min(newSize, chestContents.length));
BlockIronChest block = IronChest.ironChestBlock; BlockIronChest block = IronChest.ironChestBlock;
block.dropContent(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord); block.dropItems(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord);
newchest.setFacing((byte) tec.getBlockMetadata()); newchest.setFacing((byte) tec.getBlockMetadata());
newchest.sortTopStacks(); newchest.sortTopStacks();
for (int i = 0; i < Math.min(newSize, chestContents.length); i++) for (int i = 0; i < Math.min(newSize, chestContents.length); i++)
@ -87,8 +75,7 @@ public class ItemChestChanger extends Item {
world.setBlock(X, Y, Z, Blocks.air, 0, 3); world.setBlock(X, Y, Z, Blocks.air, 0, 3);
// Force the Chest TE to reset it's knowledge of neighbouring blocks // Force the Chest TE to reset it's knowledge of neighbouring blocks
tec.updateContainingBlockInfo(); tec.updateContainingBlockInfo();
// Force the Chest TE to update any neighbours so they update next // Force the Chest TE to update any neighbours so they update next tick
// tick
tec.checkForAdjacentChests(); tec.checkForAdjacentChests();
// And put in our block instead // And put in our block instead
world.setBlock(X, Y, Z, block, newchest.getType().ordinal(), 3); world.setBlock(X, Y, Z, block, newchest.getType().ordinal(), 3);

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import net.minecraft.block.Block; import net.minecraft.block.Block;

View File

@ -1,33 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.item.ItemStack;
public class MappableItemStackWrapper {
private ItemStack wrap;
public MappableItemStackWrapper(ItemStack toWrap)
{
wrap = toWrap;
}
@Override
public boolean equals(Object obj)
{
if (!(obj instanceof MappableItemStackWrapper)) return false;
MappableItemStackWrapper isw = (MappableItemStackWrapper) obj;
if (wrap.getHasSubtypes())
{
return isw.wrap.isItemEqual(wrap);
}
else
{
return isw.wrap == wrap;
}
}
@Override
public int hashCode()
{
return System.identityHashCode(wrap);
}
}

View File

@ -1,30 +0,0 @@
package cpw.mods.ironchest;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.ai.EntityAIOcelotSit;
import net.minecraft.entity.ai.EntityAITasks;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraftforge.event.entity.living.LivingEvent;
public class OcelotsSitOnChestsHandler {
@SubscribeEvent
public void changeSittingTaskForOcelots(LivingEvent.LivingUpdateEvent evt)
{
if (evt.entityLiving.ticksExisted < 5 && evt.entityLiving instanceof EntityOcelot)
{
EntityOcelot ocelot = (EntityOcelot) evt.entityLiving;
@SuppressWarnings("unchecked")
List<EntityAITasks.EntityAITaskEntry> tasks = ocelot.tasks.taskEntries;
for (int i = 0; i < tasks.size(); i++)
{
EntityAITasks.EntityAITaskEntry task = tasks.get(i);
if (task.priority == 6 && (task.action instanceof EntityAIOcelotSit) && !(task.action instanceof IronChestAIOcelotSit))
{
task.action = new IronChestAIOcelotSit(ocelot, 0.4F);
}
}
}
}
}

View File

@ -1,22 +1,15 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
import java.util.EnumMap; import java.util.EnumMap;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.network.FMLEmbeddedChannel; import cpw.mods.fml.common.network.FMLEmbeddedChannel;
import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec;
@ -28,7 +21,6 @@ import cpw.mods.fml.relauncher.SideOnly;
/** /**
* Handles the packet wrangling for IronChest * Handles the packet wrangling for IronChest
* @author cpw * @author cpw
*
*/ */
public enum PacketHandler { public enum PacketHandler {
INSTANCE; INSTANCE;
@ -79,7 +71,7 @@ public enum PacketHandler {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, IronChestMessage msg) throws Exception protected void channelRead0(ChannelHandlerContext ctx, IronChestMessage msg) throws Exception
{ {
World world = IronChest.proxy.getClientWorld(); World world = FMLClientHandler.instance().getClient().theWorld;
TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z); TileEntity te = world.getTileEntity(msg.x, msg.y, msg.z);
if (te instanceof TileEntityIronChest) if (te instanceof TileEntityIronChest)
{ {

View File

@ -1,19 +1,7 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
public class TileEntityCopperChest extends TileEntityIronChest { public class TileEntityCopperChest extends TileEntityIronChest {
public TileEntityCopperChest() public TileEntityCopperChest() {
{ super(IronChestType.COPPER);
super(IronChestType.COPPER); }
}
} }

View File

@ -1,18 +1,7 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
public class TileEntityCrystalChest extends TileEntityIronChest { public class TileEntityCrystalChest extends TileEntityIronChest {
public TileEntityCrystalChest() public TileEntityCrystalChest() {
{ super(IronChestType.CRYSTAL);
super(IronChestType.CRYSTAL); }
}
} }

View File

@ -1,18 +1,7 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
public class TileEntityDiamondChest extends TileEntityIronChest { public class TileEntityDiamondChest extends TileEntityIronChest {
public TileEntityDiamondChest() public TileEntityDiamondChest() {
{ super(IronChestType.DIAMOND);
super(IronChestType.DIAMOND); }
}
} }

View File

@ -20,8 +20,9 @@ public class TileEntityDirtChest extends TileEntityIronChest {
pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page5"))); pages.appendTag(new NBTTagString(StatCollector.translateToLocal("book.ironchest:dirtchest9000.page5")));
dirtChest9000GuideBook.setTagInfo("pages", pages); dirtChest9000GuideBook.setTagInfo("pages", pages);
} }
public TileEntityDirtChest() { public TileEntityDirtChest() {
super(IronChestType.DIRTCHEST9000); super(IronChestType.DIRTCHEST9000);
} }
@Override @Override

View File

@ -1,19 +1,7 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
public class TileEntityGoldChest extends TileEntityIronChest { public class TileEntityGoldChest extends TileEntityIronChest {
public TileEntityGoldChest() {
public TileEntityGoldChest() super(IronChestType.GOLD);
{ }
super(IronChestType.GOLD);
}
} }

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import java.util.Arrays; import java.util.Arrays;
@ -383,11 +373,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
public TileEntityIronChest applyUpgradeItem(ItemChestChanger itemChestChanger) public TileEntityIronChest applyUpgradeItem(ItemChestChanger itemChestChanger)
{ {
if (numUsingPlayers > 0) if (numUsingPlayers > 0 || !itemChestChanger.getType().canUpgrade(this.getType()))
{
return null;
}
if (!itemChestChanger.getType().canUpgrade(this.getType()))
{ {
return null; return null;
} }
@ -395,7 +381,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
int newSize = newEntity.chestContents.length; int newSize = newEntity.chestContents.length;
System.arraycopy(chestContents, 0, newEntity.chestContents, 0, Math.min(newSize, chestContents.length)); System.arraycopy(chestContents, 0, newEntity.chestContents, 0, Math.min(newSize, chestContents.length));
BlockIronChest block = IronChest.ironChestBlock; BlockIronChest block = IronChest.ironChestBlock;
block.dropContent(newSize, this, this.worldObj, this.xCoord, this.yCoord, this.zCoord); block.dropItems(newSize, this, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
newEntity.setFacing(facing); newEntity.setFacing(facing);
newEntity.sortTopStacks(); newEntity.sortTopStacks();
newEntity.ticksSinceSync = -1; newEntity.ticksSinceSync = -1;
@ -498,11 +484,6 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
} }
} }
public void setMaxStackSize(int size)
{
}
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) public boolean isItemValidForSlot(int i, ItemStack itemstack)
{ {
@ -527,6 +508,5 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
public void removeAdornments() public void removeAdornments()
{ {
} }
} }

View File

@ -1,9 +1,7 @@
package cpw.mods.ironchest; package cpw.mods.ironchest;
public class TileEntityObsidianChest extends TileEntityIronChest { public class TileEntityObsidianChest extends TileEntityIronChest {
public TileEntityObsidianChest() {
public TileEntityObsidianChest() super(IronChestType.OBSIDIAN);
{ }
super(IronChestType.OBSIDIAN);
}
} }

View File

@ -1,18 +1,7 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
public class TileEntitySilverChest extends TileEntityIronChest { public class TileEntitySilverChest extends TileEntityIronChest {
public TileEntitySilverChest() public TileEntitySilverChest() {
{ super(IronChestType.SILVER);
super(IronChestType.SILVER); }
}
} }

View File

@ -1,21 +0,0 @@
package cpw.mods.ironchest;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ValidatingSlot extends Slot {
private IronChestType type;
public ValidatingSlot(IInventory par1iInventory, int par2, int par3, int par4, IronChestType type)
{
super(par1iInventory, par2, par3, par4);
this.type = type;
}
@Override
public boolean isItemValid(ItemStack par1ItemStack)
{
return type.acceptsStack(par1ItemStack);
}
}

View File

@ -1,20 +1,9 @@
/*******************************************************************************
* Copyright (c) 2012 cpw. All rights reserved. This program and the accompanying materials are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at http://www.gnu.org/licenses/gpl.html
*
* Contributors: cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest; package cpw.mods.ironchest;
import java.util.Properties; import java.util.Properties;
public class Version { public class Version {
private static String major; private static String major, minor, rev, build, mcversion;
private static String minor;
private static String rev;
private static String build;
@SuppressWarnings("unused")
private static String mcversion;
static void init(Properties properties) static void init(Properties properties)
{ {

View File

@ -1,55 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest.client;
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.ironchest.CommonProxy;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest;
public class ClientProxy extends CommonProxy {
@Override
public void registerRenderInformation()
{
TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
}
@Override
public void registerTileEntitySpecialRenderer(IronChestType typ)
{
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
}
@Override
public World getClientWorld()
{
return FMLClientHandler.instance().getClient().theWorld;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityIronChest)
{
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
}
else
{
return null;
}
}
}

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest.client; package cpw.mods.ironchest.client;
import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.gui.inventory.GuiContainer;
@ -23,15 +13,15 @@ import cpw.mods.ironchest.TileEntityIronChest;
public class GUIChest extends GuiContainer { public class GUIChest extends GuiContainer {
public enum ResourceList { public enum ResourceList {
IRON(new ResourceLocation("ironchest", "textures/gui/ironcontainer.png")), IRON(new ResourceLocation("ironchest", "textures/gui/gui_chest_iron.png")),
COPPER(new ResourceLocation("ironchest", "textures/gui/coppercontainer.png")), COPPER(new ResourceLocation("ironchest", "textures/gui/gui_chest_copper.png")),
SILVER(new ResourceLocation("ironchest", "textures/gui/silvercontainer.png")), SILVER(new ResourceLocation("ironchest", "textures/gui/gui_chest_silver.png")),
GOLD(new ResourceLocation("ironchest", "textures/gui/goldcontainer.png")), GOLD(new ResourceLocation("ironchest", "textures/gui/gui_chest_gold.png")),
DIAMOND(new ResourceLocation("ironchest", "textures/gui/diamondcontainer.png")), DIAMOND(new ResourceLocation("ironchest", "textures/gui/gui_chest_diamond.png")),
DIRT(new ResourceLocation("ironchest", "textures/gui/dirtcontainer.png")); DIRT(new ResourceLocation("ironchest", "textures/gui/gui_chest_dirt.png"));
public final ResourceLocation location; public final ResourceLocation location;
private ResourceList(ResourceLocation loc) { private ResourceList(ResourceLocation loc) {
this.location = loc; location = loc;
} }
} }
public enum GUI { public enum GUI {
@ -89,8 +79,7 @@ public class GUIChest extends GuiContainer {
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) protected void drawGuiContainerBackgroundLayer(float f, int i, int j)
{ {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
// new "bind tex" mc.getTextureManager().bindTexture(type.guiResourceList.location);
this.mc.getTextureManager().bindTexture(type.guiResourceList.location);
int x = (width - xSize) / 2; int x = (width - xSize) / 2;
int y = (height - ySize) / 2; int y = (height - ySize) / 2;
drawTexturedModalRect(x, y, 0, 0, xSize, ySize); drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest.client; package cpw.mods.ironchest.client;
import java.util.Map; import java.util.Map;

View File

@ -1,13 +1,3 @@
/*******************************************************************************
* Copyright (c) 2012 cpw.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* cpw - initial API and implementation
******************************************************************************/
package cpw.mods.ironchest.client; package cpw.mods.ironchest.client;
import static org.lwjgl.opengl.GL11.glColor4f; import static org.lwjgl.opengl.GL11.glColor4f;
@ -18,11 +8,11 @@ import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glRotatef; import static org.lwjgl.opengl.GL11.glRotatef;
import static org.lwjgl.opengl.GL11.glScalef; import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef; import static org.lwjgl.opengl.GL11.glTranslatef;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import net.minecraft.client.model.ModelChest; import net.minecraft.client.model.ModelChest;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -30,30 +20,24 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.primitives.SignedBytes; import com.google.common.primitives.SignedBytes;
import cpw.mods.ironchest.IronChestType; import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.MappableItemStackWrapper;
import cpw.mods.ironchest.TileEntityIronChest; import cpw.mods.ironchest.TileEntityIronChest;
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer { public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
@SuppressWarnings("unused")
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
private static Map<IronChestType, ResourceLocation> locations; private static Map<IronChestType, ResourceLocation> locations;
static { static {
Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder(); Builder<IronChestType, ResourceLocation> builder = ImmutableMap.<IronChestType,ResourceLocation>builder();
for (IronChestType typ : IronChestType.values()) { for (IronChestType typ : IronChestType.values())
builder.put(typ, new ResourceLocation("ironchest","textures/model/"+typ.getModelTexture())); builder.put(typ, new ResourceLocation("ironchest", "textures/models/" + typ.getModelTexture()));
}
locations = builder.build(); locations = builder.build();
} }
private Random random; private Random random;
@SuppressWarnings("unused")
private RenderBlocks renderBlocks;
private RenderItem itemRenderer; private RenderItem itemRenderer;
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F },
@ -63,7 +47,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
{ {
model = new ModelChest(); model = new ModelChest();
random = new Random(); random = new Random();
renderBlocks = new RenderBlocks();
itemRenderer = new RenderItem() { itemRenderer = new RenderItem() {
@Override @Override
public byte getMiniBlockCount(ItemStack stack, byte original) { public byte getMiniBlockCount(ItemStack stack, byte original) {

View File

@ -0,0 +1,43 @@
package cpw.mods.ironchest.net;
import net.minecraft.client.renderer.tileentity.TileEntityRendererChestHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.ironchest.ContainerIronChest;
import cpw.mods.ironchest.IronChestType;
import cpw.mods.ironchest.TileEntityIronChest;
import cpw.mods.ironchest.client.GUIChest;
import cpw.mods.ironchest.client.IronChestRenderHelper;
import cpw.mods.ironchest.client.TileEntityIronChestRenderer;
public class UniversalProxy implements IGuiHandler {
public void registerRenderInformation() {
TileEntityRendererChestHelper.instance = new IronChestRenderHelper();
}
public void registerTileEntitySpecialRenderer(IronChestType typ) {
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityIronChest) {
TileEntityIronChest chest = (TileEntityIronChest) te;
return new ContainerIronChest(player.inventory, chest, chest.getType(), 0, 0);
} else
return null;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof TileEntityIronChest)
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
else
return null;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 661 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 382 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 719 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 593 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 604 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 625 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 B

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 466 B

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 480 B

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 B

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 617 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

Some files were not shown because too many files have changed in this diff Show More