Compare commits
5 Commits
f4949dadcc
...
9811e590e7
Author | SHA1 | Date |
---|---|---|
Astoria | 9811e590e7 | 1 year ago |
Astoria | 3206c61a9e | 1 year ago |
Astoria | 4a645cd035 | 1 year ago |
Astoria | cc24e7a835 | 1 year ago |
Astoria | 7959ee8afb | 1 year ago |
@ -0,0 +1,66 @@
|
||||
package net.brokenmoon.afloydironchest.blocks;
|
||||
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP;
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP;
|
||||
import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class DiamondChest extends BlockContainer{
|
||||
|
||||
Random random = new Random();
|
||||
public DiamondChest(int id, Material blockMaterial){
|
||||
super(id, blockMaterial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockRemoval(World world, int i, int j, int k) {
|
||||
TileEntityDiamondChest te = (TileEntityDiamondChest)world.getBlockTileEntity(i, j, k);
|
||||
for (int l = 0; l < te.getSizeInventory(); ++l) {
|
||||
ItemStack itemstack = te.getStackInSlot(l);
|
||||
if (itemstack == null) continue;
|
||||
float f = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
float f1 = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
float f2 = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
while (itemstack.stackSize > 0) {
|
||||
int i1 = this.random.nextInt(21) + 10;
|
||||
if (i1 > itemstack.stackSize) {
|
||||
i1 = itemstack.stackSize;
|
||||
}
|
||||
itemstack.stackSize -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata()));
|
||||
float f3 = 0.05f;
|
||||
entityitem.motionX = (float)this.random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f;
|
||||
entityitem.motionZ = (float)this.random.nextGaussian() * f3;
|
||||
world.entityJoinedWorld(entityitem);
|
||||
}
|
||||
}
|
||||
super.onBlockRemoval(world, i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
||||
IInventory chest = (TileEntityDiamondChest)world.getBlockTileEntity(x, y, z);
|
||||
if (!world.isMultiplayerAndNotHost) {
|
||||
this.displayGui(entityplayer, chest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity() {
|
||||
return new TileEntityDiamondChest();
|
||||
}
|
||||
|
||||
public static void displayGui(EntityPlayer player, IInventory inventory){
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
//Multiplayer
|
||||
((IEntityPlayerMP)player).displayGUIDiamondChest(inventory);
|
||||
return;
|
||||
}
|
||||
//Singleplayer
|
||||
((IEntityPlayerSP)player).displayGUIDiamondChest(inventory);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package net.brokenmoon.afloydironchest.blocks;
|
||||
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP;
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP;
|
||||
import net.brokenmoon.afloydironchest.tileEntities.TileEntityGoldChest;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class GoldChest extends BlockContainer{
|
||||
|
||||
Random random = new Random();
|
||||
public GoldChest(int id, Material blockMaterial){
|
||||
super(id, blockMaterial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockRemoval(World world, int i, int j, int k) {
|
||||
TileEntityGoldChest te = (TileEntityGoldChest)world.getBlockTileEntity(i, j, k);
|
||||
for (int l = 0; l < te.getSizeInventory(); ++l) {
|
||||
ItemStack itemstack = te.getStackInSlot(l);
|
||||
if (itemstack == null) continue;
|
||||
float f = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
float f1 = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
float f2 = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
while (itemstack.stackSize > 0) {
|
||||
int i1 = this.random.nextInt(21) + 10;
|
||||
if (i1 > itemstack.stackSize) {
|
||||
i1 = itemstack.stackSize;
|
||||
}
|
||||
itemstack.stackSize -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata()));
|
||||
float f3 = 0.05f;
|
||||
entityitem.motionX = (float)this.random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f;
|
||||
entityitem.motionZ = (float)this.random.nextGaussian() * f3;
|
||||
world.entityJoinedWorld(entityitem);
|
||||
}
|
||||
}
|
||||
super.onBlockRemoval(world, i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
||||
IInventory chest = (TileEntityGoldChest)world.getBlockTileEntity(x, y, z);
|
||||
if (!world.isMultiplayerAndNotHost) {
|
||||
this.displayGui(entityplayer, chest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity() {
|
||||
return new TileEntityGoldChest();
|
||||
}
|
||||
|
||||
public static void displayGui(EntityPlayer player, IInventory inventory){
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
//Multiplayer
|
||||
((IEntityPlayerMP)player).displayGUIIronChest(inventory);
|
||||
return;
|
||||
}
|
||||
//Singleplayer
|
||||
((IEntityPlayerSP)player).displayGUIIronChest(inventory);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package net.brokenmoon.afloydironchest.blocks;
|
||||
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP;
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP;
|
||||
import net.brokenmoon.afloydironchest.tileEntities.TileEntitySteelChest;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SteelChest extends BlockContainer{
|
||||
|
||||
Random random = new Random();
|
||||
public SteelChest(int id, Material blockMaterial){
|
||||
super(id, blockMaterial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockRemoval(World world, int i, int j, int k) {
|
||||
TileEntitySteelChest te = (TileEntitySteelChest)world.getBlockTileEntity(i, j, k);
|
||||
for (int l = 0; l < te.getSizeInventory(); ++l) {
|
||||
ItemStack itemstack = te.getStackInSlot(l);
|
||||
if (itemstack == null) continue;
|
||||
float f = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
float f1 = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
float f2 = this.random.nextFloat() * 0.8f + 0.1f;
|
||||
while (itemstack.stackSize > 0) {
|
||||
int i1 = this.random.nextInt(21) + 10;
|
||||
if (i1 > itemstack.stackSize) {
|
||||
i1 = itemstack.stackSize;
|
||||
}
|
||||
itemstack.stackSize -= i1;
|
||||
EntityItem entityitem = new EntityItem(world, (float)i + f, (float)j + f1, (float)k + f2, new ItemStack(itemstack.itemID, i1, itemstack.getMetadata()));
|
||||
float f3 = 0.05f;
|
||||
entityitem.motionX = (float)this.random.nextGaussian() * f3;
|
||||
entityitem.motionY = (float)this.random.nextGaussian() * f3 + 0.2f;
|
||||
entityitem.motionZ = (float)this.random.nextGaussian() * f3;
|
||||
world.entityJoinedWorld(entityitem);
|
||||
}
|
||||
}
|
||||
super.onBlockRemoval(world, i, j, k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blockActivated(World world, int x, int y, int z, EntityPlayer entityplayer) {
|
||||
IInventory chest = (TileEntitySteelChest)world.getBlockTileEntity(x, y, z);
|
||||
if (!world.isMultiplayerAndNotHost) {
|
||||
this.displayGui(entityplayer, chest);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileEntity getBlockEntity() {
|
||||
return new TileEntitySteelChest();
|
||||
}
|
||||
|
||||
public static void displayGui(EntityPlayer player, IInventory inventory){
|
||||
if(player instanceof EntityPlayerMP) {
|
||||
//Multiplayer
|
||||
((IEntityPlayerMP)player).displayGUIDiamondChest(inventory);
|
||||
return;
|
||||
}
|
||||
//Singleplayer
|
||||
((IEntityPlayerSP)player).displayGUIDiamondChest(inventory);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package net.brokenmoon.afloydironchest.gui;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ContainerWideChest extends Container {
|
||||
private IInventory inventory;
|
||||
private int numberOfRowsUpper;
|
||||
|
||||
public ContainerWideChest(IInventory lowerInventory, IInventory upperInventory) {
|
||||
this.inventory = upperInventory;
|
||||
this.numberOfRowsUpper = upperInventory.getSizeInventory() / 12;
|
||||
//Upper
|
||||
for (int j = 0; j < this.numberOfRowsUpper; ++j) {
|
||||
for (int i1 = 0; i1 < 12; ++i1) {
|
||||
this.addSlot(new Slot(upperInventory, i1 + j * 12, 8 + i1 * 18, 8 + j * 18));
|
||||
}
|
||||
}
|
||||
//Lower
|
||||
for (int k = 0; k < 3; ++k) {
|
||||
for (int j1 = 0; j1 < 9; ++j1) {
|
||||
this.addSlot(new Slot(lowerInventory, j1 + k * 9 + 9, 8 + 18 + 9 + j1 * 18, 174 + k * 18));
|
||||
}
|
||||
}
|
||||
//Taskbar
|
||||
for (int l = 0; l < 9; ++l) {
|
||||
this.addSlot(new Slot(lowerInventory, l, 8 + 18 + 9 + l * 18, 232));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer(EntityPlayer entityplayer) {
|
||||
return this.inventory.canInteractWith(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quickMoveItems(int slotID, EntityPlayer player, boolean shift, boolean control) {
|
||||
Slot slot = (Slot)this.inventorySlots.get(slotID);
|
||||
if (slot == null || !slot.hasStack()) {
|
||||
return;
|
||||
}
|
||||
ItemStack item = slot.getStack();
|
||||
ItemStack originalItem = item.copy();
|
||||
if (slotID < this.numberOfRowsUpper * 12) {
|
||||
this.onStackMergeShiftClick(item, this.numberOfRowsUpper * 12, this.inventorySlots.size(), true);
|
||||
} else {
|
||||
this.onStackMergeShiftClick(item, 0, this.numberOfRowsUpper * 12, false);
|
||||
}
|
||||
if (item.stackSize == 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (item.stackSize != originalItem.stackSize) {
|
||||
slot.onPickupFromSlot(item);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.brokenmoon.afloydironchest.gui;
|
||||
|
||||
import net.minecraft.src.GuiContainer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class GuiDiamondChest extends GuiContainer {
|
||||
private IInventory upperChestInventory;
|
||||
private IInventory lowerChestInventory;
|
||||
private int inventoryRows;
|
||||
|
||||
public GuiDiamondChest(IInventory iinventory, IInventory iinventory1) {
|
||||
super(new ContainerWideChest(iinventory, iinventory1));
|
||||
this.upperChestInventory = iinventory;
|
||||
this.lowerChestInventory = iinventory1;
|
||||
this.field_948_f = false;
|
||||
this.inventoryRows = iinventory1.getSizeInventory() / 12;
|
||||
this.ySize = 256;
|
||||
this.xSize = 230;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f) {
|
||||
int i = this.mc.renderEngine.getTexture("/assets/ironchest/gui/containerWide.png");
|
||||
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
this.mc.renderEngine.bindTexture(i);
|
||||
int x = (this.width - this.xSize) / 2;
|
||||
int y = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.brokenmoon.afloydironchest.mixin;
|
||||
|
||||
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP;
|
||||
import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.NetClientHandler;
|
||||
import net.minecraft.src.Packet100OpenWindow;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(value = NetClientHandler.class, remap = false)
|
||||
public class MixinNetClientHandler {
|
||||
|
||||
@Shadow
|
||||
private Minecraft mc;
|
||||
|
||||
@Inject(method = "handleOpenWindow", at = @At("TAIL"))
|
||||
public void injectMethod(Packet100OpenWindow packet100openwindow, CallbackInfo info) {
|
||||
if (packet100openwindow.inventoryType == 7) {
|
||||
TileEntityDiamondChest dchest = new TileEntityDiamondChest();
|
||||
((IEntityPlayerSP)this.mc.thePlayer).displayGUIDiamondChest(dchest);
|
||||
this.mc.thePlayer.craftingInventory.windowId = packet100openwindow.windowId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package net.brokenmoon.afloydironchest.tileEntities;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class TileEntityDiamondChest extends TileEntity implements IInventory {
|
||||
private ItemStack[] contents = new ItemStack[108];
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 108;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return this.contents[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (this.contents[i] != null) {
|
||||
ItemStack itemstack1;
|
||||
if (this.contents[i].stackSize <= j) {
|
||||
itemstack1 = this.contents[i];
|
||||
this.contents[i] = null;
|
||||
this.onInventoryChanged();
|
||||
return itemstack1;
|
||||
} else {
|
||||
itemstack1 = this.contents[i].splitStack(j);
|
||||
if (this.contents[i].stackSize == 0) {
|
||||
this.contents[i] = null;
|
||||
}
|
||||
|
||||
this.onInventoryChanged();
|
||||
return itemstack1;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
this.contents[i] = itemStack;
|
||||
if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) {
|
||||
itemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
this.onInventoryChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
return "Diamond Chest";
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
|
||||
this.contents = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
|
||||
int j = nbttagcompound1.getByte("Slot") & 255;
|
||||
if (j >= 0 && j < this.contents.length) {
|
||||
this.contents[j] = new ItemStack(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < this.contents.length; ++i) {
|
||||
if (this.contents[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte)i);
|
||||
this.contents[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.setTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer) {
|
||||
if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) {
|
||||
return false;
|
||||
} else {
|
||||
return entityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package net.brokenmoon.afloydironchest.tileEntities;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class TileEntityGoldChest extends TileEntity implements IInventory {
|
||||
private ItemStack[] contents = new ItemStack[81];
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 81;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return this.contents[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (this.contents[i] != null) {
|
||||
ItemStack itemstack1;
|
||||
if (this.contents[i].stackSize <= j) {
|
||||
itemstack1 = this.contents[i];
|
||||
this.contents[i] = null;
|
||||
this.onInventoryChanged();
|
||||
return itemstack1;
|
||||
} else {
|
||||
itemstack1 = this.contents[i].splitStack(j);
|
||||
if (this.contents[i].stackSize == 0) {
|
||||
this.contents[i] = null;
|
||||
}
|
||||
|
||||
this.onInventoryChanged();
|
||||
return itemstack1;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
this.contents[i] = itemStack;
|
||||
if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) {
|
||||
itemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
this.onInventoryChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
return "Gold Chest";
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
|
||||
this.contents = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
|
||||
int j = nbttagcompound1.getByte("Slot") & 255;
|
||||
if (j >= 0 && j < this.contents.length) {
|
||||
this.contents[j] = new ItemStack(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < this.contents.length; ++i) {
|
||||
if (this.contents[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte)i);
|
||||
this.contents[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.setTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer) {
|
||||
if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) {
|
||||
return false;
|
||||
} else {
|
||||
return entityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package net.brokenmoon.afloydironchest.tileEntities;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class TileEntitySteelChest extends TileEntity implements IInventory {
|
||||
private ItemStack[] contents = new ItemStack[108];
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 108;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return this.contents[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (this.contents[i] != null) {
|
||||
ItemStack itemstack1;
|
||||
if (this.contents[i].stackSize <= j) {
|
||||
itemstack1 = this.contents[i];
|
||||
this.contents[i] = null;
|
||||
this.onInventoryChanged();
|
||||
return itemstack1;
|
||||
} else {
|
||||
itemstack1 = this.contents[i].splitStack(j);
|
||||
if (this.contents[i].stackSize == 0) {
|
||||
this.contents[i] = null;
|
||||
}
|
||||
|
||||
this.onInventoryChanged();
|
||||
return itemstack1;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
this.contents[i] = itemStack;
|
||||
if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()) {
|
||||
itemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
this.onInventoryChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName() {
|
||||
return "Steel Chest";
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||
super.readFromNBT(nbttagcompound);
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items");
|
||||
this.contents = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
|
||||
NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);
|
||||
int j = nbttagcompound1.getByte("Slot") & 255;
|
||||
if (j >= 0 && j < this.contents.length) {
|
||||
this.contents[j] = new ItemStack(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||
super.writeToNBT(nbttagcompound);
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for(int i = 0; i < this.contents.length; ++i) {
|
||||
if (this.contents[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte)i);
|
||||
this.contents[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.setTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
|
||||
nbttagcompound.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityPlayer) {
|
||||
if (this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this) {
|
||||
return false;
|
||||
} else {
|
||||
return entityPlayer.getDistanceSq((double)this.xCoord + 0.5, (double)this.yCoord + 0.5, (double)this.zCoord + 0.5) <= 64.0;
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 5.5 KiB |
@ -1,2 +1,8 @@
|
||||
tile.ironchest.ironchest.name=Iron Chest
|
||||
tile.ironchest.ironchest.desc=A larger chest
|
||||
tile.ironchest.ironchest.desc=A large chest.
|
||||
tile.ironchest.goldchest.name=Gold Chest
|
||||
tile.ironchest.goldchest.desc=An extra-large chest.
|
||||
tile.ironchest.diamondchest.name=Diamond Chest
|
||||
tile.ironchest.diamondchest.desc=An extremely large chest.
|
||||
tile.ironchest.steelchest.name=Steel Chest
|
||||
tile.ironchest.steelchest.desc=An extremely large chest.
|
Loading…
Reference in New Issue