Compare commits

...

5 Commits

@ -1,6 +1,9 @@
package net.brokenmoon.afloydironchest;
import net.brokenmoon.afloydironchest.blocks.DiamondChest;
import net.brokenmoon.afloydironchest.blocks.IronChest;
import net.brokenmoon.afloydironchest.blocks.GoldChest;
import net.brokenmoon.afloydironchest.blocks.SteelChest;
import net.fabricmc.api.ModInitializer;
import net.minecraft.src.Block;
import net.minecraft.src.Material;
@ -14,6 +17,9 @@ public class IronChestMain implements ModInitializer {
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static Block IronChest = BlockHelper.createBlock(MOD_ID, new IronChest(900, Material.iron), "ironchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0);
public static Block GoldChest = BlockHelper.createBlock(MOD_ID, new GoldChest(901, Material.iron), "goldchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0);
public static Block DiamondChest = BlockHelper.createBlock(MOD_ID, new DiamondChest(902, Material.iron), "diamondchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0);
public static Block SteelChest = BlockHelper.createBlock(MOD_ID, new SteelChest(903, Material.iron), "steelchest", "ironchest.png", Block.soundMetalFootstep, 5, 6, 0);
@Override
public void onInitialize() {

@ -4,4 +4,6 @@ import net.minecraft.src.IInventory;
public interface IEntityPlayerMP {
public void displayGUIIronChest(IInventory iinventory);
public void displayGUIDiamondChest(IInventory iinventory);
}

@ -4,4 +4,6 @@ import net.minecraft.src.IInventory;
public interface IEntityPlayerSP {
public void displayGUIIronChest(IInventory iinventory);
public void displayGUIDiamondChest(IInventory iinventory);
}

@ -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);
}
}

@ -5,11 +5,41 @@ import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerSP;
import net.brokenmoon.afloydironchest.tileEntities.TileEntityIronChest;
import net.minecraft.src.*;
import java.util.Random;
public class IronChest extends BlockContainer {
Random random = new Random();
public IronChest(int id, Material blockMaterial){
super(id, blockMaterial);
}
@Override
public void onBlockRemoval(World world, int i, int j, int k) {
TileEntityIronChest te = (TileEntityIronChest)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 = (TileEntityIronChest)world.getBlockTileEntity(x, y, z);

@ -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);
}
}

@ -1,6 +1,7 @@
package net.brokenmoon.afloydironchest.mixin;
import net.brokenmoon.afloydironchest.MixinInterfaces.IEntityPlayerMP;
import net.brokenmoon.afloydironchest.gui.ContainerWideChest;
import net.minecraft.src.*;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -24,4 +25,13 @@ public class MixinEntityPlayerMP implements IEntityPlayerMP {
((EntityPlayerMP)(Object)this).craftingInventory.windowId = this.currentWindowId;
((EntityPlayerMP)(Object)this).craftingInventory.onContainerInit(((EntityPlayerMP)(Object)this));
}
public void displayGUIDiamondChest(IInventory iinventory) {
this.getNextWindowId();
NetServerHandler.logger.info(((EntityPlayerMP)(Object)this).username + " interacted with chest at (" + ((EntityPlayerMP)(Object)this).posX + ", " + ((EntityPlayerMP)(Object)this).posY + ", " + ((EntityPlayerMP)(Object)this).posZ + ")");
this.playerNetServerHandler.sendPacket(new Packet100OpenWindow(this.currentWindowId, 7, iinventory.getInvName(), iinventory.getSizeInventory()));
((EntityPlayerMP)(Object)this).craftingInventory = new ContainerWideChest(((EntityPlayerMP)(Object)this).inventory, iinventory);
((EntityPlayerMP)(Object)this).craftingInventory.windowId = this.currentWindowId;
((EntityPlayerMP)(Object)this).craftingInventory.onContainerInit(((EntityPlayerMP)(Object)this));
}
}

@ -1,5 +1,6 @@
package net.brokenmoon.afloydironchest.mixin;
import net.brokenmoon.afloydironchest.gui.GuiDiamondChest;
import net.brokenmoon.afloydironchest.gui.GuiIronChest;
import net.minecraft.client.Minecraft;
import net.minecraft.src.*;
@ -13,4 +14,8 @@ public class MixinEntityPlayerSP {
public void displayGUIIronChest(IInventory iinventory) {
this.mc.displayGuiScreen(new GuiIronChest(((EntityPlayerSP)(Object)this).inventory, iinventory));
}
public void displayGUIDiamondChest(IInventory iinventory) {
this.mc.displayGuiScreen(new GuiDiamondChest(((EntityPlayerSP)(Object)this).inventory, iinventory));
}
}

@ -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;
}
}
}

@ -1,6 +1,9 @@
package net.brokenmoon.afloydironchest.mixin;
import net.brokenmoon.afloydironchest.tileEntities.TileEntityDiamondChest;
import net.brokenmoon.afloydironchest.tileEntities.TileEntityGoldChest;
import net.brokenmoon.afloydironchest.tileEntities.TileEntityIronChest;
import net.brokenmoon.afloydironchest.tileEntities.TileEntitySteelChest;
import net.minecraft.src.TileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -11,6 +14,9 @@ public class MixinTileEntity {
static {
addMapping(TileEntityIronChest.class, "Iron Chest");
addMapping(TileEntityGoldChest.class, "Gold Chest");
addMapping(TileEntityDiamondChest.class, "Diamond Chest");
addMapping(TileEntitySteelChest.class, "Steel Chest");
}
}

@ -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;
}
}
}

@ -6,7 +6,8 @@
"mixins": [
"MixinEntityPlayerMP",
"MixinEntityPlayerSP",
"MixinTileEntity"
"MixinTileEntity",
"MixinNetClientHandler"
],
"client": [

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…
Cancel
Save