From c43ba166b3d01be215db849e6171d82c7ce8825f Mon Sep 17 00:00:00 2001 From: Alexander Anishin Date: Fri, 9 Jun 2023 09:22:06 +0300 Subject: [PATCH] Renamed several member for clarity --- .../common/blocks/ParticleGenerator.java | 2 +- .../common/blocks/multiblock/EnergyPylon.java | 2 +- .../blocks/multiblock/EnergyStorageCore.java | 2 +- .../multiblock/InvisibleMultiblock.java | 6 ++-- .../multiblocktiles/TileEnergyPylon.java | 28 +++++++++---------- .../TileEnergyStorageCore.java | 27 +++++++----------- 6 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java index 498669fb..d0893062 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/ParticleGenerator.java @@ -202,7 +202,7 @@ public class ParticleGenerator extends BlockDE { TileParticleGenerator generator = (TileParticleGenerator) tile; if (generator.getMaster() != null) { world.setBlockMetadataWithNotify(x, y, z, 0, 2); - generator.getMaster().isStructureStillValid(true); + generator.getMaster().validateStructure(true); } } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java index 39323cbd..1b5cc157 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyPylon.java @@ -72,7 +72,7 @@ public class EnergyPylon extends BlockDE { // todo fix sphere renderer if (metadata == 1 && side == 1 || metadata == 2 && side == 0) return icon_active_face; TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileEnergyPylon) { - return ((TileEnergyPylon) tile).reciveEnergy ? icon_input : icon_output; + return ((TileEnergyPylon) tile).isReceivingEnergy ? icon_input : icon_output; } return icon_input; } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java index 12d39929..943c8c29 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/EnergyStorageCore.java @@ -103,7 +103,7 @@ public class EnergyStorageCore extends BlockDE implements IHudDisplayBlock { if (tile instanceof TileEnergyStorageCore) { TileEnergyStorageCore core = (TileEnergyStorageCore) tile; if (core.isOnline() && core.getTier() == 0) { - core.isStructureStillValid(false); + core.validateStructure(false); } } } diff --git a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java index c4f88bdd..22a1989c 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/blocks/multiblock/InvisibleMultiblock.java @@ -151,7 +151,7 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock { if (pylon == null) { return false; } - pylon.reciveEnergy = !pylon.reciveEnergy; + pylon.isReceivingEnergy = !pylon.isReceivingEnergy; world.markBlockForUpdate(pylon.xCoord, pylon.yCoord, pylon.zCoord); pylon.onActivated(); return true; @@ -177,7 +177,7 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock { return; } if (core.isOnline()) { - core.isStructureStillValid(core.getTier() == 1); + core.validateStructure(core.getTier() == 1); } else { revertStructure(world, x, y, z); } @@ -196,7 +196,7 @@ public class InvisibleMultiblock extends BlockDE implements IHudDisplayBlock { TileEnergyStorageCore core = multiblock.getMaster(); if (core != null && core.isOnline()) { world.setBlockMetadataWithNotify(x, y, z, 0, 2); - core.isStructureStillValid(core.getTier() == 1); + core.validateStructure(core.getTier() == 1); } } super.breakBlock(world, x, y, z, blockBroken, metadata); diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java index 11729ddd..7d309731 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyPylon.java @@ -34,8 +34,8 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I public boolean active = false; public boolean lastTickActive = false; - public boolean reciveEnergy = false; // Power Flow to system - public boolean lastTickReciveEnergy = false; + public boolean isReceivingEnergy = false; // Power Flow to system + public boolean isReceivedEnergyLastTick = false; public float modelRotation = 0; public float modelScale = 0; private List coreLocations = new ArrayList<>(); @@ -50,9 +50,9 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I if (worldObj.isRemote) { if (active) { modelRotation += 1.5; - modelScale += reciveEnergy ? 0.01F : -0.01F; + modelScale += isReceivingEnergy ? 0.01F : -0.01F; if (modelScale < 0) { - modelScale = reciveEnergy ? 0F : 10000F; + modelScale = isReceivingEnergy ? 0F : 10000F; } spawnParticles(); } else { @@ -74,7 +74,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I } } - if (active && !reciveEnergy) { + if (active && !isReceivingEnergy) { for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = worldObj .getTileEntity(xCoord + side.offsetX, yCoord + side.offsetY, zCoord + side.offsetZ); @@ -181,7 +181,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I double targetY = cYCoord + 0.5; double targetZ = zCoord + 0.5; if (rand.nextFloat() < 0.05F) { - EnergyTransferParticle passiveParticle = reciveEnergy + EnergyTransferParticle passiveParticle = isReceivingEnergy ? new EnergyTransferParticle(worldObj, targetX, targetY, targetZ, sourceX, sourceY, sourceZ, true) : new EnergyTransferParticle(worldObj, sourceX, sourceY, sourceZ, targetX, targetY, targetZ, true); ParticleHandler.spawnCustomParticle(passiveParticle, 35); @@ -193,7 +193,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I sourceX = x + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); sourceY = y + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); sourceZ = z + 0.5 - disMod + (rand.nextFloat() * (disMod * 2)); - EnergyTransferParticle passiveParticle = reciveEnergy + EnergyTransferParticle passiveParticle = isReceivingEnergy ? new EnergyTransferParticle( worldObj, targetX, @@ -232,7 +232,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); active = compound.getBoolean("Active"); - reciveEnergy = compound.getBoolean("Input"); + isReceivingEnergy = compound.getBoolean("Input"); int i = compound.getInteger("Cores"); List list = new ArrayList<>(); for (int j = 0; j < i; j++) { @@ -250,7 +250,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I super.writeToNBT(compound); compound.setBoolean("Active", active); - compound.setBoolean("Input", reciveEnergy); + compound.setBoolean("Input", isReceivingEnergy); int i = coreLocations.size(); compound.setInteger("Cores", i); for (int j = 0; j < i; j++) { @@ -281,7 +281,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I @Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { if (getMaster() == null) return 0; - int received = reciveEnergy ? getMaster().receiveEnergy(maxReceive, simulate) : 0; + int received = isReceivingEnergy ? getMaster().receiveEnergy(maxReceive, simulate) : 0; if (!simulate && received > 0) particleRate = (byte) Math.min(20, received < 500 ? 1 : received / 500); return received; } @@ -289,7 +289,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I @Override public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { if (getMaster() == null || !getMaster().isOnline()) return 0; - int extracted = reciveEnergy ? 0 : getMaster().extractEnergy(maxExtract, simulate); + int extracted = isReceivingEnergy ? 0 : getMaster().extractEnergy(maxExtract, simulate); if (!simulate && extracted > 0) particleRate = (byte) Math.min(20, extracted < 500 ? 1 : extracted / 500); return extracted; } @@ -317,10 +317,10 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I 0, active, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 256)); - if (lastTickReciveEnergy != reciveEnergy) lastTickReciveEnergy = (Boolean) sendObjectToClient( + if (isReceivedEnergyLastTick != isReceivingEnergy) isReceivedEnergyLastTick = (Boolean) sendObjectToClient( References.BOOLEAN_ID, 1, - reciveEnergy, + isReceivingEnergy, new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 256)); if (lastTickParticleRate != particleRate) lastTickParticleRate = (Byte) sendObjectToClient(References.BYTE_ID, 2, particleRate); @@ -334,7 +334,7 @@ public class TileEnergyPylon extends TileObjectSync implements IEnergyHandler, I active = (Boolean) object; break; case 1: - reciveEnergy = (Boolean) object; + isReceivingEnergy = (Boolean) object; break; case 2: particleRate = (Byte) object; diff --git a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java index e14289e6..118a95dd 100644 --- a/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java +++ b/src/main/java/com/brandon3055/draconicevolution/common/tileentities/multiblocktiles/TileEnergyStorageCore.java @@ -62,20 +62,12 @@ public class TileEnergyStorageCore extends TileObjectSync { modelRotation += 0.5; return; } - detectAndRendChanges(); + detectAndSendChanges(); } /** * ######################MultiBlock Methods####################### */ - public boolean tryActivate() { - return tryActivate(false); - } - - public boolean creativeActivate() { - return tryActivate(true); - } - public boolean tryActivate(boolean isCreativeMode) { if (!findStabilizers()) { return false; @@ -99,7 +91,7 @@ public class TileEnergyStorageCore extends TileObjectSync { return false; } - public boolean isStructureStillValid(boolean update) { + public void validateStructure(boolean update) { online = areStabilizersActive() && scanStructure(this::isInnerBlock, this::isOuterBlock); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); if (!online) { @@ -108,7 +100,6 @@ public class TileEnergyStorageCore extends TileObjectSync { reIntegrate(); } } - return online; } private void reIntegrate() { @@ -553,12 +544,14 @@ public class TileEnergyStorageCore extends TileObjectSync { return 40960.0D; } - private void detectAndRendChanges() { - if (lastTickCapacity != energy) lastTickCapacity = (Long) sendObjectToClient( - References.LONG_ID, - 0, - energy, - new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20)); + private void detectAndSendChanges() { + if (lastTickCapacity != energy) { + lastTickCapacity = (long) sendObjectToClient( + References.LONG_ID, + 0, + energy, + new NetworkRegistry.TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 20)); + } } @Override