Smeltery Airblock cleanup

This commit is contained in:
mDiyo 2013-06-17 13:12:19 -07:00
parent f3191318f0
commit 8e5f78aebf
3 changed files with 59 additions and 66 deletions

4
mods/herp.ahk Normal file
View File

@ -0,0 +1,4 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.

View File

@ -381,15 +381,15 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z)) if (!worldObj.blockExists(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z))
{ {
fuelGague = 0; fuelGague = 0;
return; return;
} }
TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z); TileEntity tankContainer = worldObj.getBlockTileEntity(activeLavaTank.x, activeLavaTank.y, activeLavaTank.z);
if (tankContainer == null) if (tankContainer == null)
{ {
fuelGague = 0; fuelGague = 0;
return; return;
} }
if (tankContainer instanceof ITankContainer) if (tankContainer instanceof ITankContainer)
{ {
@ -505,48 +505,38 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
int southID = worldObj.getBlockId(x, y, z - 1); int southID = worldObj.getBlockId(x, y, z - 1);
int eastID = worldObj.getBlockId(x + 1, y, z); int eastID = worldObj.getBlockId(x + 1, y, z);
int westID = worldObj.getBlockId(x - 1, y, z); int westID = worldObj.getBlockId(x - 1, y, z);
Block northBlock = Block.blocksList[northID]; Block northBlock = Block.blocksList[northID];
Block southBlock = Block.blocksList[southID]; Block southBlock = Block.blocksList[southID];
Block eastBlock = Block.blocksList[eastID]; Block eastBlock = Block.blocksList[eastID];
Block westBlock = Block.blocksList[westID]; Block westBlock = Block.blocksList[westID];
if ( (northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1))
(southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) && && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)))
(eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) &&
(westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)) )
{ {
checkValidStructure(x, y, z); checkValidStructure(x, y, z);
} }
else if ( (northBlock != null && !northBlock.isAirBlock(worldObj, x, y, z + 1)) && else if ((northBlock != null && !northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1))
(southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) && && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)))
(eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) &&
(westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)) )
{ {
checkValidStructure(x, y, z - 1); checkValidStructure(x, y, z - 1);
} }
else if ( (northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && else if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock != null && !southBlock.isAirBlock(worldObj, x, y, z - 1))
(southBlock != null && !southBlock.isAirBlock(worldObj, x, y, z - 1)) && && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)))
(eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) &&
(westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)) )
{ {
checkValidStructure(x, y, z + 1); checkValidStructure(x, y, z + 1);
} }
else if ( (northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && else if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1))
(southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) && && (eastBlock != null && !eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)))
(eastBlock != null && !eastBlock.isAirBlock(worldObj, x + 1, y, z)) &&
(westBlock == null || westBlock.isAirBlock(worldObj, x - 1, y, z)) )
{ {
checkValidStructure(x - 1, y, z); checkValidStructure(x - 1, y, z);
} }
else if ( (northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && else if ((northBlock == null || northBlock.isAirBlock(worldObj, x, y, z + 1)) && (southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1))
(southBlock == null || southBlock.isAirBlock(worldObj, x, y, z - 1)) && && (eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) && (westBlock != null && !westBlock.isAirBlock(worldObj, x - 1, y, z)))
(eastBlock == null || eastBlock.isAirBlock(worldObj, x + 1, y, z)) &&
(westBlock != null && !westBlock.isAirBlock(worldObj, x - 1, y, z)) )
{ {
checkValidStructure(x + 1, y, z); checkValidStructure(x + 1, y, z);
} }
@ -589,7 +579,6 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
{ {
numBricks = 0; numBricks = 0;
lavaTanks.clear(); lavaTanks.clear();
boolean hasLavaTank = false;
Block block; Block block;
//Check inside //Check inside
@ -606,21 +595,17 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
//Check outer layer //Check outer layer
for (int xPos = x - 1; xPos <= x + 1; xPos++) for (int xPos = x - 1; xPos <= x + 1; xPos++)
{ {
if (checkBricks(xPos, y, z - 2)) numBricks += checkBricks(xPos, y, z - 2);
hasLavaTank = true; numBricks += checkBricks(xPos, y, z + 2);
if (checkBricks(xPos, y, z + 2))
hasLavaTank = true;
} }
for (int zPos = z - 1; zPos <= z + 1; zPos++) for (int zPos = z - 1; zPos <= z + 1; zPos++)
{ {
if (checkBricks(x - 2, y, zPos)) numBricks += checkBricks(x - 2, y, zPos);
hasLavaTank = true; numBricks += checkBricks(x + 2, y, zPos);
if (checkBricks(x + 2, y, zPos))
hasLavaTank = true;
} }
if (numBricks == 12 && hasLavaTank) if (numBricks == 12 && lavaTanks.size() > 0)
return true; return true;
else else
return false; return false;
@ -634,8 +619,8 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
{ {
for (int zPos = z - 1; zPos <= z + 1; zPos++) for (int zPos = z - 1; zPos <= z + 1; zPos++)
{ {
Block block = Block.blocksList[worldObj.getBlockId(xPos, y, zPos)]; Block block = Block.blocksList[worldObj.getBlockId(xPos, y, zPos)];
if (block != null && block.isAirBlock(worldObj, xPos, y, zPos)) if (block != null && !block.isAirBlock(worldObj, xPos, y, zPos))
return count; return count;
} }
} }
@ -643,14 +628,14 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
//Check outer layer //Check outer layer
for (int xPos = x - 1; xPos <= x + 1; xPos++) for (int xPos = x - 1; xPos <= x + 1; xPos++)
{ {
checkBricks(xPos, y, z - 2); numBricks += checkBricks(xPos, y, z - 2);
checkBricks(xPos, y, z + 2); numBricks += checkBricks(xPos, y, z + 2);
} }
for (int zPos = z - 1; zPos <= z + 1; zPos++) for (int zPos = z - 1; zPos <= z + 1; zPos++)
{ {
checkBricks(x - 2, y, zPos); numBricks += checkBricks(x - 2, y, zPos);
checkBricks(x + 2, y, zPos); numBricks += checkBricks(x + 2, y, zPos);
} }
if (numBricks != 12) if (numBricks != 12)
@ -683,14 +668,14 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
//Check outer layer //Check outer layer
for (int xPos = x - 1; xPos <= x + 1; xPos++) for (int xPos = x - 1; xPos <= x + 1; xPos++)
{ {
checkBricks(xPos, y, z - 2); numBricks += checkBricks(xPos, y, z - 2);
checkBricks(xPos, y, z + 2); numBricks += checkBricks(xPos, y, z + 2);
} }
for (int zPos = z - 1; zPos <= z + 1; zPos++) for (int zPos = z - 1; zPos <= z + 1; zPos++)
{ {
checkBricks(x - 2, y, zPos); numBricks += checkBricks(x - 2, y, zPos);
checkBricks(x + 2, y, zPos); numBricks += checkBricks(x + 2, y, zPos);
} }
if (numBricks != 12) if (numBricks != 12)
@ -720,16 +705,19 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
return count; return count;
} }
boolean checkBricks (int x, int y, int z) /* Returns whether the brick is a lava tank or not.
* Increments bricks, sets them as part of the structure, and adds tanks to the list.
*/
int checkBricks (int x, int y, int z)
{ {
int tempBricks = 0;
int blockID = worldObj.getBlockId(x, y, z); int blockID = worldObj.getBlockId(x, y, z);
if (blockID == TContent.smeltery.blockID || blockID == TContent.lavaTank.blockID) if (blockID == TContent.smeltery.blockID || blockID == TContent.lavaTank.blockID)
{ {
TileEntity te = worldObj.getBlockTileEntity(x, y, z); TileEntity te = worldObj.getBlockTileEntity(x, y, z);
if (te == this) if (te == this)
{ {
numBricks++; tempBricks++;
return false;
} }
else if (te instanceof MultiServantLogic) else if (te instanceof MultiServantLogic)
{ {
@ -737,21 +725,20 @@ public class SmelteryLogic extends InventoryLogic implements IActiveLogic, IFaci
if (servant.hasValidMaster()) if (servant.hasValidMaster())
{ {
if (servant.verifyMaster(this.xCoord, this.yCoord, this.zCoord)) if (servant.verifyMaster(this.xCoord, this.yCoord, this.zCoord))
numBricks++; tempBricks++;
} }
else if (servant.setMaster(this.xCoord, this.yCoord, this.zCoord)) else if (servant.setMaster(this.xCoord, this.yCoord, this.zCoord))
{ {
numBricks++; tempBricks++;
} }
if (te instanceof LavaTankLogic) if (te instanceof LavaTankLogic)
{ {
lavaTanks.add(new CoordTuple(x, y, z)); lavaTanks.add(new CoordTuple(x, y, z));
return true;
} }
} }
} }
return false; return tempBricks;
} }
public int getCapacity () public int getCapacity ()

