Fixed a bunch of loose ends

This commit is contained in:
Justin Aquadro committed 2016-02-19 00:36:55 -05:00
1 parent 143f8acab2
commit 37a304cc70
5 files changed
+75 -85

No files matched your search

@@ -6,6 +6,7 @@ storageDrawers.container.compDrawers=Compacting Drawers
storageDrawers.container.upgrades=Upgrades
storageDrawers.container.controller=Drawer Controller
storageDrawers.container.unboundSlave=Unbound Slave
storageDrawers.container.framingTable=Framing Table
storagedrawers.msg.maxUpgrades=This drawer cannot accept any more upgrades.
@@ -75,9 +76,16 @@ tile.halfDrawers4.jungle.name=Compact Jungle Drawers 2x2
tile.halfDrawers4.acacia.name=Compact Acacia Drawers 2x2
tile.halfDrawers4.big_oak.name=Compact Dark Oak Drawers 2x2
tile.fullCustom1.name=Framed Drawer
tile.fullCustom2.name=Framed Drawers 1x2
tile.fullCustom4.name=Framed Drawers 2x2
tile.halfCustom2.name=Framed Drawers 1x2
tile.halfCustom4.name=Framed Drawers 2x2
tile.compDrawers.name=Compacting Drawer
tile.drawerController.name=Drawer Controller
tile.controllerSlave.name=Controller Slave
tile.framingTable.name=Framing Table
tile.trim.oak.name=Oak Trim
tile.trim.spruce.name=Spruce Trim
@@ -11,6 +11,7 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.Constants;
public class TileEntityFramingTable extends TileEntity implements IInventory
@@ -68,7 +69,7 @@ public class TileEntityFramingTable extends TileEntity implements IInventory
@Override
public String getInventoryName () {
return hasCustomInventoryName() ? customName : "container.storagedrawers.framingTable";
return hasCustomInventoryName() ? customName : "storageDrawers.container.framingTable";
}
@Override
@@ -186,4 +187,32 @@ public class TileEntityFramingTable extends TileEntity implements IInventory
readFromNBT(pkt.func_148857_g());
//getWorldObj().func_147479_m(xCoord, yCoord, zCoord); // markBlockForRenderUpdate
}
private static final AxisAlignedBB ZERO_EXTENT_AABB = AxisAlignedBB.getBoundingBox(0, 0, 0, 0, 0, 0);
@Override
public AxisAlignedBB getRenderBoundingBox () {
int meta = getBlockMetadata();
if ((meta & 0x8) != 0)
return ZERO_EXTENT_AABB;
int side = meta & 0x7;
int xOff = 0;
int zOff = 0;
if (side == 2)
xOff = 1;
if (side == 3)
xOff = -1;
if (side == 4)
zOff = -1;
if (side == 5)
zOff = 1;
int xMin = Math.min(xCoord, xCoord + xOff);
int xMax = Math.max(xCoord, xCoord + xOff) + 1;
int zMin = Math.min(zCoord, zCoord + zOff);
int zMax = Math.max(zCoord, zCoord + zOff) + 1;
return AxisAlignedBB.getBoundingBox(xMin, yCoord + 1, xMax, zMin, yCoord + 2, zMax);
}
}
@@ -44,8 +44,6 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
if ((meta & 8) != 0)
return;
int side = meta & 0x07;
itemRenderer.setRenderManager(RenderManager.instance);
ItemStack target = tileTable.getStackInSlot(0);
@@ -60,77 +58,6 @@ public class TileEntityFramingRenderer extends TileEntitySpecialRenderer
renderSlot(tileTable, x, y, z, tileTable.getStackInSlot(1), 1.15f, -.225f, .15f, .65f);
renderSlot(tileTable, x, y, z, tileTable.getStackInSlot(2), 1.15f, -.225f, .15f, -.65f);
renderSlot(tileTable, x, y, z, tileTable.getStackInSlot(3), 1.15f, .225f, .15f, .65f);
/*ItemStack result = tileTable.getStackInSlot(0);
if (result != null) {
Block itemBlock = Block.getBlockFromItem(result.getItem());
if (itemBlock != null) {
itemBlock.setBlockBoundsBasedOnState(tile.getWorldObj(), 0, 0, 0);
itemBlock.setBlockBoundsForItemRender();
GL11.glPushMatrix();
GL11.glTranslated(x + .5, y + 1, z + .5);
if (side == 2)
GL11.glRotatef(90, 0, 1, 0);
if (side == 3)
GL11.glRotatef(270, 0, 1, 0);
if (side == 4)
GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslatef(0f, .25f, .5f);
GL11.glScalef(2f, 2f, 2f);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
try {
EntityItem itemEnt = new EntityItem(null, 0, 0, 0, result);
itemEnt.hoverStart = 0;
itemRenderer.doRender(itemEnt, 0, 0, 0, 0, 0);
}
catch (Exception e) { }
GL11.glPopMatrix();
}
}
ItemStack materialSide = tileTable.getStackInSlot(1);
if (materialSide != null) {
Block itemBlock = Block.getBlockFromItem(materialSide.getItem());
if (itemBlock != null) {
itemBlock.setBlockBoundsBasedOnState(tile.getWorldObj(), 0, 0, 0);
itemBlock.setBlockBoundsForItemRender();
GL11.glPushMatrix();
GL11.glTranslated(x + .5, y, z + .5);
if (side == 2)
GL11.glRotatef(90, 0, 1, 0);
if (side == 3)
GL11.glRotatef(270, 0, 1, 0);
if (side == 4)
GL11.glRotatef(180, 0, 1, 0);
GL11.glTranslatef(0, 0f, .5f);
GL11.glTranslatef(-.225f, 1.15f, .5f + .15f);
GL11.glScalef(1.15f, 1.15f, 1.15f);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
try {
EntityItem itemEnt = new EntityItem(null, 0, 0, 0, materialSide);
itemEnt.hoverStart = 0;
itemRenderer.doRender(itemEnt, 0, 0, 0, 0, 0);
}
catch (Exception e) { }
GL11.glPopMatrix();
}
}*/
}
private void renderSlot (TileEntityFramingTable tileTable, double x, double y, double z, ItemStack item, float scale, float tx, float ty, float tz) {
@@ -46,10 +46,10 @@ public class ContainerFramingTable extends Container
public ContainerFramingTable (InventoryPlayer inventory, TileEntityFramingTable tileEntity) {
tableInventory = new InventoryContainerProxy(tileEntity, this);
inputSlot = addSlotToContainer(new Slot(tableInventory, 0, InputX, InputY));
materialSideSlot = addSlotToContainer(new Slot(tableInventory, 1, MaterialSideX, MaterialSideY));
materialTrimSlot = addSlotToContainer(new Slot(tableInventory, 2, MaterialTrimX, MaterialTrimY));
materialFrontSlot = addSlotToContainer(new Slot(tableInventory, 3, MaterialFrontX, MaterialFrontY));
inputSlot = addSlotToContainer(new SlotRestricted(tableInventory, 0, InputX, InputY));
materialSideSlot = addSlotToContainer(new SlotRestricted(tableInventory, 1, MaterialSideX, MaterialSideY));
materialTrimSlot = addSlotToContainer(new SlotRestricted(tableInventory, 2, MaterialTrimX, MaterialTrimY));
materialFrontSlot = addSlotToContainer(new SlotRestricted(tableInventory, 3, MaterialFrontX, MaterialFrontY));
outputSlot = addSlotToContainer(new SlotCraftResult(inventory.player, tableInventory, craftResult, new int[] { 0, 1, 2, 3 }, 4, OutputX, OutputY));
playerSlots = new ArrayList<Slot>();
@@ -78,12 +78,14 @@ public class ContainerFramingTable extends Container
if (target != null) {
Block block = Block.getBlockFromItem(target.getItem());
if (block instanceof BlockDrawersCustom) {
craftResult.setInventorySlotContents(outputSlot.getSlotIndex(), ItemCustomDrawers.makeItemStack(block, 1, matSide, matTrim, matFront));
return;
if (matSide != null || (matTrim == null && matFront == null)) {
craftResult.setInventorySlotContents(0, ItemCustomDrawers.makeItemStack(block, 1, matSide, matTrim, matFront));
return;
}
}
}
craftResult.setInventorySlotContents(outputSlot.getSlotIndex(), null);
craftResult.setInventorySlotContents(0, null);
}
@Override
@@ -109,12 +111,19 @@ public class ContainerFramingTable extends Container
// Try merge stacks within inventory and hotbar spaces
else if (slotIndex >= inventoryStart && slotIndex < hotbarEnd) {
if (slotIndex >= inventoryStart && slotIndex < hotbarStart) {
if (!mergeItemStack(slotStack, hotbarStart, hotbarEnd, false))
boolean merged = false;
if (TileEntityFramingTable.isItemValidDrawer(slotStack))
merged = mergeItemStack(slotStack, inputSlot.slotNumber, inputSlot.slotNumber + 1, false);
if (TileEntityFramingTable.isItemValidMaterial(slotStack))
merged = mergeItemStack(slotStack, materialSideSlot.slotNumber, materialFrontSlot.slotNumber + 1, false);
if (!merged) {
if (slotIndex >= inventoryStart && slotIndex < hotbarStart) {
if (!mergeItemStack(slotStack, hotbarStart, hotbarEnd, false))
return null;
} else if (slotIndex >= hotbarStart && slotIndex < hotbarEnd && !this.mergeItemStack(slotStack, inventoryStart, hotbarStart, false))
return null;
}
else if (slotIndex >= hotbarStart && slotIndex < hotbarEnd && !this.mergeItemStack(slotStack, inventoryStart, hotbarStart, false))
return null;
}
// Try merge stack into inventory
@@ -0,0 +1,17 @@
package com.jaquadro.minecraft.storagedrawers.inventory;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class SlotRestricted extends Slot
{
public SlotRestricted (IInventory inventory, int slotIndex, int xDisplayPosition, int yDisplayPosition) {
super(inventory, slotIndex, xDisplayPosition, yDisplayPosition);
}
@Override
public boolean isItemValid (ItemStack stack) {
return inventory.isItemValidForSlot(getSlotIndex(), stack);
}
}