Fix #1993, Fix #1972 Managed Succulent Farm doesn't work and Farm multiblock causing chunks to be loaded

This commit is contained in:
Nedelosk committed 2018-02-16 17:07:40 +01:00
1 parent 424bc8910d
commit 355ba9a7ed
14 files changed
+54 -12

No files matched your search

@@ -136,11 +136,7 @@ public class FarmHelper {
targetLocation = targetLocation.offset(farmSide.getFacing());
BlockPos groundLocation = new BlockPos(targetLocation.getX(), groundHeight, targetLocation.getZ());
if (!world.isBlockLoaded(groundLocation)) {
break;
}
if (!farmHousing.isValidPlatform(world, groundLocation)) {
if (!world.isBlockLoaded(groundLocation) || !farmHousing.isValidPlatform(world, groundLocation)) {
break;
}
@@ -164,7 +160,7 @@ public class FarmHelper {
for (int yOffset = 2; yOffset > -4; yOffset--) {
BlockPos position = targetPosition.add(0, yOffset, 0);
if (farmHousing.isValidPlatform(world, position)) {
if (world.isBlockLoaded(position) && farmHousing.isValidPlatform(world, position)) {
return position;
}
}
@@ -195,7 +195,7 @@ public class ModuleFarming extends BlankForestryModule {
IFarmProperties arborealFarm = registry.registerLogic("farmArboreal", FarmLogicArboreal::new);
IFarmProperties cropsFarm = registry.registerLogic("farmCrops", FarmLogicCrops::new);
IFarmProperties mushroomFarm = registry.registerLogic("farmShroom", FarmLogicMushroom::new);
IFarmProperties succulentFarm = registry.registerLogic("farmSucculent", FarmLogicSucculent::new);
IFarmProperties succulentFarm = registry.registerLogic("farmSucculentes", FarmLogicSucculent::new);
IFarmProperties peatFarm = registry.registerLogic("farmPeat", FarmLogicPeat::new);
IFarmProperties infernalFarm = registry.registerLogic("farmInfernal", FarmLogicInfernal::new);
IFarmProperties poalesFarm = registry.registerLogic("farmPoales", FarmLogicReeds::new);
@@ -82,7 +82,7 @@ public abstract class FarmLogic implements IFarmLogic {
@Nullable
protected ICrop getCrop(World world, BlockPos position) {
if (world.isAirBlock(position)) {
if (!world.isBlockLoaded(position) || world.isAirBlock(position)) {
return null;
}
IBlockState blockState = world.getBlockState(position);
@@ -98,6 +98,9 @@ public abstract class FarmLogic implements IFarmLogic {
public abstract boolean isAcceptedWindfall(ItemStack stack);
protected final boolean isWaterSourceBlock(World world, BlockPos position) {
if(!world.isBlockLoaded(position)){
return false;
}
IBlockState blockState = world.getBlockState(position);
Block block = blockState.getBlock();
return block == Blocks.WATER;
@@ -116,6 +116,10 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
while (!knownCropPositions.empty()) {
BlockPos knownCropPos = knownCropPositions.pop();
for (BlockPos candidate : BlockPos.getAllInBox(knownCropPos.add(-1, -1, -1), knownCropPos.add(1, 1, 1))) {
if(!world.isBlockLoaded(candidate)){
return crops;
}
if (!checkedBlocks.contains(candidate)) {
checkedBlocks.add(candidate);
@@ -134,7 +134,7 @@ public class FarmLogicCocoa extends FarmLogic {
while (isJungleTreeTrunk(blockState)) {
for (EnumFacing direction : EnumFacing.HORIZONTALS) {
BlockPos candidate = new BlockPos(current.getX() + direction.getFrontOffsetX(), current.getY(), current.getZ() + direction.getFrontOffsetZ());
if (world.isAirBlock(candidate)) {
if (world.isBlockLoaded(candidate) && world.isAirBlock(candidate)) {
return farmHousing.plantGermling(cocoa, world, candidate, farmDirection);
}
}
@@ -214,6 +214,10 @@ public class FarmLogicCocoa extends FarmLogic {
continue;
}
if(!world.isBlockLoaded(candidate)){
continue;
}
IBlockState blockState = world.getBlockState(candidate);
ICrop crop = cocoa.getCropAt(world, candidate, blockState);
if (crop != null) {
@@ -60,6 +60,10 @@ public class FarmLogicCrops extends FarmLogicWatered {
protected boolean maintainCrops(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos, direction, i);
if(!world.isBlockLoaded(position)){
break;
}
IBlockState state = world.getBlockState(position);
if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(state, world, position)) {
continue;
@@ -85,7 +85,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous {
}
private Collection<ICrop> harvestBlocks(World world, BlockPos position) {
if (world.isAirBlock(position)) {
if (!world.isBlockLoaded(position) || world.isAirBlock(position)) {
return Collections.emptySet();
}
@@ -81,7 +81,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogicSoil {
BlockPos position = translateWithOffset(pos, direction, i);
IBlockState soilState = world.getBlockState(position);
if (farmHousing.isValidPlatform(world, pos)) {
if (!world.isBlockLoaded(position) || farmHousing.isValidPlatform(world, pos)) {
break;
}
@@ -63,6 +63,9 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos.up(), direction, i);
if(!world.isBlockLoaded(position)){
break;
}
if (world.isAirBlock(pos)) {
continue;
}
@@ -84,6 +87,10 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous {
protected boolean maintainGermlings(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos, direction, i);
if(!world.isBlockLoaded(position)){
break;
}
IBlockState blockState = world.getBlockState(position);
if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(blockState, world, position)) {
continue;
@@ -15,6 +15,7 @@ import com.google.common.collect.ImmutableList;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -134,6 +135,10 @@ public class FarmLogicOrchard extends FarmLogic {
Set<BlockPos> seen = new HashSet<>();
Stack<ICrop> crops = new Stack<>();
if(!world.isBlockLoaded(position)){
return Collections.emptyList();
}
// Determine what type we want to harvest.
IBlockState blockState = world.getBlockState(position);
Block block = blockState.getBlock();
@@ -174,7 +179,7 @@ public class FarmLogicOrchard extends FarmLogic {
if (seen.contains(candidate)) {
continue;
}
if (world.isAirBlock(candidate)) {
if (!world.isBlockLoaded(candidate) || world.isAirBlock(candidate)) {
continue;
}
@@ -56,6 +56,9 @@ public class FarmLogicPeat extends FarmLogicWatered {
Stack<ICrop> crops = new Stack<>();
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos, direction, i);
if(!world.isBlockLoaded(position)){
return crops;
}
IBlockState blockState = world.getBlockState(position);
Block block = blockState.getBlock();
if (!(block instanceof BlockBogEarth)) {
@@ -57,6 +57,10 @@ public class FarmLogicRedOrchid extends FarmLogicHomogeneous {
protected boolean maintainGermlings(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) {
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos, direction, i);
if(!world.isBlockLoaded(position)){
break;
}
IBlockState state = world.getBlockState(position);
if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(state, world, position)) {
continue;
@@ -119,6 +119,10 @@ public class FarmLogicRubber extends FarmLogic {
for (int j = 0; j < 10; j++) {
BlockPos candidate = position.add(0, j, 0);
if(!world.isBlockLoaded(candidate)){
return crops;
}
IBlockState blockState = world.getBlockState(candidate);
Block block = blockState.getBlock();
if (!ItemStackUtil.equals(block, PluginIC2.rubberWood)) {
@@ -78,6 +78,10 @@ public abstract class FarmLogicWatered extends FarmLogicSoil {
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos, direction, i);
if(!world.isBlockLoaded(position)){
break;
}
IBlockState state = world.getBlockState(position);
if (isAcceptedSoil(state) || isWaterSourceBlock(world, position) || !farmHousing.getFarmInventory().hasResources(resources)) {
continue;
@@ -112,6 +116,10 @@ public abstract class FarmLogicWatered extends FarmLogicSoil {
for (int i = 0; i < extent; i++) {
BlockPos position = translateWithOffset(pos, direction, i);
if(!world.isBlockLoaded(position)){
break;
}
BlockPos platformPosition = position.down();
if (!farmHousing.isValidPlatform(world, platformPosition)) {
break;