mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 19:59:58 +00:00
Merge pull request #3081 from HenryLoenwind/farmLoaded
Check if chunk is loaded in farming station
This commit is contained in:
commit
fa4afebca2
1 file changed
+10
-8
@@ -2,6 +2,8 @@ package crazypants.enderio.machine.farm;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
@@ -406,13 +408,14 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
clearNotification();
|
||||
}
|
||||
|
||||
BlockCoord bc = getNextCoord();
|
||||
if(bc != null && bc.equals(getLocation())) { //don't try and harvest ourselves
|
||||
BlockCoord bc = null;
|
||||
int infiniteLoop = 20;
|
||||
while (bc == null || bc.equals(getLocation()) || !worldObj.getChunkProvider().chunkExists(bc.x >> 4, bc.z >> 4)) {
|
||||
if (infiniteLoop-- <= 0) {
|
||||
return;
|
||||
}
|
||||
bc = getNextCoord();
|
||||
}
|
||||
if(bc == null) {
|
||||
return;
|
||||
}
|
||||
lastScanned = bc;
|
||||
|
||||
Block block = worldObj.getBlock(bc.x, bc.y, bc.z);
|
||||
@@ -649,14 +652,13 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
|
||||
}
|
||||
|
||||
private BlockCoord getNextCoord() {
|
||||
private @Nonnull BlockCoord getNextCoord() {
|
||||
|
||||
int size = getFarmSize();
|
||||
|
||||
BlockCoord loc = getLocation();
|
||||
if(lastScanned == null) {
|
||||
lastScanned = new BlockCoord(loc.x - size, loc.y, loc.z - size);
|
||||
return lastScanned;
|
||||
return lastScanned = new BlockCoord(loc.x - size, loc.y, loc.z - size);
|
||||
}
|
||||
|
||||
int nextX = lastScanned.x + 1;
|
||||
|
||||
Reference in new issue
Block a user