Fix 2509; reviewed all ticking entities to ensure consistency in checks (#2510)

This commit is contained in:
Dave Smith 2021-09-19 16:48:41 -06:00 committed by GitHub
parent 42f0d5ce42
commit 7d85960a4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 37 additions and 50 deletions

View file

@ -79,17 +79,12 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
if (world == null || world.isClient) {
return;
}
ticksSinceLastChange++;
if (world.isClient) {
return;
}
// Check cells input slot 2 time per second
if (ticksSinceLastChange >= 10) {
ItemStack inputStack = inventory.getStack(0);

View file

@ -56,8 +56,7 @@ public class LightningRodBlockEntity extends PowerAcceptorBlockEntity implements
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null){
if (world == null || world.isClient){
return;
}

View file

@ -148,12 +148,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
}
if (world.isClient) {
if (world == null || world.isClient) {
return;
}

View file

@ -65,23 +65,20 @@ public class DragonEggSyphonBlockEntity extends PowerAcceptorBlockEntity
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
if (world == null || world.isClient) {
return;
}
if (!world.isClient) {
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
.getBlock() == Blocks.DRAGON_EGG) {
if (tryAddingEnergy(TechRebornConfig.dragonEggSyphonEnergyPerTick))
lastOutput = world.getTime();
}
if (world.getBlockState(new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ()))
.getBlock() == Blocks.DRAGON_EGG) {
if (tryAddingEnergy(TechRebornConfig.dragonEggSyphonEnergyPerTick))
lastOutput = world.getTime();
}
if (world.getTime() - lastOutput < 30 && !isActive()) {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
} else if (world.getTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
}
if (world.getTime() - lastOutput < 30 && !isActive()) {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, true));
} else if (world.getTime() - lastOutput > 30 && isActive()) {
world.setBlockState(pos, world.getBlockState(pos).with(BlockMachineBase.ACTIVE, false));
}
}

View file

@ -56,7 +56,7 @@ public class DrainBlockEntity extends MachineBaseBlockEntity {
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
if (world == null || world.isClient) {
return;
}

View file

@ -75,12 +75,14 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
// TileGenericMachine
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null){
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient){
return;
}
ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (!world.isClient && ticksSinceLastChange >= 10) {
if (ticksSinceLastChange >= 10) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.fillContainers(tank, inventory, 1, 2);
if (tank.isEmpty()){
@ -90,8 +92,6 @@ public class FluidReplicatorBlockEntity extends GenericMachineBlockEntity implem
}
ticksSinceLastChange = 0;
}
super.tick(world, pos, state, blockEntity);
}
@Override

View file

@ -78,20 +78,20 @@ public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity impl
// TilePowerAcceptor
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null){
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient){
return;
}
ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (!world.isClient && ticksSinceLastChange >= 10) {
if (ticksSinceLastChange >= 10) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.drainContainers(tank, inventory, 1, 6);
FluidUtils.fillContainers(tank, inventory, 1, 6);
}
ticksSinceLastChange = 0;
}
super.tick(world, pos, state, blockEntity);
}
@Override

View file

@ -78,21 +78,20 @@ public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity impl
// TileGenericMachine
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
if (world == null) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
}
ticksSinceLastChange++;
// Check cells input slot 2 time per second
if (!world.isClient && ticksSinceLastChange >= 10) {
if (ticksSinceLastChange >= 10) {
if (!inventory.getStack(1).isEmpty()) {
FluidUtils.drainContainers(tank, inventory, 1, 5);
FluidUtils.fillContainers(tank, inventory, 1, 5);
}
ticksSinceLastChange = 0;
}
super.tick(world, pos, state, blockEntity);
}
// TilePowerAcceptor

View file

@ -105,7 +105,7 @@ public class RollingMachineBlockEntity extends PowerAcceptorBlockEntity
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
if (world == null || world.isClient) {
return;
}
charge(10);

View file

@ -114,10 +114,10 @@ public class MatterFabricatorBlockEntity extends PowerAcceptorBlockEntity
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
if (world == null || world.isClient) {
return;
}
this.charge(11);
for (int i = 0; i < 6; i++) {

View file

@ -92,7 +92,7 @@ public class AdjustableSUBlockEntity extends EnergyStorageBlockEntity implements
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
if (world == null || world.isClient) {
return;
}

View file

@ -69,12 +69,10 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity implement
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null) {
return;
}
if (world.isClient) {
if (world == null || world.isClient) {
return;
}
if (!inventory.getStack(0).isEmpty()) {
discharge(0);
}

View file

@ -88,6 +88,10 @@ public class LSUStorageBlockEntity extends MachineBaseBlockEntity
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world == null || world.isClient) {
return;
}
if (network == null) {
findAndJoinNetwork(world, pos);
} else {

View file

@ -101,7 +101,7 @@ public class LapotronicSUBlockEntity extends EnergyStorageBlockEntity implements
@Override
public void tick(World world, BlockPos pos, BlockState state, MachineBaseBlockEntity blockEntity) {
super.tick(world, pos, state, blockEntity);
if (world.isClient) {
if (world == null || world.isClient) {
return;
}