Update to forge 4.0
This commit is contained in:
parent
b9c4ecbbec
commit
49ebd84b8f
|
@ -10,75 +10,41 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest.client;
|
package cpw.mods.ironchest.client;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.src.ChestItemRenderHelper;
|
import net.minecraft.src.ChestItemRenderHelper;
|
||||||
import net.minecraft.src.EntityItem;
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.ModLoader;
|
import net.minecraft.src.ModLoader;
|
||||||
import net.minecraft.src.NBTTagCompound;
|
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import cpw.mods.ironchest.ChestChangerType;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.ironchest.IProxy;
|
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||||
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import cpw.mods.ironchest.ContainerIronChestBase;
|
||||||
|
import cpw.mods.ironchest.CommonProxy;
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class ClientProxy implements IProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
@Override
|
@Override
|
||||||
public void registerRenderInformation() {
|
public void registerRenderInformation() {
|
||||||
ChestItemRenderHelper.instance = new IronChestRenderHelper();
|
ChestItemRenderHelper.instance = new IronChestRenderHelper();
|
||||||
MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/block_textures.png");
|
MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/block_textures.png");
|
||||||
MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/item_textures.png");
|
MinecraftForgeClient.preloadTexture("/cpw/mods/ironchest/sprites/item_textures.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerTileEntities() {
|
public boolean isRemote() {
|
||||||
for (IronChestType typ : IronChestType.values()) {
|
return ModLoader.getMinecraftInstance().theWorld.isRemote;
|
||||||
ModLoader.registerTileEntity(typ.clazz, typ.name(), new TileEntityIronChestRenderer());
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerTranslations() {
|
public void registerTileEntitySpecialRenderer(IronChestType typ) {
|
||||||
for (IronChestType typ : IronChestType.values()) {
|
ClientRegistry.bindTileEntitySpecialRenderer(typ.clazz, new TileEntityIronChestRenderer());
|
||||||
ModLoader.addLocalization(typ.name() + ".name", typ.friendlyName);
|
}
|
||||||
}
|
|
||||||
for (ChestChangerType typ : ChestChangerType.values()) {
|
|
||||||
ModLoader.addLocalization("item." + typ.itemName + ".name", typ.descriptiveName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getMinecraftDir() {
|
public World getClientWorld() {
|
||||||
return Minecraft.getMinecraftDir();
|
return FMLClientHandler.instance().getClient().theWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyExtraDataToDrops(EntityItem entityitem, NBTTagCompound data) {
|
|
||||||
entityitem.item.setTagCompound(data);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRemote() {
|
|
||||||
return ModLoader.getMinecraftInstance().theWorld.isRemote;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public World getCurrentWorld() {
|
|
||||||
return ModLoader.getMinecraftInstance().theWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
||||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
|
||||||
if (te != null && te instanceof TileEntityIronChest) {
|
|
||||||
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest.client;
|
package cpw.mods.ironchest.client;
|
||||||
|
|
||||||
import cpw.mods.ironchest.mod_IronChest;
|
import cpw.mods.ironchest.IronChest;
|
||||||
import net.minecraft.src.Block;
|
import net.minecraft.src.Block;
|
||||||
import net.minecraft.src.ChestItemRenderHelper;
|
import net.minecraft.src.ChestItemRenderHelper;
|
||||||
import net.minecraft.src.TileEntityRenderer;
|
import net.minecraft.src.TileEntityRenderer;
|
||||||
|
@ -18,8 +18,8 @@ import net.minecraft.src.TileEntityRenderer;
|
||||||
public class IronChestRenderHelper extends ChestItemRenderHelper {
|
public class IronChestRenderHelper extends ChestItemRenderHelper {
|
||||||
@Override
|
@Override
|
||||||
public void renderChest(Block block, int i, float f) {
|
public void renderChest(Block block, int i, float f) {
|
||||||
if (block==mod_IronChest.ironChestBlock) {
|
if (block==IronChest.ironChestBlock) {
|
||||||
TileEntityRenderer.instance.renderTileEntityAt(block.getTileEntity(i), 0.0D, 0.0D, 0.0D, 0.0F);
|
TileEntityRenderer.instance.renderTileEntityAt(block.createTileEntity(null,i), 0.0D, 0.0D, 0.0D, 0.0F);
|
||||||
} else {
|
} else {
|
||||||
super.renderChest(block, i, f);
|
super.renderChest(block, i, f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,13 +37,13 @@ import net.minecraft.src.RenderBlocks;
|
||||||
import net.minecraft.src.Tessellator;
|
import net.minecraft.src.Tessellator;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.TileEntitySpecialRenderer;
|
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.src.forge.ForgeHooksClient;
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraft.src.forge.IItemRenderer;
|
import net.minecraftforge.client.IItemRenderer;
|
||||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
import cpw.mods.ironchest.IronChestType;
|
import cpw.mods.ironchest.IronChestType;
|
||||||
import cpw.mods.ironchest.MappableItemStackWrapper;
|
import cpw.mods.ironchest.MappableItemStackWrapper;
|
||||||
import cpw.mods.ironchest.TileEntityIronChest;
|
import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
import cpw.mods.ironchest.mod_IronChest;
|
import cpw.mods.ironchest.IronChest;
|
||||||
|
|
||||||
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
|
private static Map<MappableItemStackWrapper, Integer> renderList = new HashMap<MappableItemStackWrapper, Integer>();
|
||||||
|
@ -76,10 +76,10 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
}
|
}
|
||||||
int facing = 3;
|
int facing = 3;
|
||||||
IronChestType type = tile.getType();
|
IronChestType type = tile.getType();
|
||||||
if (tile != null && tile.worldObj != null) {
|
if (tile != null && tile.func_70314_l() != null) {
|
||||||
facing = tile.getFacing();
|
facing = tile.getFacing();
|
||||||
type = tile.getType();
|
type = tile.getType();
|
||||||
int typ = tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
int typ = tile.func_70314_l().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||||
type = IronChestType.values()[typ];
|
type = IronChestType.values()[typ];
|
||||||
}
|
}
|
||||||
bindTextureByName(type.getModelTexture());
|
bindTextureByName(type.getModelTexture());
|
||||||
|
@ -154,7 +154,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(shiftX, shiftY, shiftZ);
|
glTranslatef(shiftX, shiftY, shiftZ);
|
||||||
glScalef(localScale, localScale, localScale);
|
glScalef(localScale, localScale, localScale);
|
||||||
for (int miniBlocks = 0; miniBlocks < (item.stackSize / 32) + 1; miniBlocks++) {
|
/* for (int miniBlocks = 0; miniBlocks < (item.stackSize / 32) + 1; miniBlocks++) {
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
glRotatef(timeD, 0.0F, 1.0F, 0.0F);
|
||||||
if (miniBlocks > 0) {
|
if (miniBlocks > 0) {
|
||||||
|
@ -164,8 +164,8 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
glTranslatef(minishiftX, minishiftY, minishiftZ);
|
glTranslatef(minishiftX, minishiftY, minishiftZ);
|
||||||
}
|
}
|
||||||
MappableItemStackWrapper mis = new MappableItemStackWrapper(item);
|
MappableItemStackWrapper mis = new MappableItemStackWrapper(item);
|
||||||
if (!mod_IronChest.CACHE_RENDER || !renderList.containsKey(mis)) { // Added support for using only old system.
|
if (!IronChest.CACHE_RENDER || !renderList.containsKey(mis)) { // Added support for using only old system.
|
||||||
if (mod_IronChest.CACHE_RENDER) {
|
if (IronChest.CACHE_RENDER) {
|
||||||
int render = glGenLists(1);
|
int render = glGenLists(1);
|
||||||
renderList.put(mis, render);
|
renderList.put(mis, render);
|
||||||
glNewList(render, GL_COMPILE_AND_EXECUTE);
|
glNewList(render, GL_COMPILE_AND_EXECUTE);
|
||||||
|
@ -213,7 +213,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
|
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
if (mod_IronChest.CACHE_RENDER) {
|
if (IronChest.CACHE_RENDER) {
|
||||||
glEndList();
|
glEndList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -224,7 +224,7 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
*/ glPopMatrix();
|
||||||
}
|
}
|
||||||
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||||
glEnable(2896 /* GL_LIGHTING */);
|
glEnable(2896 /* GL_LIGHTING */);
|
||||||
|
|
|
@ -25,9 +25,9 @@ import net.minecraft.src.MathHelper;
|
||||||
import net.minecraft.src.NBTTagCompound;
|
import net.minecraft.src.NBTTagCompound;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
import net.minecraft.src.forge.ITextureProvider;
|
import net.minecraftforge.common.Orientation;
|
||||||
|
|
||||||
public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
public class BlockIronChest extends BlockContainer {
|
||||||
|
|
||||||
private Random random;
|
private Random random;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity getBlockEntity() {
|
public TileEntity createNewTileEntity(World w) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity getBlockEntity(int metadata) {
|
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||||
return IronChestType.makeEntity(metadata);
|
return IronChestType.makeEntity(metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer player) {
|
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int i1, float f1, float f2, float f3) {
|
||||||
TileEntity te = world.getBlockTileEntity(i, j, k);
|
TileEntity te = world.getBlockTileEntity(i, j, k);
|
||||||
|
|
||||||
if (te == null || !(te instanceof TileEntityIronChest))
|
if (te == null || !(te instanceof TileEntityIronChest))
|
||||||
|
@ -113,7 +113,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.isBlockSolidOnSide(i, j + 1, k, 0))
|
if (world.isBlockSolidOnSide(i, j + 1, k, Orientation.DOWN))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.openGui(mod_IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k);
|
player.openGui(IronChest.instance, ((TileEntityIronChest) te).getType().ordinal(), world, i, j, k);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,14 +160,15 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockRemoval(World world, int i, int j, int k)
|
@Override
|
||||||
|
public void breakBlock(World world, int i, int j, int k, int i1, int i2)
|
||||||
{
|
{
|
||||||
TileEntityIronChest tileentitychest = (TileEntityIronChest) world.getBlockTileEntity(i, j, k);
|
TileEntityIronChest tileentitychest = (TileEntityIronChest) world.getBlockTileEntity(i, j, k);
|
||||||
if (tileentitychest != null)
|
if (tileentitychest != null)
|
||||||
{
|
{
|
||||||
dropContent(0, tileentitychest, world, tileentitychest.xCoord, tileentitychest.yCoord, tileentitychest.zCoord);
|
dropContent(0, tileentitychest, world, tileentitychest.xCoord, tileentitychest.yCoord, tileentitychest.zCoord);
|
||||||
}
|
}
|
||||||
super.onBlockRemoval(world, i, j, k);
|
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 dropContent(int newSize, IInventory chest, World world, int xCoord, int yCoord, int zCoord) {
|
||||||
|
@ -197,7 +198,7 @@ public class BlockIronChest extends BlockContainer implements ITextureProvider {
|
||||||
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
entityitem.motionZ = (float) random.nextGaussian() * f3;
|
||||||
if (itemstack.hasTagCompound())
|
if (itemstack.hasTagCompound())
|
||||||
{
|
{
|
||||||
mod_IronChest.proxy.applyExtraDataToDrops(entityitem, (NBTTagCompound) itemstack.getTagCompound().copy());
|
entityitem.item.setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
|
||||||
}
|
}
|
||||||
world.spawnEntityInWorld(entityitem);
|
world.spawnEntityInWorld(entityitem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import static cpw.mods.ironchest.IronChestType.WOOD;
|
||||||
|
|
||||||
import net.minecraft.src.Block;
|
import net.minecraft.src.Block;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.forge.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
|
|
||||||
public enum ChestChangerType {
|
public enum ChestChangerType {
|
||||||
IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"),
|
IRONGOLD(IRON, GOLD, "ironGoldUpgrade", "Iron to Gold Chest Upgrade", "mmm", "msm", "mmm"),
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.World;
|
||||||
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import cpw.mods.ironchest.client.GUIChest;
|
||||||
|
|
||||||
|
|
||||||
|
public class CommonProxy implements IGuiHandler {
|
||||||
|
public void registerRenderInformation()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemote()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerTileEntitySpecialRenderer(IronChestType typ)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||||
|
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||||
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
|
return GUIChest.GUI.buildGUI(IronChestType.values()[ID], player.inventory, (TileEntityIronChest) te);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) {
|
||||||
|
TileEntity te = world.getBlockTileEntity(X, Y, Z);
|
||||||
|
if (te != null && te instanceof TileEntityIronChest) {
|
||||||
|
TileEntityIronChest icte = (TileEntityIronChest) te;
|
||||||
|
return new ContainerIronChestBase(player.inventory, icte, icte.getType(), 0, 0);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getClientWorld() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -75,7 +75,7 @@ public class ContainerIronChestBase extends Container {
|
||||||
{
|
{
|
||||||
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
|
for (int chestCol = 0; chestCol < type.getRowLength(); chestCol++)
|
||||||
{
|
{
|
||||||
addSlot(new Slot(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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -85,21 +85,17 @@ public class ContainerIronChestBase extends Container {
|
||||||
{
|
{
|
||||||
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
|
for (int playerInvCol = 0; playerInvCol < 9; playerInvCol++)
|
||||||
{
|
{
|
||||||
addSlot(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
|
addSlotToContainer(new Slot(playerInventory, playerInvCol + playerInvRow * 9 + 9, leftCol + playerInvCol * 18, ySize - (4 - playerInvRow) * 18 - 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++)
|
for (int hotbarSlot = 0; hotbarSlot < 9; hotbarSlot++)
|
||||||
{
|
{
|
||||||
addSlot(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24));
|
addSlotToContainer(new Slot(playerInventory, hotbarSlot, leftCol + hotbarSlot * 18, ySize - 24));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public EntityPlayer getPlayer() {
|
public EntityPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInventory getInventory() {
|
|
||||||
return chest;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +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 java.io.File;
|
|
||||||
|
|
||||||
import net.minecraft.src.EntityItem;
|
|
||||||
import net.minecraft.src.NBTTagCompound;
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
import net.minecraft.src.forge.IGuiHandler;
|
|
||||||
|
|
||||||
public interface IProxy extends IGuiHandler {
|
|
||||||
|
|
||||||
public abstract void registerRenderInformation();
|
|
||||||
|
|
||||||
public abstract void registerTileEntities();
|
|
||||||
|
|
||||||
public abstract void registerTranslations();
|
|
||||||
|
|
||||||
public abstract File getMinecraftDir();
|
|
||||||
|
|
||||||
public abstract void applyExtraDataToDrops(EntityItem item, NBTTagCompound data);
|
|
||||||
|
|
||||||
public abstract boolean isRemote();
|
|
||||||
|
|
||||||
public abstract World getCurrentWorld();
|
|
||||||
}
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 java.lang.reflect.Method;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.Configuration;
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.Mod.Init;
|
||||||
|
import cpw.mods.fml.common.Mod.Instance;
|
||||||
|
import cpw.mods.fml.common.Mod.PostInit;
|
||||||
|
import cpw.mods.fml.common.Mod.PreInit;
|
||||||
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
|
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.network.NetworkMod;
|
||||||
|
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
|
||||||
|
@Mod(modid = "IronChest", name = "Iron Chests", version = "4.0")
|
||||||
|
@NetworkMod(channels = { "IronChest" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
|
||||||
|
public class IronChest {
|
||||||
|
|
||||||
|
public static BlockIronChest ironChestBlock;
|
||||||
|
@SidedProxy(clientSide = "cpw.mods.ironchest.client.ClientProxy", serverSide = "cpw.mods.ironchest.common.CommonProxy")
|
||||||
|
public static CommonProxy proxy;
|
||||||
|
@Instance
|
||||||
|
public static IronChest instance;
|
||||||
|
public static boolean CACHE_RENDER = true;
|
||||||
|
public static boolean OCELOTS_SITONCHESTS = true;
|
||||||
|
|
||||||
|
@PreInit
|
||||||
|
public void preInit(FMLPreInitializationEvent event) {
|
||||||
|
Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
|
event.getModMetadata().version = Version.fullVersionString();
|
||||||
|
try {
|
||||||
|
cfg.load();
|
||||||
|
int bId = cfg.getOrCreateBlockIdProperty("ironChests", 181).getInt(181);
|
||||||
|
ironChestBlock = new BlockIronChest(bId);
|
||||||
|
ChestChangerType.buildItems(cfg, 29501);
|
||||||
|
CACHE_RENDER = cfg.getOrCreateBooleanProperty("cacheRenderingInformation", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
||||||
|
OCELOTS_SITONCHESTS = cfg.getOrCreateBooleanProperty("ocelotsSitOnChests", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
FMLLog.log(Level.SEVERE, e, "IronChest has a problem loading it's configuration");
|
||||||
|
} finally {
|
||||||
|
cfg.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Init
|
||||||
|
public void load(FMLInitializationEvent evt) {
|
||||||
|
GameRegistry.registerBlock(ironChestBlock);
|
||||||
|
for (IronChestType typ : IronChestType.values()) {
|
||||||
|
GameRegistry.registerTileEntity(typ.clazz, typ.name());
|
||||||
|
LanguageRegistry.instance().addStringLocalization(typ.name() + ".name", "en_US", typ.friendlyName);
|
||||||
|
proxy.registerTileEntitySpecialRenderer(typ);
|
||||||
|
}
|
||||||
|
for (ChestChangerType typ : ChestChangerType.values()) {
|
||||||
|
LanguageRegistry.instance().addStringLocalization("item." + typ.itemName + ".name", "en_US", typ.descriptiveName);
|
||||||
|
}
|
||||||
|
IronChestType.generateTieredRecipes(ironChestBlock);
|
||||||
|
ChestChangerType.generateRecipes();
|
||||||
|
NetworkRegistry.instance().registerGuiHandler(instance, proxy);
|
||||||
|
proxy.registerRenderInformation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostInit
|
||||||
|
public void modsLoaded(FMLPostInitializationEvent evt) {
|
||||||
|
try {
|
||||||
|
Class<?> equivexmaps = Class.forName("ee.EEMaps");
|
||||||
|
Method addEMC = equivexmaps.getMethod("addEMC", int.class, int.class, int.class);
|
||||||
|
Method addMeta = equivexmaps.getMethod("addMeta", int.class, int.class);
|
||||||
|
int[] chestEMCValues = new int[] { 8 * 8 + 256 * 8, /* iron chest */
|
||||||
|
8 * 8 + 256 * 8 + 2048 * 8, /* gold chest */
|
||||||
|
2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6, /* diamond chest */
|
||||||
|
85 * 8 + 8 * 8, /* copper chest */
|
||||||
|
85 * 8 + 8 * 8 + 512 * 8, /* silver chest */
|
||||||
|
2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6 + 8 /* crystal chest */
|
||||||
|
};
|
||||||
|
for (IronChestType icType : IronChestType.values()) {
|
||||||
|
if (icType.ordinal() >= chestEMCValues.length)
|
||||||
|
break;
|
||||||
|
addEMC.invoke(null, ironChestBlock.blockID, icType.ordinal(), chestEMCValues[icType.ordinal()]);
|
||||||
|
}
|
||||||
|
addMeta.invoke(null, ironChestBlock.blockID, IronChestType.values().length - 1);
|
||||||
|
FMLLog.fine("mod_IronChest registered chests with Equivalent Exchange");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
FMLLog.fine("mod_IronChest unable to load Equivalent Exchange integration");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -126,7 +126,7 @@ public class IronChestAIOcelotSit extends EntityAIBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBlockAChestBlock(World world, int x, int y, int z) {
|
private boolean isBlockAChestBlock(World world, int x, int y, int z) {
|
||||||
if (world.getBlockId(x, y, z)==mod_IronChest.ironChestBlock.blockID) {
|
if (world.getBlockId(x, y, z)==IronChest.ironChestBlock.blockID) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -18,7 +18,7 @@ import net.minecraft.src.Block;
|
||||||
import net.minecraft.src.CraftingManager;
|
import net.minecraft.src.CraftingManager;
|
||||||
import net.minecraft.src.Item;
|
import net.minecraft.src.Item;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.forge.oredict.ShapedOreRecipe;
|
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||||
|
|
||||||
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", "ironchest.png", 0, Arrays.asList("ingotIron","ingotRefinedIron"), TileEntityIronChest.class, "mmmmPmmmm", "mGmG3GmGm"),
|
||||||
|
|
|
@ -10,16 +10,15 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest;
|
package cpw.mods.ironchest;
|
||||||
|
|
||||||
import cpw.mods.fml.common.ReflectionHelper;
|
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.Item;
|
import net.minecraft.src.Item;
|
||||||
import net.minecraft.src.ItemStack;
|
import net.minecraft.src.ItemStack;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.TileEntityChest;
|
import net.minecraft.src.TileEntityChest;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
import net.minecraft.src.forge.ITextureProvider;
|
|
||||||
|
|
||||||
public class ItemChestChanger extends Item implements ITextureProvider {
|
public class ItemChestChanger extends Item {
|
||||||
|
|
||||||
private ChestChangerType type;
|
private ChestChangerType type;
|
||||||
|
|
||||||
|
@ -52,9 +51,9 @@ public class ItemChestChanger extends Item implements ITextureProvider {
|
||||||
// Force old TE out of the world so that adjacent chests can update
|
// Force old TE out of the world so that adjacent chests can update
|
||||||
newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal()));
|
newchest = IronChestType.makeEntity(getTargetChestOrdinal(IronChestType.WOOD.ordinal()));
|
||||||
int newSize = newchest.chestContents.length;
|
int newSize = newchest.chestContents.length;
|
||||||
ItemStack[] chestContents = ReflectionHelper.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 = mod_IronChest.ironChestBlock;
|
BlockIronChest block = IronChest.ironChestBlock;
|
||||||
block.dropContent(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord);
|
block.dropContent(newSize, tec, world, tec.xCoord, tec.yCoord, tec.zCoord);
|
||||||
newchest.setFacing((byte)tec.getBlockMetadata());
|
newchest.setFacing((byte)tec.getBlockMetadata());
|
||||||
newchest.sortTopStacks();
|
newchest.sortTopStacks();
|
||||||
|
|
|
@ -31,8 +31,4 @@ public class ItemIronChest extends ItemBlock {
|
||||||
public String getItemNameIS(ItemStack itemstack) {
|
public String getItemNameIS(ItemStack itemstack) {
|
||||||
return IronChestType.values()[itemstack.getItemDamage()].name();
|
return IronChestType.values()[itemstack.getItemDamage()].name();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addCreativeItems(@SuppressWarnings("rawtypes") ArrayList itemList) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,91 +16,71 @@ import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.network.IPacketHandler;
|
||||||
|
import cpw.mods.fml.common.network.Player;
|
||||||
|
|
||||||
import net.minecraft.src.NetworkManager;
|
import net.minecraft.src.NetworkManager;
|
||||||
import net.minecraft.src.Packet;
|
import net.minecraft.src.Packet;
|
||||||
import net.minecraft.src.Packet1Login;
|
import net.minecraft.src.Packet1Login;
|
||||||
import net.minecraft.src.Packet250CustomPayload;
|
import net.minecraft.src.Packet250CustomPayload;
|
||||||
import net.minecraft.src.TileEntity;
|
import net.minecraft.src.TileEntity;
|
||||||
import net.minecraft.src.World;
|
import net.minecraft.src.World;
|
||||||
import net.minecraft.src.forge.IConnectionHandler;
|
|
||||||
import net.minecraft.src.forge.IPacketHandler;
|
|
||||||
import net.minecraft.src.forge.MessageManager;
|
|
||||||
|
|
||||||
public class PacketHandler implements IPacketHandler, IConnectionHandler {
|
public class PacketHandler implements IPacketHandler {
|
||||||
@Override
|
@Override
|
||||||
public void onConnect(NetworkManager network) {
|
public void onPacketData(NetworkManager network, Packet250CustomPayload packet, Player player) {
|
||||||
MessageManager.getInstance().registerChannel(network, this, "IronChest");
|
ByteArrayDataInput dat = ByteStreams.newDataInput(packet.data);
|
||||||
}
|
int x = dat.readInt();
|
||||||
|
int y = dat.readInt();
|
||||||
@Override
|
int z = dat.readInt();
|
||||||
public void onLogin(NetworkManager network, Packet1Login login) {
|
byte typ = dat.readByte();
|
||||||
}
|
boolean hasStacks = dat.readByte() != 0;
|
||||||
|
int[] items = new int[0];
|
||||||
@Override
|
if (hasStacks) {
|
||||||
public void onDisconnect(NetworkManager network, String message, Object[] args) {
|
items = new int[24];
|
||||||
MessageManager.getInstance().removeConnection(network);
|
for (int i = 0; i < items.length; i++) {
|
||||||
}
|
items[i] = dat.readInt();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPacketData(NetworkManager network, String channel, byte[] data) {
|
|
||||||
DataInputStream dis=new DataInputStream(new ByteArrayInputStream(data));
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int z;
|
|
||||||
int typ;
|
|
||||||
boolean hasStacks;
|
|
||||||
int[] items=null;
|
|
||||||
try {
|
|
||||||
x = dis.readInt();
|
|
||||||
y = dis.readInt();
|
|
||||||
z = dis.readInt();
|
|
||||||
typ=dis.readByte();
|
|
||||||
hasStacks=dis.readByte()!=0;
|
|
||||||
if (hasStacks) {
|
|
||||||
items = new int[24];
|
|
||||||
for (int i=0; i<items.length; i++) {
|
|
||||||
items[i]=dis.readInt();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
World world=mod_IronChest.proxy.getCurrentWorld();
|
World world = IronChest.proxy.getClientWorld();
|
||||||
TileEntity te=world.getBlockTileEntity(x, y, z);
|
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||||
if (te instanceof TileEntityIronChest) {
|
if (te instanceof TileEntityIronChest) {
|
||||||
TileEntityIronChest icte = (TileEntityIronChest)te;
|
TileEntityIronChest icte = (TileEntityIronChest) te;
|
||||||
icte.handlePacketData(typ, items);
|
icte.handlePacketData(typ, items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getPacket(TileEntityIronChest tileEntityIronChest) {
|
public static Packet getPacket(TileEntityIronChest tileEntityIronChest) {
|
||||||
ByteArrayOutputStream bos=new ByteArrayOutputStream(140);
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
|
||||||
DataOutputStream dos=new DataOutputStream(bos);
|
DataOutputStream dos = new DataOutputStream(bos);
|
||||||
int x=tileEntityIronChest.xCoord;
|
int x = tileEntityIronChest.xCoord;
|
||||||
int y=tileEntityIronChest.yCoord;
|
int y = tileEntityIronChest.yCoord;
|
||||||
int z=tileEntityIronChest.zCoord;
|
int z = tileEntityIronChest.zCoord;
|
||||||
int typ=tileEntityIronChest.getType().ordinal();
|
int typ = tileEntityIronChest.getType().ordinal();
|
||||||
int[] items=tileEntityIronChest.buildIntDataList();
|
int[] items = tileEntityIronChest.buildIntDataList();
|
||||||
boolean hasStacks=(items!=null);
|
boolean hasStacks = (items != null);
|
||||||
try {
|
try {
|
||||||
dos.writeInt(x);
|
dos.writeInt(x);
|
||||||
dos.writeInt(y);
|
dos.writeInt(y);
|
||||||
dos.writeInt(z);
|
dos.writeInt(z);
|
||||||
dos.writeByte(typ);
|
dos.writeByte(typ);
|
||||||
dos.writeByte(hasStacks? 1 : 0);
|
dos.writeByte(hasStacks ? 1 : 0);
|
||||||
if (hasStacks) {
|
if (hasStacks) {
|
||||||
for (int i=0; i<24; i++) {
|
for (int i = 0; i < 24; i++) {
|
||||||
dos.writeInt(items[i]);
|
dos.writeInt(items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// UNPOSSIBLE?
|
// UNPOSSIBLE?
|
||||||
}
|
}
|
||||||
Packet250CustomPayload pkt=new Packet250CustomPayload();
|
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
||||||
pkt.channel="IronChest";
|
pkt.channel = "IronChest";
|
||||||
pkt.data=bos.toByteArray();
|
pkt.data = bos.toByteArray();
|
||||||
pkt.length=bos.size();
|
pkt.length = bos.size();
|
||||||
pkt.isChunkDataPacket=true;
|
pkt.isChunkDataPacket = true;
|
||||||
return pkt;
|
return pkt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sortTopStacks() {
|
protected void sortTopStacks() {
|
||||||
if (!type.isTransparent() || mod_IronChest.proxy.isRemote()) {
|
if (!type.isTransparent() || IronChest.proxy.isRemote()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack[] tempCopy = new ItemStack[getSizeInventory()];
|
ItemStack[] tempCopy = new ItemStack[getSizeInventory()];
|
||||||
|
@ -232,7 +232,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
// Resynchronize clients with the server state
|
// Resynchronize clients with the server state
|
||||||
if ((++ticksSinceSync % 20) * 4 == 0) {
|
if ((++ticksSinceSync % 20) * 4 == 0) {
|
||||||
worldObj.sendClientEvent(xCoord, yCoord, zCoord, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7));
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 3, ((numUsingPlayers << 3) & 0xF8) | (facing & 0x7));
|
||||||
if (inventoryTouched) {
|
if (inventoryTouched) {
|
||||||
inventoryTouched = false;
|
inventoryTouched = false;
|
||||||
sortTopStacks();
|
sortTopStacks();
|
||||||
|
@ -287,7 +287,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
if (worldObj == null)
|
if (worldObj == null)
|
||||||
return;
|
return;
|
||||||
numUsingPlayers++;
|
numUsingPlayers++;
|
||||||
worldObj.sendClientEvent(xCoord, yCoord, zCoord, 1, numUsingPlayers);
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 1, numUsingPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -295,7 +295,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
if (worldObj == null)
|
if (worldObj == null)
|
||||||
return;
|
return;
|
||||||
numUsingPlayers--;
|
numUsingPlayers--;
|
||||||
worldObj.sendClientEvent(xCoord, yCoord, zCoord, 1, numUsingPlayers);
|
worldObj.addBlockEvent(xCoord, yCoord, zCoord, IronChest.ironChestBlock.blockID, 1, numUsingPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacing(byte chestFacing) {
|
public void setFacing(byte chestFacing) {
|
||||||
|
@ -312,7 +312,7 @@ public class TileEntityIronChest extends TileEntity implements IInventory {
|
||||||
TileEntityIronChest newEntity = IronChestType.makeEntity(itemChestChanger.getTargetChestOrdinal(getType().ordinal()));
|
TileEntityIronChest newEntity = IronChestType.makeEntity(itemChestChanger.getTargetChestOrdinal(getType().ordinal()));
|
||||||
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 = mod_IronChest.ironChestBlock;
|
BlockIronChest block = IronChest.ironChestBlock;
|
||||||
block.dropContent(newSize, this, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
block.dropContent(newSize, this, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||||
newEntity.setFacing(facing);
|
newEntity.setFacing(facing);
|
||||||
newEntity.sortTopStacks();
|
newEntity.sortTopStacks();
|
||||||
|
|
|
@ -1,113 +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 java.io.File;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.ModContainer;
|
|
||||||
import cpw.mods.fml.common.modloader.ModLoaderModContainer;
|
|
||||||
|
|
||||||
import net.minecraft.src.ModLoader;
|
|
||||||
import net.minecraft.src.SidedProxy;
|
|
||||||
import net.minecraft.src.forge.Configuration;
|
|
||||||
import net.minecraft.src.forge.MinecraftForge;
|
|
||||||
import net.minecraft.src.forge.NetworkMod;
|
|
||||||
import net.minecraft.src.forge.adaptors.EntityLivingHandlerAdaptor;
|
|
||||||
|
|
||||||
public class mod_IronChest extends NetworkMod {
|
|
||||||
|
|
||||||
public static BlockIronChest ironChestBlock;
|
|
||||||
@SidedProxy(clientSide="cpw.mods.ironchest.client.ClientProxy", serverSide="cpw.mods.ironchest.server.ServerProxy")
|
|
||||||
public static IProxy proxy;
|
|
||||||
public static mod_IronChest instance;
|
|
||||||
public static boolean CACHE_RENDER = true;
|
|
||||||
public static boolean OCELOTS_SITONCHESTS = true;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion() {
|
|
||||||
return Version.version();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load() {
|
|
||||||
MinecraftForge.versionDetect("IronChest", 3, 3, 8);
|
|
||||||
ModContainer fml=ModLoaderModContainer.findContainerFor(this);
|
|
||||||
if (fml.getMetadata()!=null) {
|
|
||||||
fml.getMetadata().version=Version.fullVersionString();
|
|
||||||
}
|
|
||||||
instance = this;
|
|
||||||
File cfgFile = new File(proxy.getMinecraftDir(), "config/IronChest.cfg");
|
|
||||||
Configuration cfg = new Configuration(cfgFile);
|
|
||||||
try {
|
|
||||||
cfg.load();
|
|
||||||
int bId = cfg.getOrCreateBlockIdProperty("ironChests", 181).getInt(181);
|
|
||||||
ironChestBlock = new BlockIronChest(bId);
|
|
||||||
ChestChangerType.buildItems(cfg, 29501);
|
|
||||||
CACHE_RENDER = cfg.getOrCreateBooleanProperty("cacheRenderingInformation", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
|
||||||
OCELOTS_SITONCHESTS = cfg.getOrCreateBooleanProperty("ocelotsSitOnChests", Configuration.CATEGORY_GENERAL, true).getBoolean(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
ModLoader.getLogger().severe("IronChest was unable to load it's configuration successfully");
|
|
||||||
e.printStackTrace(System.err);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} finally {
|
|
||||||
cfg.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
ModLoader.registerBlock(ironChestBlock, ItemIronChest.class);
|
|
||||||
proxy.registerTranslations();
|
|
||||||
proxy.registerTileEntities();
|
|
||||||
IronChestType.generateTieredRecipes(ironChestBlock);
|
|
||||||
ChestChangerType.generateRecipes();
|
|
||||||
|
|
||||||
MinecraftForge.setGuiHandler(this, proxy);
|
|
||||||
MinecraftForge.registerConnectionHandler(new PacketHandler());
|
|
||||||
proxy.registerRenderInformation();
|
|
||||||
MinecraftForge.registerEntityLivingHandler(new OcelotsSitOnChestsHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modsLoaded() {
|
|
||||||
try {
|
|
||||||
Class<?> equivexmaps = Class.forName("ee.EEMaps");
|
|
||||||
Method addEMC = equivexmaps.getMethod("addEMC", int.class, int.class, int.class);
|
|
||||||
Method addMeta = equivexmaps.getMethod("addMeta", int.class, int.class);
|
|
||||||
int[] chestEMCValues = new int[]
|
|
||||||
{
|
|
||||||
8 * 8 + 256 * 8, /* iron chest */
|
|
||||||
8 * 8 + 256 * 8 + 2048 * 8, /* gold chest */
|
|
||||||
2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6, /* diamond chest */
|
|
||||||
85 * 8 + 8 * 8, /* copper chest */
|
|
||||||
85 * 8 + 8 * 8 + 512 * 8, /* silver chest */
|
|
||||||
2 * 8192 + 8 * 8 + 256 * 8 + 2048 * 8 + 6 + 8 /* crystal chest */
|
|
||||||
};
|
|
||||||
for (IronChestType icType : IronChestType.values()) {
|
|
||||||
if (icType.ordinal()>=chestEMCValues.length)
|
|
||||||
break;
|
|
||||||
addEMC.invoke(null, ironChestBlock.blockID, icType.ordinal(), chestEMCValues[icType.ordinal()]);
|
|
||||||
}
|
|
||||||
addMeta.invoke(null, ironChestBlock.blockID, IronChestType.values().length - 1);
|
|
||||||
ModLoader.getLogger().fine("mod_IronChest registered chests with Equivalent Exchange");
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ModLoader.getLogger().fine("mod_IronChest unable to load Equivalent Exchange integration");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean clientSideRequired() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean serverSideRequired() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -57,17 +57,6 @@ public class ServerProxy implements IProxy {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getGuiElement(int ID, EntityPlayer player, World world, int X, int Y, int Z) {
|
|
||||||
TileEntity te=world.getBlockTileEntity(X, Y, Z);
|
|
||||||
if (te!=null && te instanceof TileEntityIronChest) {
|
|
||||||
TileEntityIronChest icte=(TileEntityIronChest) te;
|
|
||||||
return new ContainerIronChestBase(player.inventory, icte, icte.getType(), 0, 0);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getCurrentWorld() {
|
public World getCurrentWorld() {
|
||||||
// NOOP on server: there's lots
|
// NOOP on server: there's lots
|
||||||
|
|
Loading…
Reference in New Issue