Fix status upgrades for "pack" versions of drawers.

This commit is contained in:
Justin Aquadro committed 2015-09-13 00:25:58 -04:00
1 parent 6dc10af857
commit d22ffc2b46
6 files changed
+67 -20

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ buildscript {
apply plugin: 'forge'
version = "1.7.10-1.6.0"
version = "1.7.10-1.6.1"
group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "StorageDrawers"
@@ -54,11 +54,13 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
public final boolean halfDepth;
public final int drawerCount;
public float trimWidth = 0.0625f;
public float trimDepth = 0.0625f;
public float indStart = 0;
public float indEnd = 0;
public int indSteps = 0;
private float trimWidth = 0.0625f;
private float trimDepth = 0.0625f;
private float indStart = 0;
private float indEnd = 0;
private int indSteps = 0;
private String blockConfigName;
@SideOnly(Side.CLIENT)
protected IIcon[] iconSide;
@@ -114,9 +116,39 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
setHardness(5f);
setStepSound(Block.soundTypeWood);
setBlockName(blockName);
setConfigName(blockName);
setLightOpacity(255);
}
public float getTrimWidth () {
return trimWidth;
}
public float getTrimDepth () {
return trimDepth;
}
public float getIndStart () {
return indStart;
}
public float getIndEnd () {
return indEnd;
}
public int getIndSteps () {
return indSteps;
}
public BlockDrawers setConfigName (String name) {
blockConfigName = name;
return this;
}
public String getConfigName () {
return blockConfigName;
}
@Override
public boolean renderAsNormalBlock () {
return false;
@@ -740,7 +772,7 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
reader = new BufferedReader(new InputStreamReader(configResource.getInputStream()));
JsonObject root = (new JsonParser()).parse(reader).getAsJsonObject();
JsonObject entry = root.getAsJsonObject(getUnlocalizedName().substring(5));
JsonObject entry = root.getAsJsonObject(getConfigName());
if (entry != null) {
if (entry.has("trimWidth"))
trimWidth = entry.get("trimWidth").getAsFloat();
@@ -114,7 +114,7 @@ public class DrawersItemRenderer implements IItemRenderer
}
private void renderInterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double unit = block.trimDepth;
double unit = block.getTrimDepth();
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
@@ -102,7 +102,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
break;
}
boxRenderer.setUnit(block.trimWidth);
boxRenderer.setUnit(block.getTrimWidth());
boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
for (int i = 0; i < 6; i++)
boxRenderer.setExteriorIcon(block.getIcon(world, x, y, z, i), i);
@@ -216,7 +216,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
TileEntityDrawers tile = block.getTileEntity(renderer.blockAccess, x, y, z);
double depth = block.halfDepth ? 8 : 16;
double depthAdj = block.trimDepth * 16;
double depthAdj = block.getTrimDepth() * 16;
int count = 0;
float w = 2;
@@ -267,7 +267,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
TileEntityDrawers tile = block.getTileEntity(renderer.blockAccess, x, y, z);
double depth = block.halfDepth ? 8 : 16;
double depthAdj = block.trimDepth * 16;
double depthAdj = block.getTrimDepth() * 16;
int count = 0;
float[][] xywhSet = null;
@@ -306,9 +306,9 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
boxRenderer.renderExterior(renderer, block, x, y, z, boxCoord[0], boxCoord[1], boxCoord[2], boxCoord[3], boxCoord[4], boxCoord[5], 0, cut[side - 2]);
}
else if (level >= 2) {
double indStart = xywh[0] + block.indStart / unit;
double indEnd = xywh[0] + block.indEnd / unit;
double indCur = getIndEnd(block, tile, i, indStart, (block.indEnd - block.indStart) / unit);
double indStart = xywh[0] + block.getIndStart() / unit;
double indEnd = xywh[0] + block.getIndEnd() / unit;
double indCur = getIndEnd(block, tile, i, indStart, (block.getIndEnd() - block.getIndStart()) / unit);
if (indCur > indStart) {
if (indCur >= indEnd)
@@ -337,7 +337,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
if (cap == 0 || count == 0)
return x;
int step = block.indSteps > 0 ? block.indSteps : 1000;
int step = block.getIndSteps() > 0 ? block.getIndSteps() : 1000;
float fillAmt = (float)(step * count / cap) / step;
return x + (w * fillAmt);
@@ -420,7 +420,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler
}
private void renderInterior (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer) {
double unit = block.trimDepth;
double unit = block.getTrimDepth();
double depth = block.halfDepth ? .5 : 1;
double xMin = 0, xMax = 0, zMin = 0, zMax = 0;
@@ -393,7 +393,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
float xunit = getXOffset(drawerCount, slot);
float yunit = getYOffset(drawerCount, slot);
float zunit = isBlockType ? 1.95f * block.trimDepth : block.trimDepth;
float zunit = isBlockType ? 1.95f * block.getTrimDepth() : block.getTrimDepth();
float xc = 0, zc = 0;
float itemDepth = depth + .001f;
@@ -470,7 +470,7 @@ public class TileEntityDrawersRenderer extends TileEntitySpecialRenderer
GL11.glPushMatrix();
alignRendering(side);
moveRendering(size, getOffsetXForSide(side, xunit) * 16 - (8 * size), 12.25f - yunit, 1f - depth + block.trimDepth);
moveRendering(size, getOffsetXForSide(side, xunit) * 16 - (8 * size), 12.25f - yunit, 1f - depth + block.getTrimDepth());
List<IRenderLabel> renderHandlers = StorageDrawers.renderRegistry.getRenderHandlers();
for (int i = 0, n = renderHandlers.size(); i < n; i++) {
@@ -24,10 +24,10 @@ public class PackFactory implements IPackBlockFactory
public Block createBlock (BlockConfiguration blockConfig, IPackDataResolver dataResolver) {
switch (blockConfig.getBlockType()) {
case Drawers:
return new BlockDrawersPack(dataResolver, blockConfig.getDrawerCount(), blockConfig.isHalfDepth());
return new BlockDrawersPack(dataResolver, blockConfig.getDrawerCount(), blockConfig.isHalfDepth()).setConfigName(getConfigName(blockConfig));
case DrawersSorting:
if (IntegrationRegistry.instance().isModLoaded("RefinedRelocation"))
return new BlockSortingDrawersPack(dataResolver, blockConfig.getDrawerCount(), blockConfig.isHalfDepth());
return new BlockSortingDrawersPack(dataResolver, blockConfig.getDrawerCount(), blockConfig.isHalfDepth()).setConfigName(getConfigName(blockConfig));
return null;
case Trim:
return new BlockTrimPack(dataResolver);
@@ -36,6 +36,21 @@ public class PackFactory implements IPackBlockFactory
return null;
}
private static String getConfigName (BlockConfiguration blockConfig) {
if (blockConfig.getDrawerCount() == 1)
return "fullDrawers1";
if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth())
return "fullDrawers2";
if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth())
return "fullDrawers4";
if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth())
return "halfDrawers2";
if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth())
return "halfDrawers4";
return "";
}
@Override
public void registerBlock (Block block, String name) {
if (block instanceof BlockDrawersPack) {