View File

@ -27,7 +27,7 @@ public class SmelteryRender implements ISimpleBlockRenderingHandler
{ {
if (modelID == smelteryModel) if (modelID == smelteryModel)
{ {
TProxyClient.renderStandardInvBlock(renderer, block, metadata); TProxyClient.renderStandardInvBlock(renderer, block, metadata);
} }
} }
@ -137,20 +137,22 @@ public class SmelteryRender implements ISimpleBlockRenderingHandler
if (input != null && logic.getTempForSlot(i + start) > 20) if (input != null && logic.getTempForSlot(i + start) > 20)
{ {
ItemStack blockToRender = Smeltery.getRenderIndex(input); ItemStack blockToRender = Smeltery.getRenderIndex(input);
float blockHeight = input.stackSize / (float) blockToRender.stackSize; if (blockToRender != null)
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, MathHelper.clamp_float(blockHeight, 0.01F, 1.0F), 1.0F); {
float blockHeight = input.stackSize / (float) blockToRender.stackSize;
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, MathHelper.clamp_float(blockHeight, 0.01F, 1.0F), 1.0F);
if (blockToRender.itemID < 4096) //Block if (blockToRender.itemID < 4096) //Block
{ {
Block liquidBlock = Block.blocksList[blockToRender.itemID]; Block liquidBlock = Block.blocksList[blockToRender.itemID];
BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, blockToRender.getItemDamage(), posX + i % 3, posY, posZ + i / 3, renderer, world); BlockSkinRenderHelper.renderMetadataBlock(liquidBlock, blockToRender.getItemDamage(), posX + i % 3, posY, posZ + i / 3, renderer, world);
} }
else else //Item
//Item {
{ Item liquidItem = Item.itemsList[blockToRender.itemID];
Item liquidItem = Item.itemsList[blockToRender.itemID]; int metadata = blockToRender.getItemDamage();
int metadata = blockToRender.getItemDamage(); BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(metadata), posX + i % 3, posY, posZ + i / 3, renderer, world);
BlockSkinRenderHelper.renderFakeBlock(liquidItem.getIconFromDamage(metadata), posX + i % 3, posY, posZ + i / 3, renderer, world); }
} }
} }
} }