From aa52b063b720382c693d95fd373420abcee26fb2 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Mon, 18 Sep 2017 15:08:58 +0200 Subject: [PATCH] Fix two Greenhouse Crashes --- .../greenhouse/api/climate/IClimateSource.java | 2 +- .../forestry/greenhouse/climate/ClimateSource.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/greenhouse/api/climate/IClimateSource.java b/src/main/java/forestry/greenhouse/api/climate/IClimateSource.java index cd5d7b351..8eaf5134b 100644 --- a/src/main/java/forestry/greenhouse/api/climate/IClimateSource.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateSource.java @@ -43,7 +43,7 @@ public interface IClimateSource extends INbtWritable, INbtReadable { IClimateState work(IClimateState previousState, IClimateState targetState, IClimateState currentState, final double sizeModifier, final boolean canWork); /** - * @return true if source has changed the climate at the last work cicle. + * @return true if source has changed the climate at the last work circle. */ boolean isActive(); diff --git a/src/main/java/forestry/greenhouse/climate/ClimateSource.java b/src/main/java/forestry/greenhouse/climate/ClimateSource.java index 47e6b1c4d..83fc2fcc9 100644 --- a/src/main/java/forestry/greenhouse/climate/ClimateSource.java +++ b/src/main/java/forestry/greenhouse/climate/ClimateSource.java @@ -157,13 +157,15 @@ public abstract class ClimateSource implements IC } else if (ClimateStates.isNearTarget(currentState, targetState)) { return change; } - //If the state is not already zero, remove one change state from the state. - change = getChange(oppositeType, defaultState, currentState); - change = ClimateStates.INSTANCE.create(-change.getTemperature(), -change.getHumidity(), ClimateStateType.EXTENDED); + if(oppositeType != null) { + //If the state is not already zero, remove one change state from the state. + change = getChange(oppositeType, defaultState, currentState); + change = ClimateStates.INSTANCE.create(-change.getTemperature(), -change.getHumidity(), ClimateStateType.EXTENDED); + } } else if (validType == null && oppositeType != null) { //Remove the resources if the owner has enough resources and the state is not the default state. removeResources(state, oppositeType); - } else { + } else if(validType != null){ change = getChange(validType, targetState, previousState); IClimateState changedState = state.add(change.scale(1 / sizeModifier)); boolean couldWork = canWork(changedState, oppositeType);