Skip to content

Commit

Permalink
Improve greenhouse and add new greenhouse gui texture
Browse files Browse the repository at this point in the history
  • Loading branch information
Nedelosk committed Dec 25, 2016
1 parent ea976eb commit d4f9c69
Show file tree
Hide file tree
Showing 66 changed files with 565 additions and 394 deletions.
Expand Up @@ -2,6 +2,6 @@

public enum EnumClimatiserModes {

POSITIVE, NEGATIVE, NONE
POSITIVE, NEGATIVE, BOTH

}
Expand Up @@ -2,6 +2,6 @@

public enum EnumClimatiserTypes {

TEMPERATURE, HUMIDITY, NONE
TEMPERATURE, HUMIDITY, BOTH

}
4 changes: 4 additions & 0 deletions src/main/java/forestry/api/climate/IClimateControl.java
Expand Up @@ -7,6 +7,10 @@

public interface IClimateControl {

IClimateInfo getControlClimate();

void setControlClimate(IClimateInfo climateInfo);

float getControlTemperature();

float getControlHumidity();
Expand Down
Expand Up @@ -9,6 +9,8 @@

public interface IClimateControlProvider extends ILocatable {

IClimateControl getClimateControl();
IClimateInfo getControlClimate();

void setControlClimate(IClimateInfo climateControl);

}
9 changes: 9 additions & 0 deletions src/main/java/forestry/api/climate/IClimateInfo.java
@@ -0,0 +1,9 @@
package forestry.api.climate;

public interface IClimateInfo {

float getTemperature();

float getHumidity();

}
6 changes: 3 additions & 3 deletions src/main/java/forestry/api/climate/IClimateManager.java
Expand Up @@ -14,9 +14,9 @@

public interface IClimateManager {

float getTemperature(World world, BlockPos pos);

float getHumidity(World world, BlockPos pos);
IClimateInfo createInfo(float temperature, float humidity);
IClimateInfo getInfo(World world, BlockPos pos);

IClimateProvider getDefaultClimate(World world, BlockPos pos);

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/forestry/api/climate/IClimatePosition.java
Expand Up @@ -29,5 +29,7 @@ public interface IClimatePosition extends INbtReadable, INbtWritable {
void addHumidity(float humidity);

float getHumidity();

IClimateInfo getInfo();

}
4 changes: 3 additions & 1 deletion src/main/java/forestry/api/core/CamouflageManager.java
Expand Up @@ -9,10 +9,12 @@ public class CamouflageManager {

public static ICamouflageAccess camouflageAccess;

public static final String DEFAULT = "default";
public static final String BLOCK = "block";

public static final String GLASS = "glass";

public static final String DOOR = "door";

public static final String NONE = "none";

}
3 changes: 2 additions & 1 deletion src/main/java/forestry/api/core/EnumTemperature.java
Expand Up @@ -5,6 +5,7 @@
******************************************************************************/
package forestry.api.core;

import forestry.core.utils.ClimateUtil;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand Down Expand Up @@ -71,7 +72,7 @@ public static EnumTemperature getFromBiome(Biome biome, World world, BlockPos po
if (BiomeHelper.isBiomeHellish(biome)) {
return HELLISH;
}
float temperature = ForestryAPI.climateManager.getTemperature(world, pos);
float temperature = ClimateUtil.getTemperature(world, pos);
return getFromValue(temperature);
}
}
3 changes: 2 additions & 1 deletion src/main/java/forestry/api/core/ICamouflageAccess.java
Expand Up @@ -31,7 +31,8 @@ public interface ICamouflageAccess {

boolean isItemBlackListed(String type, ItemStack camouflageBlock);

@Nullable
ICamouflageItemHandler getNoneItemHandler();

ICamouflageItemHandler getHandlerFromItem(ItemStack stack);

}
Expand Up @@ -45,4 +45,12 @@ public String getName() {
return name;
}

@Override
public void onMachineAssembled() {
}

@Override
public void onMachineDisassembled() {
}

}
4 changes: 4 additions & 0 deletions src/main/java/forestry/api/greenhouse/IGreenhouseLogic.java
Expand Up @@ -19,7 +19,11 @@ public interface IGreenhouseLogic extends INbtWritable, INbtReadable {
void work();

void onEvent(EnumGreenhouseEventType type, Object event);

void onMachineAssembled();

void onMachineDisassembled();

IGreenhouseController getController();

String getName();
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/forestry/api/greenhouse/ITerrainRecipe.java
@@ -0,0 +1,16 @@
package forestry.api.greenhouse;

import forestry.api.climate.IClimateInfo;
import net.minecraft.block.state.IBlockState;

public interface ITerrainRecipe {

IBlockState getInput();

IBlockState getResult();

IClimateInfo getMinClimate();

IClimateInfo getMaxClimate();

}
Expand Up @@ -5,7 +5,6 @@
******************************************************************************/
package forestry.api.multiblock;

import forestry.api.climate.IClimateControl;
import forestry.api.climate.IClimateControlProvider;
import forestry.api.climate.IClimateSourceProvider;
import forestry.api.climate.IClimatiserDefinition;
Expand All @@ -24,8 +23,6 @@ interface Listener extends IGreenhouseComponent {

interface ClimateControl extends IGreenhouseComponent, IClimateControlProvider {

@Override
IClimateControl getClimateControl();
}

interface Door extends IGreenhouseComponent {
Expand Down
Expand Up @@ -6,13 +6,15 @@
package forestry.api.multiblock;

import java.util.List;
import java.util.Set;

import forestry.api.climate.IClimateControlProvider;
import forestry.api.climate.IClimateRegion;
import forestry.api.core.ICamouflageHandler;
import forestry.api.greenhouse.EnumGreenhouseEventType;
import forestry.api.greenhouse.IGreenhouseHousing;
import forestry.api.greenhouse.IGreenhouseLogic;
import forestry.api.greenhouse.IInternalBlock;

public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlProvider {

Expand All @@ -25,6 +27,11 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous
* @return The logics of the greenhouse.
*/
List<IGreenhouseLogic> getLogics();

/**
* @return All internal blocks of the greenhouse.
*/
Set<IInternalBlock> getInternalBlocks();

IClimateRegion getRegion();

Expand Down
Expand Up @@ -35,6 +35,7 @@
import forestry.core.owner.OwnerHandler;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IClimatised;
import forestry.core.utils.ClimateUtil;
import net.minecraft.entity.item.EntityMinecart;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
Expand Down Expand Up @@ -113,12 +114,12 @@ public EnumHumidity getHumidity() {

@Override
public float getExactTemperature() {
return ForestryAPI.climateManager.getTemperature(world, getPosition());
return ClimateUtil.getTemperature(world, getPosition());
}

@Override
public float getExactHumidity() {
return ForestryAPI.climateManager.getHumidity(world, getPosition());
return ClimateUtil.getHumidity(world, getPosition());
}

@Override
Expand Down
Expand Up @@ -14,7 +14,6 @@

import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.core.ISpriteRegister;
import forestry.api.core.ITextureManager;
import forestry.api.core.Tabs;
Expand All @@ -24,6 +23,7 @@
import forestry.apiculture.inventory.ItemInventoryHabitatLocator;
import forestry.apiculture.render.TextureHabitatLocator;
import forestry.core.items.ItemWithGui;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.Translator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
Expand Down Expand Up @@ -71,9 +71,9 @@ public void addInformation(ItemStack itemstack, EntityPlayer player, List<String

Biome currentBiome = player.world.getBiome(player.getPosition());

float temperatureValue = ForestryAPI.climateManager.getTemperature(player.world, player.getPosition());
float temperatureValue = ClimateUtil.getTemperature(player.world, player.getPosition());
EnumTemperature temperature = EnumTemperature.getFromValue(temperatureValue);
EnumHumidity humidity = EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(player.world, player.getPosition()));
EnumHumidity humidity = EnumHumidity.getFromValue(ClimateUtil.getHumidity(player.world, player.getPosition()));

list.add(Translator.translateToLocal("for.gui.currentBiome") + ": " + currentBiome.getBiomeName());
list.add(Translator.translateToLocal("for.gui.temperature") + ": " + AlleleManager.climateHelper.toDisplay(temperature));
Expand Down
Expand Up @@ -336,13 +336,13 @@ public Vec3d getBeeFXCoordinates() {
@Override
public float getExactTemperature() {
BlockPos coords = getReferenceCoord();
return ForestryAPI.climateManager.getTemperature(getWorldObj(), coords) + tempChange;
return ClimateUtil.getTemperature(getWorldObj(), coords) + tempChange;
}

@Override
public float getExactHumidity() {
BlockPos coords = getReferenceCoord();
return ForestryAPI.climateManager.getHumidity(getWorldObj(), coords) + humidChange;
return ClimateUtil.getHumidity(getWorldObj(), coords) + humidChange;
}

@Override
Expand Down Expand Up @@ -399,7 +399,7 @@ public boolean isRaining() {

@Override
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
float temperature = ForestryAPI.climateManager.getTemperature(world, getReferenceCoord());
float temperature = ClimateUtil.getTemperature(world, getReferenceCoord());

tempChange += change;
tempChange = Math.max(boundaryDown - temperature, tempChange);
Expand All @@ -408,7 +408,7 @@ public void addTemperatureChange(float change, float boundaryDown, float boundar

@Override
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
float humidity = ForestryAPI.climateManager.getHumidity(world, getReferenceCoord());
float humidity = ClimateUtil.getHumidity(world, getReferenceCoord());

humidChange += change;
humidChange = Math.max(boundaryDown - humidity, humidChange);
Expand Down
Expand Up @@ -101,12 +101,12 @@ public EnumHumidity getHumidity() {

@Override
public float getExactTemperature() {
return ForestryAPI.climateManager.getTemperature(world, getPos());
return ClimateUtil.getTemperature(world, getPos());
}

@Override
public float getExactHumidity() {
return ForestryAPI.climateManager.getHumidity(world, getPos());
return ClimateUtil.getHumidity(world, getPos());
}

/* UPDATING */
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/forestry/apiculture/tiles/TileHive.java
Expand Up @@ -40,6 +40,7 @@
import forestry.core.inventory.InventoryAdapter;
import forestry.core.proxy.Proxies;
import forestry.core.tiles.IActivatable;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.DamageSourceForestry;
import forestry.core.utils.InventoryUtil;
import forestry.core.utils.ItemStackUtil;
Expand Down Expand Up @@ -312,7 +313,7 @@ public EnumTemperature getTemperature() {

@Override
public EnumHumidity getHumidity() {
float humidity = ForestryAPI.climateManager.getHumidity(getWorld(), getPos());
float humidity = ClimateUtil.getHumidity(getWorld(), getPos());
return EnumHumidity.getFromValue(humidity);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/forestry/arboriculture/tiles/TileLeaves.java
Expand Up @@ -25,7 +25,6 @@
import forestry.api.arboriculture.TreeManager;
import forestry.api.core.EnumHumidity;
import forestry.api.core.EnumTemperature;
import forestry.api.core.ForestryAPI;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IAllele;
import forestry.api.genetics.IEffectData;
Expand All @@ -44,6 +43,7 @@
import forestry.core.network.PacketBufferForestry;
import forestry.core.network.packets.PacketTileStream;
import forestry.core.proxy.Proxies;
import forestry.core.utils.ClimateUtil;
import forestry.core.utils.ColourUtil;
import forestry.core.utils.GeneticsUtil;
import net.minecraft.block.state.IBlockState;
Expand Down Expand Up @@ -510,6 +510,6 @@ public EnumTemperature getTemperature() {

@Override
public EnumHumidity getHumidity() {
return EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(world, pos));
return EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, pos));
}
}
14 changes: 10 additions & 4 deletions src/main/java/forestry/core/CamouflageAccess.java
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;

import forestry.api.core.CamouflageManager;
import forestry.api.core.ICamouflageAccess;
import forestry.api.core.ICamouflageItemHandler;
import forestry.core.utils.Log;
Expand All @@ -29,6 +30,7 @@ public class CamouflageAccess implements ICamouflageAccess {
private static final Map<String, List<ICamouflageItemHandler>> camouflageItemHandlers = new HashMap<>();
private static final Map<String, List<ItemStack>> camouflageItemBlacklist = new HashMap<>();
private static final Map<String, List<String>> blacklistedMods = new HashMap<>();
public static final ICamouflageItemHandler NONE = new CamouflageHandlerNone();

@Override
public void registerCamouflageItemHandler(ICamouflageItemHandler itemHandler) {
Expand All @@ -48,7 +50,7 @@ public void registerCamouflageItemHandler(ICamouflageItemHandler itemHandler) {
@Override
@Nullable
public List<ICamouflageItemHandler> getCamouflageItemHandler(String type) {
if (type == null) {
if (type.equals(CamouflageManager.NONE)) {
List<ICamouflageItemHandler> handlers = new ArrayList<>();
for (List<ICamouflageItemHandler> handler : camouflageItemHandlers.values()) {
handlers.addAll(handler);
Expand Down Expand Up @@ -114,12 +116,16 @@ public boolean isItemBlackListed(String type, ItemStack camouflageBlock) {

return false;
}

@Override
public ICamouflageItemHandler getNoneItemHandler() {
return NONE;
}

@Override
@Nullable
public ICamouflageItemHandler getHandlerFromItem(ItemStack stack) {
if (stack.isEmpty()) {
return null;
return NONE;
}
for (List<ICamouflageItemHandler> handlers : camouflageItemHandlers.values()) {
for (ICamouflageItemHandler handler : handlers) {
Expand All @@ -128,7 +134,7 @@ public ICamouflageItemHandler getHandlerFromItem(ItemStack stack) {
}
}
}
return null;
return NONE;
}

}

0 comments on commit d4f9c69

Please sign in to comment.