mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-28 15:36:18 +00:00
Merge remote-tracking branch 'origin/mc-1.12' into dev
This commit is contained in:
commit
934ffde12a
4 files changed
+26
-10
No files matched your search
@@ -228,6 +228,7 @@ public class BeekeepingLogic implements IBeekeepingLogic {
|
||||
}
|
||||
|
||||
hasFlowersCache.update(queen, housing);
|
||||
|
||||
boolean hasFlowers = hasFlowersCache.hasFlowers();
|
||||
boolean flowerCacheNeedsSync = hasFlowersCache.needsSync();
|
||||
errorLogic.setCondition(!hasFlowers, EnumErrorCode.NO_FLOWER);
|
||||
|
||||
@@ -37,10 +37,18 @@ import forestry.core.utils.TickHelper;
|
||||
public class HasFlowersCache implements INbtWritable, INbtReadable {
|
||||
private static final String NBT_KEY = "hasFlowerCache";
|
||||
private static final String NBT_KEY_FLOWERS = "flowers";
|
||||
private static final int FLOWER_CHECK_INTERVAL = 200;
|
||||
private int flowerCheckInterval;
|
||||
|
||||
private final TickHelper tickHelper = new TickHelper();
|
||||
|
||||
public HasFlowersCache() {
|
||||
this.flowerCheckInterval = 200;
|
||||
}
|
||||
|
||||
public HasFlowersCache(int checkInterval) {
|
||||
flowerCheckInterval = checkInterval;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FlowerData flowerData;
|
||||
private final List<BlockPos> flowerCoords = new ArrayList<>();
|
||||
@@ -76,7 +84,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable {
|
||||
World world = beeHousing.getWorldObj();
|
||||
tickHelper.onTick();
|
||||
|
||||
if (!flowerCoords.isEmpty() && tickHelper.updateOnInterval(FLOWER_CHECK_INTERVAL)) {
|
||||
if (!flowerCoords.isEmpty() && tickHelper.updateOnInterval(flowerCheckInterval)) {
|
||||
Iterator<BlockPos> iterator = flowerCoords.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BlockPos flowerPos = iterator.next();
|
||||
@@ -118,7 +126,7 @@ public class HasFlowersCache implements INbtWritable, INbtReadable {
|
||||
IBeeGenome genome = queen.getGenome();
|
||||
String flowerType = genome.getFlowerProvider().getFlowerType();
|
||||
if (!this.flowerData.flowerType.equals(flowerType)
|
||||
|| !this.flowerData.territory.equals(genome.getTerritory())) {
|
||||
|| !this.flowerData.territory.equals(genome.getTerritory())) {
|
||||
flowerData = new FlowerData(queen, housing);
|
||||
flowerCoords.clear();
|
||||
flowers.clear();
|
||||
|
||||
@@ -33,8 +33,9 @@ import forestry.core.utils.TickHelper;
|
||||
|
||||
public class WorldgenBeekeepingLogic implements IBeekeepingLogic {
|
||||
private final TileHive housing;
|
||||
private IBee queen;
|
||||
private IEffectData effectData[] = new IEffectData[2];
|
||||
private final HasFlowersCache hasFlowersCache = new HasFlowersCache();
|
||||
private final HasFlowersCache hasFlowersCache = new HasFlowersCache(2);
|
||||
private final TickHelper tickHelper = new TickHelper();
|
||||
|
||||
// Client
|
||||
@@ -92,10 +93,11 @@ public class WorldgenBeekeepingLogic implements IBeekeepingLogic {
|
||||
public boolean canWork() {
|
||||
tickHelper.onTick();
|
||||
|
||||
IBee queen = housing.getContainedBee();
|
||||
hasFlowersCache.update(queen, housing);
|
||||
|
||||
if (tickHelper.updateOnInterval(200)) {
|
||||
if (queen == null) { //Trying to set this in constructor causes crash
|
||||
queen = housing.getContainedBee();
|
||||
}
|
||||
hasFlowersCache.update(queen, housing);
|
||||
World world = housing.getWorldObj();
|
||||
boolean canWork = (world.isDaytime() || queen.getGenome().getNeverSleeps()) &&
|
||||
(!housing.isRaining() || queen.getGenome().getToleratesRain());
|
||||
|
||||
Reference in new issue
Block a user