mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-26 06:43:05 +00:00
Clean Up Greenhouse Climate
This commit is contained in:
1 parent
d48e9484b8
commit
e07f10d981
15 files changed
+104
-184
No files matched your search
@@ -10,7 +10,7 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public interface IGreenhouseListener {
|
||||
|
||||
/**
|
||||
* Called before the greenhouse update the climate system.
|
||||
* Called before the greenhouse updates the climate system.
|
||||
*
|
||||
* @param greenhouse The greenhouse of the listener.
|
||||
* @param canWork The actual {@link Boolean} value.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import forestry.api.greenhouse.IClimateHousing;
|
||||
import forestry.greenhouse.api.climate.IClimateContainer;
|
||||
import forestry.greenhouse.api.climate.IClimateFactory;
|
||||
import forestry.api.greenhouse.IClimateHousing;
|
||||
import forestry.greenhouse.climate.ClimateContainer;
|
||||
|
||||
public class ClimateFactory implements IClimateFactory{
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
|
||||
// Ticks
|
||||
private static final Random rand = new Random();
|
||||
//TODO: Use TickHelper
|
||||
private int tickCount = rand.nextInt(256);
|
||||
|
||||
// Disassembled -> Assembled; Assembled -> Disassembled OR Paused; Paused -> Assembled
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.greenhouse.IClimateHousing;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.core.climate.ClimateContainer;
|
||||
import forestry.core.multiblock.MultiblockUtil;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketClient;
|
||||
@@ -26,6 +25,7 @@ import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import forestry.core.network.PacketIdClient;
|
||||
import forestry.greenhouse.api.climate.IClimateContainer;
|
||||
import forestry.greenhouse.climate.ClimateContainer;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
|
||||
public class PacketUpdateClimate extends ForestryPacket implements IForestryPacketClient {
|
||||
|
||||
@@ -18,10 +18,10 @@ import java.util.Map;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseLogicFactory;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseHelper;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseLogicFactory;
|
||||
|
||||
public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.api.climate;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -36,21 +34,6 @@ public interface IClimateContainer extends INbtReadable, INbtWritable, IClimateS
|
||||
*/
|
||||
void updateClimate(int ticks);
|
||||
|
||||
/**
|
||||
* Add a listener to this container.
|
||||
*/
|
||||
void addListener(IClimateContainerListener listener);
|
||||
|
||||
/**
|
||||
* Remove a listener to this container.
|
||||
*/
|
||||
void removeListener(IClimateContainerListener listener);
|
||||
|
||||
/**
|
||||
* All listeners of this container.
|
||||
*/
|
||||
Collection<IClimateContainerListener> getListeners();
|
||||
|
||||
/**
|
||||
* @return only not present if the controller never was assembled.
|
||||
*/
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.api.climate;
|
||||
|
||||
public interface IClimateContainerListener {
|
||||
|
||||
/**
|
||||
* Test if the container is closed.
|
||||
*/
|
||||
boolean isClosed(IClimateContainer container);
|
||||
|
||||
}
|
||||
@@ -40,8 +40,13 @@ public interface IClimateSourceContainer {
|
||||
IClimateState getBoundaryDown();
|
||||
|
||||
/**
|
||||
* Has to be called if any range of a {@link IClimateSource} changes. It calculates the range of all {@link IClimateSource}s together.
|
||||
* Calculates the range of all {@link IClimateSource}s together.
|
||||
*/
|
||||
void recalculateBoundaries(double sizeModifier);
|
||||
|
||||
/**
|
||||
* @return True if the container allows the {@link IClimateSource}s to work.
|
||||
*/
|
||||
boolean canWork();
|
||||
|
||||
}
|
||||
@@ -9,8 +9,6 @@ import java.util.Collection;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseLogicFactory;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
public interface IGreenhouseHelper {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
package forestry.greenhouse.api.greenhouse;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
package forestry.greenhouse.api.greenhouse;
|
||||
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
+22
-87
@@ -8,14 +8,13 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.climate;
|
||||
package forestry.greenhouse.climate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -29,23 +28,23 @@ import forestry.api.climate.ClimateType;
|
||||
import forestry.api.climate.IClimateState;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.greenhouse.IClimateHousing;
|
||||
import forestry.core.climate.AbsentClimateState;
|
||||
import forestry.core.climate.ClimateData;
|
||||
import forestry.core.climate.ClimateState;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import forestry.core.network.packets.PacketUpdateClimate;
|
||||
import forestry.core.utils.NetworkUtil;
|
||||
import forestry.greenhouse.api.climate.IClimateContainer;
|
||||
import forestry.greenhouse.api.climate.IClimateContainerListener;
|
||||
import forestry.greenhouse.api.climate.IClimateData;
|
||||
import forestry.greenhouse.api.climate.IClimateModifier;
|
||||
import forestry.greenhouse.api.climate.IClimateSource;
|
||||
import forestry.greenhouse.climate.GreenhouseClimateManager;
|
||||
|
||||
public class ClimateContainer implements IClimateContainer, IStreamable {
|
||||
public static final float CLIMATE_CHANGE = 0.01F;
|
||||
|
||||
protected final IClimateHousing parent;
|
||||
protected final ClimateContainerListeners listeners;
|
||||
protected final Set<IClimateSource> sources;
|
||||
protected final Supplier<Boolean> canWork;
|
||||
private int delay;
|
||||
protected IClimateState state;
|
||||
protected IClimateState targetedState;
|
||||
@@ -57,8 +56,11 @@ public class ClimateContainer implements IClimateContainer, IStreamable {
|
||||
* Creates an empty region.
|
||||
*/
|
||||
public ClimateContainer(IClimateHousing parent) {
|
||||
this(parent, () -> true);
|
||||
}
|
||||
|
||||
public ClimateContainer(IClimateHousing parent, Supplier<Boolean> canWork) {
|
||||
this.parent = parent;
|
||||
this.listeners = new ClimateContainerListeners();
|
||||
this.sources = new HashSet<>();
|
||||
this.delay = 20;
|
||||
this.state = parent.getDefaultClimate().toState(ClimateStateType.MUTABLE);
|
||||
@@ -66,11 +68,7 @@ public class ClimateContainer implements IClimateContainer, IStreamable {
|
||||
this.boundaryUp = ClimateState.MIN;
|
||||
this.boundaryDown = ClimateState.MIN;
|
||||
this.targetedState = AbsentClimateState.INSTANCE;
|
||||
}
|
||||
|
||||
public ClimateContainer(IClimateHousing parent, NBTTagCompound nbtTag) {
|
||||
this(parent);
|
||||
readFromNBT(nbtTag);
|
||||
this.canWork = canWork;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,41 +79,15 @@ public class ClimateContainer implements IClimateContainer, IStreamable {
|
||||
@Override
|
||||
public void updateClimate(int ticks) {
|
||||
if (ticks % getTickDelay() == 0) {
|
||||
if(!listeners.isClosed(this)) {
|
||||
returnClimateToDefault();
|
||||
}else{
|
||||
IClimateState oldState = state.toState(ClimateStateType.IMMUTABLE);
|
||||
state = parent.getDefaultClimate().toState(ClimateStateType.CHANGE);
|
||||
for(IClimateModifier modifier : GreenhouseClimateManager.getInstance().getModifiers()){
|
||||
state = modifier.modifyTarget(this, state, oldState, modifierData).toState(ClimateStateType.CHANGE);
|
||||
}
|
||||
state = state.toState(ClimateStateType.MUTABLE);
|
||||
if(!state.equals(oldState)) {
|
||||
BlockPos coordinates = parent.getCoordinates();
|
||||
NetworkUtil.sendNetworkPacket(new PacketUpdateClimate(coordinates, this), coordinates, parent.getWorldObj());
|
||||
}
|
||||
IClimateState oldState = state.toState(ClimateStateType.IMMUTABLE);
|
||||
state = parent.getDefaultClimate().toState(ClimateStateType.CHANGE);
|
||||
for (IClimateModifier modifier : GreenhouseClimateManager.getInstance().getModifiers()) {
|
||||
state = modifier.modifyTarget(this, state, oldState, modifierData).toState(ClimateStateType.CHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void returnClimateToDefault(){
|
||||
IClimateState defaultState = parent.getDefaultClimate();
|
||||
float biomeTemperature = defaultState.getTemperature();
|
||||
float biomeHumidity = defaultState.getHumidity();
|
||||
float temperature = state.getTemperature();
|
||||
float humidity = state.getHumidity();
|
||||
if (temperature != biomeTemperature) {
|
||||
if (temperature > biomeTemperature) {
|
||||
state.addTemperature(-Math.min(CLIMATE_CHANGE, temperature - biomeTemperature));
|
||||
} else {
|
||||
state.addTemperature(Math.min(CLIMATE_CHANGE, biomeTemperature - temperature));
|
||||
}
|
||||
}
|
||||
if (humidity != biomeHumidity) {
|
||||
if (humidity > biomeHumidity) {
|
||||
state.addHumidity(-Math.min(CLIMATE_CHANGE, humidity - biomeHumidity));
|
||||
} else {
|
||||
state.addHumidity(Math.min(CLIMATE_CHANGE, biomeHumidity - humidity));
|
||||
state = state.toState(ClimateStateType.MUTABLE);
|
||||
if (!state.equals(oldState)) {
|
||||
BlockPos coordinates = parent.getCoordinates();
|
||||
NetworkUtil.sendNetworkPacket(new PacketUpdateClimate(coordinates, this), coordinates, parent.getWorldObj());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,21 +221,6 @@ public class ClimateContainer implements IClimateContainer, IStreamable {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addListener(IClimateContainerListener listener) {
|
||||
listeners.addListaner(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IClimateContainerListener listener) {
|
||||
listeners.removeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IClimateContainerListener> getListeners() {
|
||||
return listeners.getListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof IClimateContainer)){
|
||||
@@ -291,32 +248,10 @@ public class ClimateContainer implements IClimateContainer, IStreamable {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private static final class ClimateContainerListeners implements IClimateContainerListener{
|
||||
private List<IClimateContainerListener> listeners = new LinkedList<>();
|
||||
|
||||
@Override
|
||||
public boolean isClosed(IClimateContainer container) {
|
||||
for(IClimateContainerListener listener : listeners){
|
||||
if(!listener.isClosed(container)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addListaner(IClimateContainerListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(IClimateContainerListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public Collection<IClimateContainerListener> getListeners() {
|
||||
return listeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWork() {
|
||||
return canWork.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,6 +30,7 @@ import forestry.greenhouse.api.climate.IClimateModifier;
|
||||
import forestry.greenhouse.api.climate.IClimateSource;
|
||||
|
||||
public class ClimateSourceModifier implements IClimateModifier {
|
||||
public static final float CLIMATE_CHANGE = 0.01F;
|
||||
|
||||
@Override
|
||||
public IClimateState modifyTarget(IClimateContainer container, IClimateState newState, IClimateState oldState, NBTTagCompound data) {
|
||||
@@ -42,48 +43,69 @@ public class ClimateSourceModifier implements IClimateModifier {
|
||||
}
|
||||
IClimateHousing housing = container.getParent();
|
||||
double sizeModifier = housing.getSize() / Config.climateSourceRange;
|
||||
double size = sizeModifier * 0.2D;
|
||||
sizeModifier = Math.max(sizeModifier, 1.0D);
|
||||
|
||||
container.recalculateBoundaries(sizeModifier);
|
||||
|
||||
IClimateState boundaryUp = container.getBoundaryUp();
|
||||
IClimateState boundaryDown = container.getBoundaryDown();
|
||||
|
||||
data.setTag("rangeUp", boundaryUp.writeToNBT(new NBTTagCompound()));
|
||||
data.setTag("rangeDown", boundaryDown.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
IClimateState targetedState = container.getTargetedState();
|
||||
if (!targetedState.isPresent()) {
|
||||
return newState;
|
||||
}
|
||||
int workedSources = 0;
|
||||
IClimateState target = getTargetOrBound(oldState, container.getBoundaryDown(), container.getBoundaryUp(), targetedState);
|
||||
IClimateState changeState = new ClimateState(data.getCompoundTag("change"), ClimateStateType.CHANGE);
|
||||
|
||||
for (IClimateSource source : container.getClimateSources()) {
|
||||
IClimateState state = source.work(oldState, target);
|
||||
if (state.isPresent()) {
|
||||
boolean hasChange = false;
|
||||
double temperatureChange = state.getTemperature();
|
||||
double humidityChange = state.getHumidity();
|
||||
if (temperatureChange != 0) {
|
||||
temperatureChange /= sizeModifier;
|
||||
hasChange = true;
|
||||
}
|
||||
if (humidityChange != 0) {
|
||||
humidityChange /= sizeModifier;
|
||||
hasChange = true;
|
||||
}
|
||||
if (hasChange) {
|
||||
changeState = changeState.addTemperature((float) temperatureChange);
|
||||
changeState = changeState.addHumidity((float) humidityChange);
|
||||
workedSources++;
|
||||
if (!container.canWork()) {
|
||||
IClimateState defaultState = container.getParent().getDefaultClimate();
|
||||
float defaultTemperature = defaultState.getTemperature();
|
||||
float defaultHumidity = defaultState.getHumidity();
|
||||
float temperature = changeState.getTemperature();
|
||||
float humidity = changeState.getHumidity();
|
||||
if (temperature != defaultTemperature) {
|
||||
if (temperature > defaultTemperature) {
|
||||
changeState = changeState.addTemperature((float) -Math.min(CLIMATE_CHANGE / sizeModifier, temperature - defaultTemperature));
|
||||
} else {
|
||||
changeState = changeState.addTemperature((float) Math.min(CLIMATE_CHANGE / sizeModifier, defaultTemperature - temperature));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (workedSources == 0) {
|
||||
return newState.add(changeState);
|
||||
if (humidity != defaultHumidity) {
|
||||
if (humidity > defaultHumidity) {
|
||||
changeState = changeState.addHumidity((float) -Math.min(CLIMATE_CHANGE / sizeModifier, humidity - defaultHumidity));
|
||||
} else {
|
||||
changeState = changeState.addHumidity((float) Math.min(CLIMATE_CHANGE / sizeModifier, defaultHumidity - humidity));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
container.recalculateBoundaries(sizeModifier);
|
||||
|
||||
IClimateState boundaryUp = container.getBoundaryUp();
|
||||
IClimateState boundaryDown = container.getBoundaryDown();
|
||||
|
||||
data.setTag("rangeUp", boundaryUp.writeToNBT(new NBTTagCompound()));
|
||||
data.setTag("rangeDown", boundaryDown.writeToNBT(new NBTTagCompound()));
|
||||
|
||||
IClimateState targetedState = container.getTargetedState();
|
||||
if (!targetedState.isPresent()) {
|
||||
return newState;
|
||||
}
|
||||
int workedSources = 0;
|
||||
IClimateState target = getTargetOrBound(oldState, container.getBoundaryDown(), container.getBoundaryUp(), targetedState);
|
||||
|
||||
for (IClimateSource source : container.getClimateSources()) {
|
||||
IClimateState state = source.work(oldState, target);
|
||||
if (state.isPresent()) {
|
||||
boolean hasChange = false;
|
||||
double temperatureChange = state.getTemperature();
|
||||
double humidityChange = state.getHumidity();
|
||||
if (temperatureChange != 0) {
|
||||
temperatureChange /= sizeModifier;
|
||||
hasChange = true;
|
||||
}
|
||||
if (humidityChange != 0) {
|
||||
humidityChange /= sizeModifier;
|
||||
hasChange = true;
|
||||
}
|
||||
if (hasChange) {
|
||||
changeState = changeState.addTemperature((float) temperatureChange);
|
||||
changeState = changeState.addHumidity((float) humidityChange);
|
||||
workedSources++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (workedSources == 0) {
|
||||
return newState.add(changeState);
|
||||
}
|
||||
}
|
||||
data.setTag("change", changeState.writeToNBT(new NBTTagCompound()));
|
||||
return newState.add(changeState);
|
||||
|
||||
@@ -33,13 +33,11 @@ import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Active;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Listener;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.climate.ClimateContainer;
|
||||
import forestry.core.climate.ClimateState;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
@@ -52,14 +50,15 @@ import forestry.core.utils.Translator;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.greenhouse.api.climate.GreenhouseState;
|
||||
import forestry.greenhouse.api.climate.IClimateContainer;
|
||||
import forestry.greenhouse.api.climate.IClimateContainerListener;
|
||||
import forestry.greenhouse.api.greenhouse.GreenhouseManager;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseBlock;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseLimits;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseProvider;
|
||||
import forestry.greenhouse.api.greenhouse.IGreenhouseProviderListener;
|
||||
import forestry.greenhouse.api.greenhouse.Position2D;
|
||||
import forestry.greenhouse.camouflage.CamouflageHandlerType;
|
||||
import forestry.greenhouse.climate.ClimateContainer;
|
||||
import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProvider;
|
||||
import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProviderClient;
|
||||
import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProviderServer;
|
||||
@@ -68,7 +67,7 @@ import forestry.greenhouse.network.packets.PacketCamouflageSelectionServer;
|
||||
import forestry.greenhouse.network.packets.PacketGreenhouseDataRequest;
|
||||
import forestry.greenhouse.tiles.TileGreenhousePlain;
|
||||
|
||||
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, IClimateContainerListener, IGreenhouseProviderListener {
|
||||
public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, IGreenhouseProviderListener {
|
||||
|
||||
public static final String TYPE = "for.multiblock.greenhouse.type";
|
||||
public static final int CENTER_HEIGHT = 3;
|
||||
@@ -95,13 +94,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
private boolean requestedData;
|
||||
|
||||
public GreenhouseController(World world) {
|
||||
super(world, GreenhouseMultiblockSizeLimits.instance);
|
||||
super(world, GreenhouseMultiblockSizeLimits.INSTANCE);
|
||||
|
||||
this.energyManager = new EnergyManager(200, 100000);
|
||||
|
||||
this.camouflage = getDefaultCamouflageBlock();
|
||||
this.climateContainer = new ClimateContainer(this);
|
||||
this.climateContainer.addListener(this);
|
||||
this.climateContainer = new ClimateContainer(this, this::canWork);
|
||||
this.centerPos = BlockPos.ORIGIN;
|
||||
if (world.isRemote) {
|
||||
provider = new GreenhouseProviderClient(world, climateContainer);
|
||||
@@ -189,11 +187,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
return limits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed(IClimateContainer container) {
|
||||
return provider.isClosed();
|
||||
}
|
||||
|
||||
/* IMultiblockControllerInternal */
|
||||
@Override
|
||||
public void formatDescriptionPacket(NBTTagCompound data) {
|
||||
@@ -281,9 +274,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
provider.create();
|
||||
}
|
||||
} else {
|
||||
if (canWork()) {
|
||||
climateContainer.updateClimate(tickCount);
|
||||
}
|
||||
climateContainer.updateClimate(tickCount);
|
||||
|
||||
for (Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(tickCount);
|
||||
@@ -364,7 +355,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
IGreenhouseListener listener = listenerComponent.getGreenhouseListener();
|
||||
canWork = listener.canWork(this, canWork);
|
||||
}
|
||||
return canWork;
|
||||
return canWork && provider.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,10 +13,9 @@ package forestry.greenhouse.multiblock;
|
||||
import forestry.core.multiblock.IMultiblockSizeLimits;
|
||||
|
||||
class GreenhouseMultiblockSizeLimits implements IMultiblockSizeLimits {
|
||||
public static final GreenhouseMultiblockSizeLimits instance = new GreenhouseMultiblockSizeLimits();
|
||||
public static final GreenhouseMultiblockSizeLimits INSTANCE = new GreenhouseMultiblockSizeLimits();
|
||||
|
||||
private GreenhouseMultiblockSizeLimits() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user