Greenhouse Controller try harvest/grow blocks in order instead of at random + growth fix (#2420). Thanks to trobol

* Greenhouse Controller try harvest/grow blocks in order
* fix greenhouse growth acceleration
This commit is contained in:
Thornton Fernbacher 2021-06-29 04:19:52 -04:00 committed by GitHub
parent 5390cbfe2e
commit 85d69faec7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,6 +60,10 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
private BlockPos multiblockCenter;
private int ticksToNextMultiblockCheck = 0;
private boolean growthBoost = false;
private int workingIndex = 0;
// number of blocks from center
private int range = 4;
public GreenhouseControllerBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.GREENHOUSE_CONTROLLER, pos, state);
@ -69,7 +73,14 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
if (world == null){
return;
}
BlockPos blockPos = multiblockCenter.add(world.random.nextInt(9) - 4, 0, world.random.nextInt(9) - 4);
int size = range * 2 + 1;
int offsetX = workingIndex % size;
int offsetZ = workingIndex / size;
BlockPos corner = multiblockCenter.add(-range, 0, -range);
BlockPos blockPos = corner.add(offsetX, 0, offsetZ);
workingIndex = (workingIndex + 1) % (size * size);
BlockState blockState = world.getBlockState(blockPos);
Block block = blockState.getBlock();
@ -81,7 +92,7 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
) {
if (getStored(EnergySide.UNKNOWN) > TechRebornConfig.greenhouseControllerEnergyPerBonemeal) {
useEnergy(TechRebornConfig.greenhouseControllerEnergyPerBonemeal);
blockState.scheduledTick((ServerWorld) world, blockPos, world.random);
blockState.randomTick((ServerWorld) world, blockPos, world.random);
}
}
}
@ -189,8 +200,9 @@ public class GreenhouseControllerBlockEntity extends PowerAcceptorBlockEntity
return;
}
if (multiblockCenter == null) {
multiblockCenter = pos.offset(getFacing().getOpposite(), 5);
multiblockCenter = pos.offset(getFacing().getOpposite(), range + 1);
}
charge(6);
super.tick(world, pos, state, blockEntity);