mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Capacitor Bank fill bars are now automatically extended when placing new blocks.
This commit is contained in:
1 parent
fb7620be02
commit
99e1fac73b
2 files changed
+32
-6
No files matched your search
@@ -355,12 +355,10 @@ public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTool
|
||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, x, y, z, player, stack);
|
||||
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof TileCapBank)) {
|
||||
TileCapBank cb = getTileEntity(world, x, y, z);
|
||||
if(cb == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
TileCapBank cb = (TileCapBank) te;
|
||||
if(stack.stackTagCompound != null) {
|
||||
cb.readCommonNBT(stack.stackTagCompound);
|
||||
}
|
||||
@@ -370,6 +368,13 @@ public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTool
|
||||
int heading = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
|
||||
ForgeDirection dir = getDirForHeading(heading);
|
||||
cb.setDisplayType(dir, InfoDisplayType.LEVEL_BAR);
|
||||
} else {
|
||||
boolean modifiedDisplayType = false;
|
||||
modifiedDisplayType = setDisplayToVerticalFillBar(cb, getTileEntity(world, x, y - 1, z));
|
||||
modifiedDisplayType |= setDisplayToVerticalFillBar(cb, getTileEntity(world, x, y + 1, z));
|
||||
if(modifiedDisplayType) {
|
||||
cb.validateDisplayTypes();
|
||||
}
|
||||
}
|
||||
|
||||
if(world.isRemote) {
|
||||
@@ -378,6 +383,27 @@ public class BlockCapBank extends BlockEio implements IGuiHandler, IAdvancedTool
|
||||
world.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
|
||||
protected boolean setDisplayToVerticalFillBar(TileCapBank cb, TileCapBank capBank) {
|
||||
boolean modifiedDisplayType = false;
|
||||
if(capBank != null) {
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if(dir.offsetY == 0 && capBank.getDisplayType(dir) == InfoDisplayType.LEVEL_BAR && capBank.getType() == cb.getType()) {
|
||||
cb.setDisplayType(dir, InfoDisplayType.LEVEL_BAR);
|
||||
modifiedDisplayType = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return modifiedDisplayType;
|
||||
}
|
||||
|
||||
private TileCapBank getTileEntity(World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileCapBank) {
|
||||
return (TileCapBank) te;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ForgeDirection getDirForHeading(int heading) {
|
||||
switch (heading) {
|
||||
case 0:
|
||||
|
||||
@@ -193,7 +193,7 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerReceptor
|
||||
updateReceptors();
|
||||
}
|
||||
if(revalidateDisplayTypes) {
|
||||
checkDisplayTypesValid();
|
||||
validateDisplayTypes();
|
||||
revalidateDisplayTypes = false;
|
||||
}
|
||||
if(displayTypesDirty) {
|
||||
@@ -343,7 +343,7 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerReceptor
|
||||
displayTypesDirty = markDirty;
|
||||
}
|
||||
|
||||
private void checkDisplayTypesValid() {
|
||||
public void validateDisplayTypes() {
|
||||
if(faceDisplayTypes == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user