Merge branch 'indicators'

Conflicts:
	src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java
This commit is contained in:
Justin Aquadro committed 2014-09-12 01:56:20 -04:00
commit 8765cad121
11 files changed
+118 -2

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

@@ -59,6 +59,13 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
@SideOnly(Side.CLIENT)
private IIcon[] iconOverlayCross;
@SideOnly(Side.CLIENT)
private IIcon iconIndicatorOn;
@SideOnly(Side.CLIENT)
private IIcon iconIndicatorAmber;
@SideOnly(Side.CLIENT)
private IIcon iconIndicatorOff;
public BlockDrawers (String blockName, int drawerCount, boolean halfDepth) {
super(Material.wood);
@@ -400,6 +407,25 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
return getIcon(blockAccess, x, y, z, side, level);
}
@SideOnly(Side.CLIENT)
public IIcon getIndicatorIcon (boolean on) {
return on ? iconIndicatorOn : iconIndicatorAmber;
}
@SideOnly(Side.CLIENT)
public IIcon getIndicatorIcon (int level) {
switch (level) {
case 0:
return iconIndicatorOff;
case 1:
return iconIndicatorAmber;
case 2:
return iconIndicatorOn;
default:
return iconIndicatorOff;
}
}
@SideOnly(Side.CLIENT)
private IIcon getIcon (IBlockAccess blockAccess, int x, int y, int z, int side, int level) {
int meta = blockAccess.getBlockMetadata(x, y, z) % BlockWood.field_150096_a.length;
@@ -467,5 +493,9 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
iconOverlayH[i] = register.registerIcon(StorageDrawers.MOD_ID + ":overlay_" + overlays[i] + "_h");
iconOverlayCross[i] = register.registerIcon(StorageDrawers.MOD_ID + ":overlay_" + overlays[i] + "_cross");
}
iconIndicatorOff = register.registerIcon(StorageDrawers.MOD_ID + ":indicator_off");
iconIndicatorAmber = register.registerIcon(StorageDrawers.MOD_ID + ":indicator_amber");
iconIndicatorOn = register.registerIcon(StorageDrawers.MOD_ID + ":indicator_on");
}
}
@@ -60,6 +60,13 @@ public class TileEntityCompDrawers extends TileEntityDrawersBase implements ISto
return pooledCount / convRate[slot];
}
public int getItemCapacity (int slot) {
if (!isSlotValid(slot))
return 0;
return data[slot].maxCapacity() * convRate[slot];
}
public int getItemStackSize (int slot) {
return data[slot].itemStackMaxSize();
}
@@ -160,6 +160,10 @@ public class TileEntityDrawers extends TileEntityDrawersBase implements IStorage
return data[slot].count;
}
public int getItemCapacity (int slot) {
return data[slot].maxCapacity();
}
public int getItemStackSize (int slot) {
return data[slot].itemStackMaxSize();
}
@@ -53,6 +53,8 @@ public abstract class TileEntityDrawersBase extends TileEntity
public abstract int getItemStackSize (int slot);
public abstract int getItemCapacity (int slot);
public abstract ItemStack getSingleItemStack (int slot);
@Override
@@ -22,6 +22,8 @@ import org.lwjgl.opengl.GL11;
public class DrawersRenderer implements ISimpleBlockRenderingHandler
{
private static final double unit = .0625f;
private ModularBoxRenderer boxRenderer = new ModularBoxRenderer();
@Override
@@ -33,7 +35,6 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
}
private void renderInventoryBlock (BlockDrawers block, int metadata, int modelId, RenderBlocks renderer) {
double unit = .0625;
int side = 4;
boxRenderer.setUnit(unit);
@@ -91,9 +92,81 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
renderInterior(block, x, y, z, side, renderer);
boxRenderer.setIcon(block.getIndicatorIcon(false));
/*if (block.drawerCount == 2)
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 14, unit * 1, unit * 15, unit * 15, unit * 15, unit * 15.5, 0,
ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_ZNEG);
else
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 7, unit * 1, unit * 15, unit * 9, unit * 15, unit * 15.5, 0,
ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_ZNEG);*/
/*if (block.drawerCount == 2) {
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 6, unit * 14, unit * 15, unit * 10, unit * 15, unit * 15.05, 0,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG);
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 6, unit * 6, unit * 15, unit * 10, unit * 7, unit * 15.05, 0,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG);
}*/
renderHandleIndicator(block, x, y, z, side, renderer);
/*boxRenderer.renderExterior(renderer, block, x, y, z, unit * 14, unit * 14, unit * 15, unit * 15, unit * 15, unit * 16, 0,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_ZNEG);
if (block.drawerCount == 4)
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 1, unit * 14, unit * 15, unit * 2, unit * 15, unit * 16, 0,
ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG);*/
return true;
}
//private static double[] handleIndicatorX = new double[] { unit * 6, unit * 10, unit * 3, unit * 4, unit * 11, unit * 12 };
//private static double[] handleIndicatorXN = new double[] { 1 - unit * 6, 1 - unit * 10, 1 - unit * 3, 1 - unit * 4, 1 - unit * 11, 1 - unit * 12 };
//private static double[] handleIndicatorZ = new double[] { unit * 15.05, unit * 15.05, unit * 15.05, unit * 15.05, unit * 15.05, unit * 15.05 };
//private static double[] handleIndicatorZN = new double[] { unit * .95, unit * .95, unit * .95, unit * .95, unit * .96, unit * .95 };
private void renderHandleIndicator (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
TileEntityDrawersBase tile = block.getTileEntity(renderer.blockAccess, x, y, z);
double depth = block.halfDepth ? .5 : 1;
int cut2 = ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZPOS;
int cut3 = ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG;
int cut4 = ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XPOS | ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS;
int cut5 = ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_XNEG | ModularBoxRenderer.CUT_ZNEG | ModularBoxRenderer.CUT_ZPOS;
if (block.drawerCount == 2) {
int iconIndex0 = (tile.getItemCapacity(0) > 0 && tile.getItemCount(0) == tile.getItemCapacity(0)) ? 2
: (tile.getItemCapacity(0) > 0 && tile.getItemCount(0) / tile.getItemCapacity(0) > .75) ? 1 : 0;
int iconIndex1 = (tile.getItemCapacity(1) > 0 && tile.getItemCount(1) == tile.getItemCapacity(1)) ? 2
: (tile.getItemCapacity(1) > 0 && tile.getItemCount(1) / tile.getItemCapacity(1) > .75) ? 1 : 0;
switch (side) {
case 2:
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex0));
boxRenderer.renderExterior(renderer, block, x, y, z, 1 - unit * 10, unit * 14, 1 - depth + unit * .95, 1 - unit * 6, unit * 15, 1 - depth + unit * 1, 0, cut2);
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex1));
boxRenderer.renderExterior(renderer, block, x, y, z, 1 - unit * 10, unit * 6, 1 - depth + unit * .95, 1 - unit * 6, unit * 7, 1 - depth + unit * 1, 0, cut2);
break;
case 3:
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex0));
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 6, unit * 14, depth - unit * 1, unit * 10, unit * 15, depth - unit * .95, 0, cut3);
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex1));
boxRenderer.renderExterior(renderer, block, x, y, z, unit * 6, unit * 6, depth - unit * 1, unit * 10, unit * 7, depth - unit * .95, 0, cut3);
break;
case 4:
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex0));
boxRenderer.renderExterior(renderer, block, x, y, z, 1 - depth + unit * .95, unit * 14, 1 - unit * 10, 1 - depth + unit * 1, unit * 15, 1 - unit * 6, 0, cut4);
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex1));
boxRenderer.renderExterior(renderer, block, x, y, z, 1 - depth + unit * .95, unit * 6, 1 - unit * 10, 1 - depth + unit * 1, unit * 7, 1 - unit * 6, 0, cut4);
break;
case 5:
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex0));
boxRenderer.renderExterior(renderer, block, x, y, z, depth - unit * 1, unit * 14, unit * 6, depth - unit * .95, unit * 15, unit * 10, 0, cut5);
boxRenderer.setExteriorIcon(block.getIndicatorIcon(iconIndex1));
boxRenderer.renderExterior(renderer, block, x, y, z, depth - unit * 1, unit * 6, unit * 6, depth - unit * .95, unit * 7, unit * 10, 0, cut5);
break;
}
}
}
private void renderExterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
@@ -225,7 +225,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
if (blockType) {
Block itemBlock = Block.getBlockFromItem(itemStack.getItem());
itemBlock.setBlockBoundsForItemRender();
double zDepth = 1 - itemBlock.getBlockBoundsMaxZ();
itemDepth += zDepth * zunit;
}