mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Improve greenhouse and add new greenhouse gui texture
This commit is contained in:
1 parent
ea976ebb2f
commit
d4f9c69538
66 files changed
+565
-394
No files matched your search
@@ -2,6 +2,6 @@ package forestry.api.climate;
|
||||
|
||||
public enum EnumClimatiserModes {
|
||||
|
||||
POSITIVE, NEGATIVE, NONE
|
||||
POSITIVE, NEGATIVE, BOTH
|
||||
|
||||
}
|
||||
@@ -2,6 +2,6 @@ package forestry.api.climate;
|
||||
|
||||
public enum EnumClimatiserTypes {
|
||||
|
||||
TEMPERATURE, HUMIDITY, NONE
|
||||
TEMPERATURE, HUMIDITY, BOTH
|
||||
|
||||
}
|
||||
@@ -7,6 +7,10 @@ package forestry.api.climate;
|
||||
|
||||
public interface IClimateControl {
|
||||
|
||||
IClimateInfo getControlClimate();
|
||||
|
||||
void setControlClimate(IClimateInfo climateInfo);
|
||||
|
||||
float getControlTemperature();
|
||||
|
||||
float getControlHumidity();
|
||||
|
||||
@@ -9,6 +9,8 @@ import forestry.api.core.ILocatable;
|
||||
|
||||
public interface IClimateControlProvider extends ILocatable {
|
||||
|
||||
IClimateControl getClimateControl();
|
||||
IClimateInfo getControlClimate();
|
||||
|
||||
void setControlClimate(IClimateInfo climateControl);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package forestry.api.climate;
|
||||
|
||||
public interface IClimateInfo {
|
||||
|
||||
float getTemperature();
|
||||
|
||||
float getHumidity();
|
||||
|
||||
}
|
||||
@@ -14,9 +14,9 @@ import net.minecraft.world.World;
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -29,5 +29,7 @@ public interface IClimatePosition extends INbtReadable, INbtWritable {
|
||||
void addHumidity(float humidity);
|
||||
|
||||
float getHumidity();
|
||||
|
||||
IClimateInfo getInfo();
|
||||
|
||||
}
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -71,7 +72,7 @@ public enum EnumTemperature {
|
||||
if (BiomeHelper.isBiomeHellish(biome)) {
|
||||
return HELLISH;
|
||||
}
|
||||
float temperature = ForestryAPI.climateManager.getTemperature(world, pos);
|
||||
float temperature = ClimateUtil.getTemperature(world, pos);
|
||||
return getFromValue(temperature);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,8 @@ public interface ICamouflageAccess {
|
||||
|
||||
boolean isItemBlackListed(String type, ItemStack camouflageBlock);
|
||||
|
||||
@Nullable
|
||||
ICamouflageItemHandler getNoneItemHandler();
|
||||
|
||||
ICamouflageItemHandler getHandlerFromItem(ItemStack stack);
|
||||
|
||||
}
|
||||
@@ -45,4 +45,12 @@ public class DefaultGreenhouseLogic implements IGreenhouseLogic {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineDisassembled() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
@@ -24,8 +23,6 @@ public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> exte
|
||||
|
||||
interface ClimateControl extends IGreenhouseComponent, IClimateControlProvider {
|
||||
|
||||
@Override
|
||||
IClimateControl getClimateControl();
|
||||
}
|
||||
|
||||
interface Door extends IGreenhouseComponent {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
@@ -13,6 +14,7 @@ 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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import forestry.core.owner.IOwnerHandler;
|
||||
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;
|
||||
@@ -113,12 +114,12 @@ public abstract class EntityMinecartBeeHousingBase extends EntityMinecartContain
|
||||
|
||||
@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
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
|
||||
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;
|
||||
@@ -24,6 +23,7 @@ import forestry.apiculture.gui.GuiHabitatLocator;
|
||||
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;
|
||||
@@ -71,9 +71,9 @@ public class ItemHabitatLocator extends ItemWithGui implements ISpriteRegister {
|
||||
|
||||
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));
|
||||
|
||||
@@ -336,13 +336,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
@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
|
||||
@@ -399,7 +399,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@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);
|
||||
@@ -408,7 +408,7 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
|
||||
@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);
|
||||
|
||||
@@ -101,12 +101,12 @@ public abstract class TileBeeHousingBase extends TileBase implements IBeeHousing
|
||||
|
||||
@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 */
|
||||
|
||||
@@ -40,6 +40,7 @@ import forestry.core.config.Config;
|
||||
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;
|
||||
@@ -312,7 +313,7 @@ public class TileHive extends TileEntity implements ITickable, IHiveTile, IActiv
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
float humidity = ForestryAPI.climateManager.getHumidity(getWorld(), getPos());
|
||||
float humidity = ClimateUtil.getHumidity(getWorld(), getPos());
|
||||
return EnumHumidity.getFromValue(humidity);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import forestry.api.arboriculture.ITreekeepingMode;
|
||||
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;
|
||||
@@ -44,6 +43,7 @@ import forestry.arboriculture.network.PacketRipeningUpdate;
|
||||
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;
|
||||
@@ -510,6 +510,6 @@ public class TileLeaves extends TileTreeContainer implements IPollinatable, IFru
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(world, pos));
|
||||
return EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, pos));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import java.util.HashMap;
|
||||
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;
|
||||
@@ -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) {
|
||||
@@ -48,7 +50,7 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
@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);
|
||||
@@ -114,12 +116,16 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
|
||||
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) {
|
||||
@@ -128,7 +134,7 @@ public class CamouflageAccess implements ICamouflageAccess {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return NONE;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -27,7 +27,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class CamouflageHandlerDefault implements ICamouflageItemHandler {
|
||||
public class CamouflageHandlerBlock implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack) {
|
||||
@@ -42,7 +42,7 @@ public class CamouflageHandlerDefault implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.DEFAULT;
|
||||
return CamouflageManager.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,35 @@
|
||||
package forestry.core;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflageItemHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class CamouflageHandlerNone implements ICamouflageItemHandler {
|
||||
|
||||
@Override
|
||||
public boolean canHandle(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return CamouflageManager.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLightTransmittance(ItemStack stack, ICamouflageHandler camouflageHandler) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack, ICamouflageHandler camouflageHandler, ICamouflagedTile camouflageTile) {
|
||||
return Pair.of(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ package forestry.core;
|
||||
import forestry.api.climate.IClimateProvider;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.utils.ClimateUtil;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@@ -39,6 +39,6 @@ public class DefaultClimateProvider implements IClimateProvider {
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(world, pos));
|
||||
return EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, pos));
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
|
||||
rootCommand.addChildCommand(new CommandPlugins());
|
||||
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerDefault());
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerBlock());
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerGlass());
|
||||
CamouflageManager.camouflageAccess.registerCamouflageItemHandler(new CamouflageHandlerDoor());
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.greenhouse.multiblock.DefaultClimateControl;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class BiomeClimateControl extends DefaultClimateControl {
|
||||
|
||||
private static final Map<Biome, BiomeClimateControl> climateControls = new HashMap<>();
|
||||
|
||||
public static BiomeClimateControl getControl(Biome biome) {
|
||||
if (!climateControls.containsKey(biome)) {
|
||||
climateControls.put(biome, new BiomeClimateControl(biome));
|
||||
}
|
||||
return climateControls.get(biome);
|
||||
}
|
||||
|
||||
private final Biome biome;
|
||||
|
||||
private BiomeClimateControl(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlTemperature() {
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlHumidity() {
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class BiomeClimateInfo implements IClimateInfo {
|
||||
|
||||
private static final Map<Biome, BiomeClimateInfo> climateControls = new HashMap<>();
|
||||
|
||||
public static BiomeClimateInfo getInfo(Biome biome) {
|
||||
if (!climateControls.containsKey(biome)) {
|
||||
climateControls.put(biome, new BiomeClimateInfo(biome));
|
||||
}
|
||||
return climateControls.get(biome);
|
||||
}
|
||||
|
||||
private final Biome biome;
|
||||
|
||||
private BiomeClimateInfo(Biome biome) {
|
||||
this.biome = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature() {
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity() {
|
||||
return biome.getRainfall();
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import forestry.core.network.IStreamable;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ClimateControl implements IClimateControl, INbtWritable, INbtReadable, IStreamable {
|
||||
|
||||
private float temperature;
|
||||
private float humidity;
|
||||
|
||||
public ClimateControl() {
|
||||
temperature = 2.0F;
|
||||
humidity = 2.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlTemperature(float temperature) {
|
||||
if (temperature > 2.0F) {
|
||||
this.temperature = 2.0F;
|
||||
} else {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlHumidity(float humidity) {
|
||||
if (humidity > 2.0F) {
|
||||
this.humidity = 2.0F;
|
||||
} else {
|
||||
this.humidity = humidity;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(PacketBufferForestry data) {
|
||||
data.writeFloat(temperature);
|
||||
data.writeFloat(humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(PacketBufferForestry data) throws IOException {
|
||||
temperature = data.readFloat();
|
||||
humidity = data.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
temperature = nbt.getFloat("Temperature");
|
||||
humidity = nbt.getFloat("Humidity");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("Temperature", temperature);
|
||||
nbt.setFloat("Humidity", humidity);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,11 +16,9 @@ import java.util.Map;
|
||||
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.multiblock.MultiblockRegistry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.io.IOException;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ClimateInfo implements IClimateInfo{
|
||||
|
||||
public static final ClimateInfo MIN = new ClimateInfo(false);
|
||||
public static final ClimateInfo MAX = new ClimateInfo(true);
|
||||
|
||||
private final float temperature;
|
||||
private final float humidity;
|
||||
|
||||
private ClimateInfo(boolean isMax) {
|
||||
if(isMax){
|
||||
this.temperature = 2.0F;
|
||||
this.humidity = 2.0F;
|
||||
}else{
|
||||
this.temperature = 0.0F;
|
||||
this.humidity = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
public ClimateInfo(float temperature, float humidity) {
|
||||
if (temperature > MAX.getTemperature()) {
|
||||
temperature = MAX.getTemperature();
|
||||
}
|
||||
if (humidity > MAX.getHumidity()) {
|
||||
humidity = MAX.getHumidity();
|
||||
}
|
||||
if (temperature < MIN.getTemperature()) {
|
||||
temperature = MIN.getTemperature();
|
||||
}
|
||||
if (humidity < MIN.getHumidity()) {
|
||||
humidity = MIN.getHumidity();
|
||||
}
|
||||
this.temperature = temperature;
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
public ClimateInfo(NBTTagCompound compound) {
|
||||
this.temperature = compound.getFloat("Temperature");
|
||||
this.humidity = compound.getFloat("Humidity");
|
||||
}
|
||||
|
||||
public ClimateInfo(PacketBufferForestry data) throws IOException {
|
||||
this.temperature = data.readFloat();
|
||||
this.humidity = data.readFloat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,6 +14,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimateManager;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateProvider;
|
||||
@@ -98,25 +100,20 @@ public class ClimateManager implements IClimateManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, pos);
|
||||
|
||||
if (position != null) {
|
||||
return position.getTemperature();
|
||||
}
|
||||
return world.getBiome(pos).getTemperature();
|
||||
public IClimateInfo createInfo(float temperature, float humidity) {
|
||||
return new ClimateInfo(temperature, humidity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
public IClimateInfo getInfo(World world, BlockPos pos) {
|
||||
IClimatePosition position = ForestryAPI.climateManager.getPosition(world, pos);
|
||||
|
||||
if (position != null) {
|
||||
return position.getHumidity();
|
||||
return position.getInfo();
|
||||
}
|
||||
return world.getBiome(pos).getRainfall();
|
||||
return BiomeClimateInfo.getInfo(world.getBiome(pos));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.climate;
|
||||
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -83,6 +84,11 @@ public class ClimatePosition implements IClimatePosition {
|
||||
public float getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateInfo getInfo() {
|
||||
return new ClimateInfo(temperature, humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.climate.IClimateSource;
|
||||
@@ -99,23 +99,23 @@ public class ClimateRegion implements IClimateRegion, IStreamable {
|
||||
if (world.isBlockLoaded(pos)) {
|
||||
hasChange |= updateSides(position);
|
||||
if (!controller.isAssembled()) {
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
IClimateInfo climateInfo = getControl(pos);
|
||||
|
||||
if (position.getTemperature() != climateControl.getControlTemperature()) {
|
||||
if (position.getTemperature() > climateControl.getControlTemperature()) {
|
||||
position.addTemperature(-Math.min(0.01F, position.getTemperature() - climateControl.getControlTemperature()));
|
||||
if (position.getTemperature() != climateInfo.getTemperature()) {
|
||||
if (position.getTemperature() > climateInfo.getTemperature()) {
|
||||
position.addTemperature(-Math.min(0.01F, position.getTemperature() - climateInfo.getTemperature()));
|
||||
hasChange = true;
|
||||
} else {
|
||||
position.addTemperature(Math.min(0.01F, climateControl.getControlTemperature() - position.getTemperature()));
|
||||
position.addTemperature(Math.min(0.01F, climateInfo.getTemperature() - position.getTemperature()));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
if (position.getHumidity() != climateControl.getControlHumidity()) {
|
||||
if (position.getHumidity() > climateControl.getControlHumidity()) {
|
||||
position.addHumidity(-Math.min(0.01F, position.getHumidity() - climateControl.getControlHumidity()));
|
||||
if (position.getHumidity() != climateInfo.getHumidity()) {
|
||||
if (position.getHumidity() > climateInfo.getHumidity()) {
|
||||
position.addHumidity(-Math.min(0.01F, position.getHumidity() - climateInfo.getHumidity()));
|
||||
hasChange = true;
|
||||
} else {
|
||||
position.addHumidity(Math.min(0.01F, climateControl.getControlHumidity() - position.getHumidity()));
|
||||
position.addHumidity(Math.min(0.01F, climateInfo.getHumidity() - position.getHumidity()));
|
||||
hasChange = true;
|
||||
}
|
||||
}
|
||||
@@ -130,9 +130,9 @@ public class ClimateRegion implements IClimateRegion, IStreamable {
|
||||
|
||||
protected boolean updateSides(IClimatePosition positon) {
|
||||
BlockPos pos = positon.getPos();
|
||||
IClimateControl climateControl = getControl(pos);
|
||||
IClimateInfo climateInfo = getControl(pos);
|
||||
boolean hasChange = false;
|
||||
if (climateControl.getControlTemperature() != temperature || climateControl.getControlHumidity() != humidity) {
|
||||
if (climateInfo.getTemperature() != temperature || climateInfo.getHumidity() != humidity) {
|
||||
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||
IClimatePosition climatedInfoFace = getPosition(pos.offset(facing));
|
||||
if (climatedInfoFace != null) {
|
||||
@@ -154,13 +154,13 @@ public class ClimateRegion implements IClimateRegion, IStreamable {
|
||||
return hasChange;
|
||||
}
|
||||
|
||||
protected IClimateControl getControl(BlockPos pos) {
|
||||
protected IClimateInfo getControl(BlockPos pos) {
|
||||
if (world.isBlockLoaded(pos)) {
|
||||
if (!controller.isAssembled()) {
|
||||
return BiomeClimateControl.getControl(world.getBiome(pos));
|
||||
return BiomeClimateInfo.getInfo(world.getBiome(pos));
|
||||
}
|
||||
}
|
||||
return controller.getClimateControl();
|
||||
return controller.getControlClimate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forestry.core.gui;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.widgets.WidgetCamouflageSlot;
|
||||
import forestry.core.inventory.ItemInventoryCamouflageSprayCan;
|
||||
@@ -12,7 +13,7 @@ public class GuiCamouflageSprayCan extends GuiForestry<ContainerCamouflageSprayC
|
||||
public GuiCamouflageSprayCan(EntityPlayer player, ItemInventoryCamouflageSprayCan inventory) {
|
||||
super(Constants.TEXTURE_PATH_GUI + "/camouflage_spray_can.png", new ContainerCamouflageSprayCan(inventory, player.inventory), inventory);
|
||||
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 80, 39, inventory, null));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 80, 39, inventory, CamouflageManager.NONE));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -147,9 +147,10 @@ public abstract class GuiForestry<C extends Container, I extends IInventory> ext
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
if(widgetManager.handleMouseRelease(mouseX, mouseY, state)){
|
||||
return;
|
||||
}
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
|
||||
widgetManager.handleMouseRelease(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,10 +51,11 @@ public class ProbeButton extends Widget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
public boolean handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
if (pressed) {
|
||||
pressed = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,8 @@ public abstract class Widget implements IToolTipProvider {
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
}
|
||||
|
||||
public void handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
public boolean handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) {
|
||||
|
||||
@@ -69,10 +69,12 @@ public class WidgetManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
public boolean handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
boolean hasToStop = false;
|
||||
for (Widget slot : widgets) {
|
||||
slot.handleMouseRelease(mouseX, mouseY, eventType);
|
||||
hasToStop|=slot.handleMouseRelease(mouseX, mouseY, eventType);
|
||||
}
|
||||
return hasToStop;
|
||||
}
|
||||
|
||||
public void handleMouseMove(int mouseX, int mouseY, int mouseButton, long time) {
|
||||
|
||||
@@ -36,23 +36,22 @@ public class ItemCamouflageSprayCan extends ItemWithGui {
|
||||
super.registerModel(item, manager);
|
||||
ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:camouflage_spray_can_filled"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX,
|
||||
float hitY, float hitZ, EnumHand hand) {
|
||||
ItemStack heldItem = player.getHeldItem(hand);
|
||||
ItemInventoryCamouflageSprayCan inventory = new ItemInventoryCamouflageSprayCan(player, heldItem);
|
||||
ItemStack camouflage = inventory.getStackInSlot(0);
|
||||
if (!camouflage.isEmpty()) {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof ICamouflageHandler) {
|
||||
ICamouflageHandler handler = (ICamouflageHandler) tile;
|
||||
String type = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflage).getType();
|
||||
if (handler.canHandleType(type)) {
|
||||
if (world.isRemote) {
|
||||
handler.setCamouflageBlock(type, camouflage, false);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof ICamouflageHandler) {
|
||||
ICamouflageHandler handler = (ICamouflageHandler) tile;
|
||||
String type = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflage).getType();
|
||||
if (handler.canHandleType(type)) {
|
||||
if(world.isRemote){
|
||||
handler.setCamouflageBlock(type, camouflage, true);
|
||||
}
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
return EnumActionResult.PASS;
|
||||
|
||||
@@ -2,10 +2,11 @@ package forestry.core.network.packets;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
import forestry.core.climate.ClimateInfo;
|
||||
import forestry.core.network.ForestryPacket;
|
||||
import forestry.core.network.IForestryPacketHandlerServer;
|
||||
import forestry.core.network.IForestryPacketServer;
|
||||
@@ -17,15 +18,12 @@ import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class PacketUpdateClimateControl extends ForestryPacket implements IForestryPacketServer {
|
||||
private final BlockPos pos;
|
||||
private final float controlTemperature;
|
||||
private final float controlHumidity;
|
||||
private final IClimateInfo climateInfo;
|
||||
|
||||
public PacketUpdateClimateControl(IClimateControlProvider provider) {
|
||||
pos = provider.getCoordinates();
|
||||
|
||||
IClimateControl control = provider.getClimateControl();
|
||||
controlTemperature = control.getControlTemperature();
|
||||
controlHumidity = control.getControlHumidity();
|
||||
climateInfo = provider.getControlClimate();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,32 +34,31 @@ public class PacketUpdateClimateControl extends ForestryPacket implements IFores
|
||||
@Override
|
||||
protected void writeData(PacketBufferForestry data) throws IOException {
|
||||
data.writeBlockPos(pos);
|
||||
data.writeFloat(controlTemperature);
|
||||
data.writeFloat(controlHumidity);
|
||||
data.writeFloat(climateInfo.getTemperature());
|
||||
data.writeFloat(climateInfo.getHumidity());
|
||||
}
|
||||
|
||||
public static class Handler implements IForestryPacketHandlerServer {
|
||||
@Override
|
||||
public void onPacketData(PacketBufferForestry data, EntityPlayerMP player) throws IOException {
|
||||
BlockPos pos = data.readBlockPos();
|
||||
float controlTemperature = data.readFloat();
|
||||
float controlHumidity = data.readFloat();
|
||||
float tmperature = data.readFloat();
|
||||
float humidity = data.readFloat();
|
||||
|
||||
TileEntity tile = player.world.getTileEntity(pos);
|
||||
IClimateControl control = null;
|
||||
IClimateControlProvider control = null;
|
||||
if (tile instanceof IMultiblockComponent) {
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
IMultiblockLogic logic = component.getMultiblockLogic();
|
||||
if (logic.isConnected() && logic.getController() instanceof IClimateControlProvider) {
|
||||
control = ((IClimateControlProvider) logic.getController()).getClimateControl();
|
||||
control = (IClimateControlProvider) logic.getController();
|
||||
}
|
||||
} else if (tile instanceof IClimateControlProvider) {
|
||||
control = ((IClimateControlProvider) tile).getClimateControl();
|
||||
control = (IClimateControlProvider) tile;
|
||||
}
|
||||
|
||||
if (control != null) {
|
||||
control.setControlTemperature(controlTemperature);
|
||||
control.setControlHumidity(controlHumidity);
|
||||
control.setControlClimate(new ClimateInfo(tmperature, humidity));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,8 @@ public class CamouflageUtil {
|
||||
if (tile instanceof ICamouflageHandler) {
|
||||
ICamouflageHandler tileHandler = (ICamouflageHandler) tile;
|
||||
camouflageStack = tileHandler.getCamouflageBlock(type);
|
||||
} else if (tile instanceof IMultiblockComponent) {
|
||||
}
|
||||
if (camouflageStack.isEmpty() && tile instanceof IMultiblockComponent) {
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
IMultiblockController controller = component.getMultiblockLogic().getController();
|
||||
if (controller.isAssembled() && controller instanceof ICamouflageHandler) {
|
||||
|
||||
@@ -16,10 +16,13 @@ import java.util.Locale;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.genetics.EnumTolerance;
|
||||
import forestry.api.genetics.IClimateHelper;
|
||||
import forestry.core.climate.ClimateRegion;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ClimateUtil implements IClimateHelper {
|
||||
|
||||
@@ -203,6 +206,14 @@ public class ClimateUtil implements IClimateHelper {
|
||||
public String toDisplay(EnumHumidity humidity) {
|
||||
return Translator.translateToLocal("for.gui." + humidity.toString().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static float getTemperature(World world, BlockPos pos){
|
||||
return ForestryAPI.climateManager.getInfo(world, pos).getTemperature();
|
||||
}
|
||||
|
||||
public static float getHumidity(World world, BlockPos pos){
|
||||
return ForestryAPI.climateManager.getInfo(world, pos).getHumidity();
|
||||
}
|
||||
|
||||
public static void writeRoomPositionData(IClimatePosition position, PacketBufferForestry data) {
|
||||
data.writeBlockPos(position.getPos());
|
||||
|
||||
@@ -34,7 +34,6 @@ import forestry.api.circuits.ICircuitBoard;
|
||||
import forestry.api.circuits.ICircuitSocketType;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
@@ -59,6 +58,7 @@ import forestry.core.multiblock.MultiblockValidationException;
|
||||
import forestry.core.multiblock.RectangularMultiblockControllerBase;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import forestry.core.tiles.ILiquidTankTile;
|
||||
import forestry.core.utils.ClimateUtil;
|
||||
import forestry.core.utils.PlayerUtil;
|
||||
import forestry.core.utils.TopDownBlockPosComparator;
|
||||
import forestry.core.utils.Translator;
|
||||
@@ -387,13 +387,13 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
BlockPos coords = getCoordinates();
|
||||
return ForestryAPI.climateManager.getTemperature(getWorldObj(), coords);
|
||||
return ClimateUtil.getTemperature(getWorldObj(), coords);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
BlockPos coords = getCoordinates();
|
||||
return ForestryAPI.climateManager.getHumidity(getWorldObj(), coords);
|
||||
return ClimateUtil.getHumidity(getWorldObj(), coords);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ package forestry.greenhouse;
|
||||
|
||||
import forestry.api.climate.EnumClimatiserModes;
|
||||
import forestry.api.climate.EnumClimatiserTypes;
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.climate.IClimatiserDefinition;
|
||||
@@ -50,9 +50,9 @@ public class GreenhouseClimateSource<P extends TileGreenhouseClimatiser> extends
|
||||
boolean isActive = false;
|
||||
if (logic.isConnected() && controller.isAssembled() && controller instanceof IGreenhouseControllerInternal && positionsInRange.iterator().hasNext()) {
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
IClimateControl climateControl = getClimateControl(greenhouseInternal);
|
||||
float controlTemp = climateControl.getControlTemperature();
|
||||
float controlHum = climateControl.getControlHumidity();
|
||||
IClimateInfo climateInfo = getClimateControl(greenhouseInternal);
|
||||
float controlTemp = climateInfo.getTemperature();
|
||||
float controlHum = climateInfo.getHumidity();
|
||||
isActive = greenhouseInternal.canWork() && provider.canWork();
|
||||
EnumClimatiserTypes type = definition.getType();
|
||||
EnumClimatiserModes mode = definition.getMode();
|
||||
@@ -135,15 +135,15 @@ public class GreenhouseClimateSource<P extends TileGreenhouseClimatiser> extends
|
||||
}
|
||||
|
||||
protected boolean canChange(EnumClimatiserTypes climatiserType, EnumClimatiserTypes type) {
|
||||
return type == climatiserType || climatiserType == EnumClimatiserTypes.NONE;
|
||||
return type == climatiserType || climatiserType == EnumClimatiserTypes.BOTH;
|
||||
}
|
||||
|
||||
protected boolean canChange(EnumClimatiserModes climatiserMode, EnumClimatiserModes mode) {
|
||||
return mode == climatiserMode || climatiserMode == EnumClimatiserModes.NONE;
|
||||
return mode == climatiserMode || climatiserMode == EnumClimatiserModes.BOTH;
|
||||
}
|
||||
|
||||
protected IClimateControl getClimateControl(IGreenhouseControllerInternal greenhouseInternal) {
|
||||
return greenhouseInternal.getClimateControl();
|
||||
protected IClimateInfo getClimateControl(IGreenhouseControllerInternal greenhouseInternal) {
|
||||
return greenhouseInternal.getControlClimate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,13 +4,13 @@ import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.climate.EnumClimatiserModes;
|
||||
import forestry.api.climate.EnumClimatiserTypes;
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.climate.IClimatiserDefinition;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
import forestry.core.climate.BiomeClimateControl;
|
||||
import forestry.core.climate.BiomeClimateInfo;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseWindow;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseWindow.WindowMode;
|
||||
@@ -41,9 +41,9 @@ public class GreenhouseClimateWindow extends GreenhouseClimateSource<TileGreenho
|
||||
WindowMode windowMode = provider.getMode();
|
||||
if (logic.isConnected() && controller.isAssembled() && controller instanceof IGreenhouseControllerInternal && positionsInRange.iterator().hasNext()) {
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
IClimateControl climateControl = getClimateControl(greenhouseInternal);
|
||||
float controlTemp = climateControl.getControlTemperature();
|
||||
float controlHum = climateControl.getControlHumidity();
|
||||
IClimateInfo climateInfo = getClimateControl(greenhouseInternal);
|
||||
float controlTemp = climateInfo.getTemperature();
|
||||
float controlHum = climateInfo.getHumidity();
|
||||
if (!greenhouseInternal.canWork()) {
|
||||
if (windowMode == WindowMode.OPEN) {
|
||||
provider.setMode(windowMode = WindowMode.CONTROL);
|
||||
@@ -100,13 +100,13 @@ public class GreenhouseClimateWindow extends GreenhouseClimateSource<TileGreenho
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IClimateControl getClimateControl(IGreenhouseControllerInternal greenhouseInternal) {
|
||||
protected IClimateInfo getClimateControl(IGreenhouseControllerInternal greenhouseInternal) {
|
||||
if (biome == null) {
|
||||
BlockPos pos = provider.getCoordinates();
|
||||
World world = provider.getWorld();
|
||||
biome = world.getBiome(pos);
|
||||
}
|
||||
return BiomeClimateControl.getControl(biome);
|
||||
return BiomeClimateInfo.getInfo(biome);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@ import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.OreDictUtil;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.blocks.BlockRegistryGreenhouse;
|
||||
import forestry.greenhouse.logics.GreenhouseLogicGreenhouseDoor;
|
||||
import forestry.greenhouse.logics.GreenhouseLogicGreenhouseEffect;
|
||||
import forestry.greenhouse.proxy.ProxyGreenhouse;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch;
|
||||
@@ -160,12 +159,11 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
|
||||
Block greenhouseSprinklerBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.HUMIDIFIER);
|
||||
RecipeUtil.addRecipe(greenhouseSprinklerBlock,
|
||||
"TXT",
|
||||
"GIG",
|
||||
" I ",
|
||||
'X', blocks.getGreenhouseBlock(BlockGreenhouseType.GLASS),
|
||||
'I', OreDictUtil.INGOT_IRON,
|
||||
'G', OreDictUtil.GEAR_TIN,
|
||||
"T#T",
|
||||
"#X#",
|
||||
"T#T",
|
||||
'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN),
|
||||
'#', OreDictUtil.INGOT_TIN,
|
||||
'T', coreItems.tubes.get(EnumElectronTube.LAPIS, 1));
|
||||
|
||||
Block greenhouseDoorBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.DOOR);
|
||||
@@ -250,7 +248,6 @@ public class PluginGreenhouse extends BlankForestryPlugin {
|
||||
proxy.initializeModels();
|
||||
|
||||
GreenhouseManager.greenhouseHelper.addGreenhouseLogic(GreenhouseLogicGreenhouseEffect.class);
|
||||
GreenhouseManager.greenhouseHelper.addGreenhouseLogic(GreenhouseLogicGreenhouseDoor.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -202,7 +202,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR
|
||||
if (!controller.isAssembled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!worldIn.isRemote) {
|
||||
part.openGui(playerIn);
|
||||
}
|
||||
|
||||
@@ -14,22 +14,21 @@ import java.io.IOException;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.primitives.Floats;
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateControlProvider;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.climate.ClimateInfo;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.gui.GuiForestryTitled;
|
||||
import forestry.core.gui.ledgers.ClimateLedger;
|
||||
import forestry.core.gui.ledgers.Ledger;
|
||||
import forestry.core.gui.widgets.TankWidget;
|
||||
import forestry.core.gui.widgets.WidgetCamouflageSlot;
|
||||
import forestry.core.network.packets.PacketUpdateClimateControl;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.render.ColourProperties;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.greenhouse.multiblock.DefaultClimateControl;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
import forestry.greenhouse.tiles.TileGreenhouse;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
@@ -61,14 +60,15 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
|
||||
//Add the water tank
|
||||
widgetManager.add(new TankWidget(widgetManager, 152, 16, 0).setOverlayOrigin(176, 0));
|
||||
|
||||
//Add the multiblock camouflage slots
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 16, inventory.getMultiblockLogic().getController(), CamouflageManager.DEFAULT));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 37, inventory.getMultiblockLogic().getController(), CamouflageManager.GLASS));
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 8, 58, inventory.getMultiblockLogic().getController(), CamouflageManager.DOOR));
|
||||
|
||||
//Add the tile camouflage slots
|
||||
widgetManager.add(new WidgetCamouflageSlot(widgetManager, 35, 37, inventory, tile.getCamouflageType()));
|
||||
//Add the multiblock camouflage tabs
|
||||
WidgetCamouflageTab previous;
|
||||
int x = 3;
|
||||
widgetManager.add(previous = new WidgetCamouflageTab(widgetManager, guiLeft + x, guiTop - 25, inventory.getMultiblockLogic().getController(), tile, CamouflageManager.BLOCK));
|
||||
x+=50 + (previous.getHandlerSlot() != null ? 20 : 0);
|
||||
widgetManager.add(previous = new WidgetCamouflageTab(widgetManager, guiLeft + x, guiTop - 25, inventory.getMultiblockLogic().getController(), tile, CamouflageManager.GLASS));
|
||||
x+=50 + (previous.getHandlerSlot() != null ? 20 : 0);
|
||||
widgetManager.add(new WidgetCamouflageTab(widgetManager, guiLeft + x, guiTop - 25, inventory.getMultiblockLogic().getController(), tile, CamouflageManager.DOOR));
|
||||
|
||||
fieldsEnabeled = true;
|
||||
|
||||
temperatureField = new GuiTextField(0, fontRendererObj, guiLeft + 63, guiTop + 30, 50, 10);
|
||||
@@ -86,16 +86,16 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
humidityField.setValidator(numberFilter);
|
||||
|
||||
IGreenhouseController controller = inventory.getMultiblockLogic().getController();
|
||||
if (controller == null || controller.getClimateControl() == DefaultClimateControl.instance) {
|
||||
if (controller == null || controller.getControlClimate() == ClimateInfo.MAX) {
|
||||
temperatureField.setEnabled(false);
|
||||
temperatureField.setVisible(false);
|
||||
humidityField.setEnabled(false);
|
||||
humidityField.setVisible(false);
|
||||
fieldsEnabeled = false;
|
||||
} else {
|
||||
IClimateControl control = controller.getClimateControl();
|
||||
temperatureField.setText(Float.toString(control.getControlTemperature()));
|
||||
humidityField.setText(Float.toString(control.getControlHumidity()));
|
||||
IClimateInfo info = controller.getControlClimate();
|
||||
temperatureField.setText(Float.toString(info.getTemperature()));
|
||||
humidityField.setText(Float.toString(info.getHumidity()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,15 +119,15 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
temperatureField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
humidityField.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
IClimateControlProvider provider = inventory.getMultiblockLogic().getController();
|
||||
IClimateControl control = provider.getClimateControl();
|
||||
IClimateInfo info = provider.getControlClimate();
|
||||
if (temperatureWasFocused && !temperatureField.isFocused()) {
|
||||
float temp = parseField(temperatureField);
|
||||
temperatureField.setText(Float.toString(temp));
|
||||
control.setControlTemperature(temp);
|
||||
provider.setControlClimate(new ClimateInfo(temp, info.getHumidity()));
|
||||
} else if (humidityWasFocused && !humidityField.isFocused()) {
|
||||
float hum = parseField(humidityField);
|
||||
humidityField.setText(Float.toString(hum));
|
||||
control.setControlHumidity(parseField(humidityField));
|
||||
provider.setControlClimate(new ClimateInfo(info.getTemperature(), hum));
|
||||
}
|
||||
Proxies.net.sendToServer(new PacketUpdateClimateControl(provider));
|
||||
}
|
||||
@@ -164,7 +164,6 @@ public class GuiGreenhouse extends GuiForestryTitled<ContainerGreenhouse, TileGr
|
||||
|
||||
humidityField.drawTextBox();
|
||||
}
|
||||
bindTexture(textureFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package forestry.greenhouse.gui;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.CamouflageManager;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.gui.tooltips.ToolTip;
|
||||
import forestry.core.gui.widgets.Widget;
|
||||
import forestry.core.gui.widgets.WidgetCamouflageSlot;
|
||||
import forestry.core.gui.widgets.WidgetManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class WidgetCamouflageTab extends Widget {
|
||||
private final IGreenhouseController controller;
|
||||
private final ICamouflageHandler camouflageHandler;
|
||||
private final WidgetCamouflageSlot greenhouseSlot;
|
||||
@Nullable
|
||||
private final WidgetCamouflageSlot handlerSlot;
|
||||
private final ItemStack typeStack;
|
||||
private final String type;
|
||||
|
||||
public WidgetCamouflageTab(WidgetManager manager, int xPos, int yPos, IGreenhouseController controller, ICamouflageHandler camouflageHandler, String type) {
|
||||
super(manager, xPos, yPos);
|
||||
|
||||
this.controller = controller;
|
||||
this.camouflageHandler = camouflageHandler;
|
||||
this.type = type;
|
||||
this.width = 48;
|
||||
this.height = 25;
|
||||
greenhouseSlot = new WidgetCamouflageSlot(manager, xPos + 26, yPos + 6, controller, type);
|
||||
if(camouflageHandler.canHandleType(type)){
|
||||
handlerSlot = new WidgetCamouflageSlot(manager, xPos + 46, yPos + 6, camouflageHandler, type);
|
||||
width+=20;
|
||||
}else{
|
||||
handlerSlot = null;
|
||||
}
|
||||
if(type.equals(CamouflageManager.BLOCK)){
|
||||
typeStack = new ItemStack(Blocks.BRICK_BLOCK);
|
||||
}else if(type.equals(CamouflageManager.GLASS)){
|
||||
typeStack = new ItemStack(Blocks.GLASS);
|
||||
}else if(type.equals(CamouflageManager.DOOR)){
|
||||
typeStack = new ItemStack(Items.OAK_DOOR);
|
||||
}else{
|
||||
typeStack = ItemStack.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(int startX, int startY) {
|
||||
Proxies.render.bindTexture(manager.gui.textureFile);
|
||||
manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, 192, 0, 48, 25);
|
||||
if(handlerSlot != null){
|
||||
manager.gui.drawTexturedModalRect(startX + xPos + 44, startY + yPos, 192, 25, 24, 25);
|
||||
}
|
||||
if (!typeStack.isEmpty()) {
|
||||
Proxies.render.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
RenderItem renderItem = Proxies.common.getClientInstance().getRenderItem();
|
||||
renderItem.renderItemIntoGUI(typeStack, startX + xPos + 6, startY + yPos + 6);
|
||||
}
|
||||
greenhouseSlot.draw(startX, startY);
|
||||
if(handlerSlot != null){
|
||||
handlerSlot.draw(startX, startY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseClick(int mouseX, int mouseY, int mouseButton) {
|
||||
mouseX-=manager.gui.getGuiLeft();
|
||||
mouseY-=manager.gui.getGuiTop();
|
||||
if(greenhouseSlot.isMouseOver(mouseX, mouseY)){
|
||||
greenhouseSlot.handleMouseClick(mouseX, mouseY, mouseButton);
|
||||
}else if(handlerSlot != null && handlerSlot.isMouseOver(mouseX, mouseY)){
|
||||
handlerSlot.handleMouseClick(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMouseRelease(int mouseX, int mouseY, int eventType) {
|
||||
if(isMouseOver(mouseX - manager.gui.getGuiLeft(), mouseY - manager.gui.getGuiTop())){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public WidgetCamouflageSlot getHandlerSlot() {
|
||||
return handlerSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolTip getToolTip(int mouseX, int mouseY) {
|
||||
if(greenhouseSlot.isMouseOver(mouseX, mouseY)){
|
||||
return greenhouseSlot.getToolTip(mouseX, mouseY);
|
||||
}else if(handlerSlot != null && handlerSlot.isMouseOver(mouseX, mouseY)){
|
||||
return handlerSlot.getToolTip(mouseX, mouseY);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.logics;
|
||||
|
||||
import forestry.api.greenhouse.DefaultGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseClimaLogic;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic {
|
||||
|
||||
private int workTimer;
|
||||
|
||||
public GreenhouseLogicGreenhouseDoor(IGreenhouseController controller) {
|
||||
super(controller, "GreenhouseDoor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void work() {
|
||||
/*if (controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
if (workTimer++ > 20) {
|
||||
int openDoors = 0;
|
||||
for (IMultiblockComponent component : controller.getComponents()) {
|
||||
if (component instanceof TileGreenhouseDoor) {
|
||||
IBlockState state = ((TileGreenhouseDoor) component).getWorld().getBlockState(component.getCoordinates());
|
||||
if (state.getValue(BlockDoor.OPEN)) {
|
||||
openDoors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.addTemperatureChange(-0.0001F * openDoors, 0.05F, 2.5F);
|
||||
controller.addHumidityChange(-0.0001F * openDoors, 0.05F, 2.5F);
|
||||
workTimer = 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("workTimer", workTimer);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
workTimer = nbt.getInteger("workTimer");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package forestry.greenhouse.logics;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.greenhouse.DefaultGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class GreenhouseLogicTerrain extends DefaultGreenhouseLogic {
|
||||
|
||||
private World world;
|
||||
private Set<BlockPos> terrain;
|
||||
|
||||
public GreenhouseLogicTerrain(IGreenhouseController controller) {
|
||||
super(controller, "Terrain");
|
||||
this.terrain = new HashSet<>();
|
||||
this.world = controller.getWorldObj();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void work() {
|
||||
if (controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled() {
|
||||
for(IInternalBlock internalBlock : controller.getInternalBlocks()){
|
||||
BlockPos pos = internalBlock.getPos();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineDisassembled() {
|
||||
terrain.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package forestry.greenhouse.multiblock;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
|
||||
public class DefaultClimateControl implements IClimateControl {
|
||||
|
||||
public static final DefaultClimateControl instance = new DefaultClimateControl();
|
||||
|
||||
public DefaultClimateControl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlTemperature() {
|
||||
return 2.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getControlHumidity() {
|
||||
return 2.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlTemperature(float temperature) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlHumidity(float humidity) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,13 +15,14 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.ButterflyHatch;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Listener;
|
||||
import forestry.core.climate.ClimateInfo;
|
||||
import forestry.core.fluids.FakeTankManager;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
@@ -112,8 +113,13 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateControl getClimateControl() {
|
||||
return DefaultClimateControl.instance;
|
||||
public IClimateInfo getControlClimate() {
|
||||
return ClimateInfo.MAX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlClimate(IClimateInfo climateControl) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.climate.IClimatePosition;
|
||||
import forestry.api.climate.IClimateRegion;
|
||||
import forestry.api.climate.IClimateSourceProvider;
|
||||
@@ -43,6 +43,7 @@ import forestry.api.multiblock.IGreenhouseComponent.ClimateControl;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Climatiser;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.climate.ClimateInfo;
|
||||
import forestry.core.climate.ClimatePosition;
|
||||
import forestry.core.climate.ClimateRegion;
|
||||
import forestry.core.config.Constants;
|
||||
@@ -108,10 +109,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
this.energyManager = new EnergyManager(200, 100000);
|
||||
this.inventory = new InventoryGreenhouse(this);
|
||||
|
||||
camouflagePlainBlock = getDefaultCamouflageBlock(CamouflageManager.DEFAULT);
|
||||
camouflagePlainBlock = getDefaultCamouflageBlock(CamouflageManager.BLOCK);
|
||||
camouflageGlassBlock = getDefaultCamouflageBlock(CamouflageManager.GLASS);
|
||||
camouflageDoorBlock = getDefaultCamouflageBlock(CamouflageManager.DOOR);
|
||||
this.region = new ClimateRegion(this);
|
||||
createLogics();
|
||||
}
|
||||
|
||||
/* CLIMATE */
|
||||
@@ -154,7 +156,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
energyManager.writeToNBT(data);
|
||||
inventory.writeToNBT(data);
|
||||
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.BLOCK);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DOOR);
|
||||
|
||||
@@ -177,7 +179,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
energyManager.readFromNBT(data);
|
||||
inventory.readFromNBT(data);
|
||||
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.BLOCK);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DOOR);
|
||||
|
||||
@@ -218,7 +220,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
tankManager.writeData(data);
|
||||
energyManager.writeData(data);
|
||||
inventory.writeData(data);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.DEFAULT);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.BLOCK);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.GLASS);
|
||||
CamouflageUtil.writeCamouflageBlockToData(data, this, CamouflageManager.DOOR);
|
||||
region.writeData(data);
|
||||
@@ -237,7 +239,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
public boolean canHandleType(String type) {
|
||||
return type.equals(CamouflageManager.DEFAULT) || type.equals(CamouflageManager.GLASS) || type.equals(CamouflageManager.DOOR);
|
||||
return type.equals(CamouflageManager.BLOCK) || type.equals(CamouflageManager.GLASS) || type.equals(CamouflageManager.DOOR);
|
||||
}
|
||||
|
||||
/* CAMOUFLAGE */
|
||||
@@ -245,7 +247,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public boolean setCamouflageBlock(String type, ItemStack camouflageBlock, boolean sendClientUpdate) {
|
||||
ItemStack oldCamouflageBlock;
|
||||
switch (type) {
|
||||
case CamouflageManager.DEFAULT:
|
||||
case CamouflageManager.BLOCK:
|
||||
oldCamouflageBlock = camouflagePlainBlock;
|
||||
break;
|
||||
case CamouflageManager.GLASS:
|
||||
@@ -260,7 +262,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
if (!ItemStackUtil.isIdenticalItem(camouflageBlock, oldCamouflageBlock)) {
|
||||
switch (type) {
|
||||
case CamouflageManager.DEFAULT:
|
||||
case CamouflageManager.BLOCK:
|
||||
camouflagePlainBlock = camouflageBlock;
|
||||
break;
|
||||
case CamouflageManager.GLASS:
|
||||
@@ -284,7 +286,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
@Override
|
||||
public ItemStack getCamouflageBlock(String type) {
|
||||
switch (type) {
|
||||
case CamouflageManager.DEFAULT:
|
||||
case CamouflageManager.BLOCK:
|
||||
return camouflagePlainBlock;
|
||||
case CamouflageManager.GLASS:
|
||||
return camouflageGlassBlock;
|
||||
@@ -298,7 +300,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
@Override
|
||||
public ItemStack getDefaultCamouflageBlock(String type) {
|
||||
switch (type) {
|
||||
case CamouflageManager.DEFAULT:
|
||||
case CamouflageManager.BLOCK:
|
||||
return new ItemStack(Blocks.BRICK_BLOCK);
|
||||
case CamouflageManager.GLASS:
|
||||
return new ItemStack(Blocks.STAINED_GLASS, 1, 13);
|
||||
@@ -385,7 +387,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
protected void onMachineAssembled() {
|
||||
super.onMachineAssembled();
|
||||
|
||||
createLogics();
|
||||
Set<IClimatePosition> internalPositions = new HashSet<>();
|
||||
for (IInternalBlock block : internalBlocks) {
|
||||
if (block != null) {
|
||||
@@ -404,6 +405,9 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
world.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates());
|
||||
}
|
||||
}
|
||||
for(IGreenhouseLogic logic : logics){
|
||||
logic.onMachineAssembled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -424,6 +428,9 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
world.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates());
|
||||
}
|
||||
}
|
||||
for(IGreenhouseLogic logic : logics){
|
||||
logic.onMachineDisassembled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -717,11 +724,18 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateControl getClimateControl() {
|
||||
public IClimateInfo getControlClimate() {
|
||||
if (climateControl == null) {
|
||||
return DefaultClimateControl.instance;
|
||||
return ClimateInfo.MAX;
|
||||
}
|
||||
return climateControl.getControlClimate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlClimate(IClimateInfo climateControl) {
|
||||
if (this.climateControl != null) {
|
||||
this.climateControl.setControlClimate(climateControl);
|
||||
}
|
||||
return climateControl.getClimateControl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,6 @@ package forestry.greenhouse.multiblock;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
@@ -40,11 +39,6 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM
|
||||
*/
|
||||
EnergyManager getEnergyManager();
|
||||
|
||||
/**
|
||||
* @return All internal blocks of the greenhouse.
|
||||
*/
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
/**
|
||||
* @return True if the greenhouse can work.
|
||||
*/
|
||||
|
||||
@@ -104,6 +104,7 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
|
||||
if (sendClientUpdate && world != null && world.isRemote) {
|
||||
Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.TILE));
|
||||
world.markBlockRangeForRenderUpdate(pos, pos);
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController(), this, this, type));
|
||||
return true;
|
||||
@@ -197,7 +198,7 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
} else if (((BlockGreenhouse) getBlockType()).getGreenhouseType() == BlockGreenhouseType.DOOR) {
|
||||
return CamouflageManager.DOOR;
|
||||
}
|
||||
return CamouflageManager.DEFAULT;
|
||||
return CamouflageManager.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,60 +2,69 @@ package forestry.greenhouse.tiles;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import forestry.api.climate.IClimateControl;
|
||||
import forestry.api.climate.IClimateInfo;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.core.climate.ClimateInfo;
|
||||
import forestry.core.network.PacketBufferForestry;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class TileGreenhouseClimateControl extends TileGreenhouse implements IGreenhouseComponent.ClimateControl {
|
||||
|
||||
private final forestry.core.climate.ClimateControl climateControl;
|
||||
private IClimateInfo climateControl;
|
||||
|
||||
public TileGreenhouseClimateControl() {
|
||||
super();
|
||||
climateControl = new forestry.core.climate.ClimateControl();
|
||||
climateControl = ClimateInfo.MAX;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decodeDescriptionPacket(NBTTagCompound packetData) {
|
||||
super.decodeDescriptionPacket(packetData);
|
||||
climateControl.readFromNBT(packetData);
|
||||
climateControl = new ClimateInfo(packetData);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void encodeDescriptionPacket(NBTTagCompound packetData) {
|
||||
super.encodeDescriptionPacket(packetData);
|
||||
climateControl.writeToNBT(packetData);
|
||||
packetData.setFloat("Temperature", climateControl.getTemperature());
|
||||
packetData.setFloat("Humidity", climateControl.getHumidity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
climateControl.readFromNBT(data);
|
||||
climateControl = new ClimateInfo(data);
|
||||
super.readFromNBT(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound data) {
|
||||
climateControl.writeToNBT(data);
|
||||
data.setFloat("Temperature", climateControl.getTemperature());
|
||||
data.setFloat("Humidity", climateControl.getHumidity());
|
||||
return super.writeToNBT(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(PacketBufferForestry data) {
|
||||
climateControl.writeData(data);
|
||||
data.writeFloat(climateControl.getTemperature());
|
||||
data.writeFloat(climateControl.getHumidity());
|
||||
super.writeGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(PacketBufferForestry data) throws IOException {
|
||||
climateControl.readData(data);
|
||||
climateControl = new ClimateInfo(data);
|
||||
super.readGuiData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateControl getClimateControl() {
|
||||
public IClimateInfo getControlClimate() {
|
||||
return climateControl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlClimate(IClimateInfo climateControl) {
|
||||
this.climateControl = climateControl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -211,7 +211,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
if (getBlockType() instanceof BlockGreenhouse && ((BlockGreenhouse) getBlockType()).getGreenhouseType() == BlockGreenhouseType.GLASS) {
|
||||
return CamouflageManager.GLASS;
|
||||
}
|
||||
return CamouflageManager.DEFAULT;
|
||||
return CamouflageManager.BLOCK;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -28,7 +28,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
public class TileGreenhouseWindow extends TileGreenhouseClimatiser {
|
||||
@Nullable
|
||||
private WindowMode mode;
|
||||
private static final IClimatiserDefinition DEFINITION = new ClimatiserDefinition(0.001F, EnumClimatiserModes.NONE, 5F, EnumClimatiserTypes.NONE);
|
||||
private static final IClimatiserDefinition DEFINITION = new ClimatiserDefinition(0.001F, EnumClimatiserModes.BOTH, 5F, EnumClimatiserTypes.BOTH);
|
||||
|
||||
public TileGreenhouseWindow() {
|
||||
super(DEFINITION, new GreenhouseClimateWindow(20));
|
||||
|
||||
@@ -19,7 +19,6 @@ import java.util.Set;
|
||||
|
||||
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.IAlleleTolerance;
|
||||
@@ -39,6 +38,7 @@ import forestry.api.lepidopterology.IEntityButterfly;
|
||||
import forestry.core.genetics.Chromosome;
|
||||
import forestry.core.genetics.GenericRatings;
|
||||
import forestry.core.genetics.IndividualLiving;
|
||||
import forestry.core.utils.ClimateUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.lepidopterology.PluginLepidopterology;
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
@@ -175,7 +175,7 @@ public class Butterfly extends IndividualLiving implements IButterfly {
|
||||
private boolean isAcceptedEnvironment(World world, int x, int y, int z) {
|
||||
Biome biome = world.getBiome(new BlockPos(x, y, z));
|
||||
EnumTemperature biomeTemperature = EnumTemperature.getFromBiome(biome, world, new BlockPos(x, y, z));
|
||||
EnumHumidity biomeHumidity = EnumHumidity.getFromValue(ForestryAPI.climateManager.getHumidity(world, new BlockPos(x, y, z)));
|
||||
EnumHumidity biomeHumidity = EnumHumidity.getFromValue(ClimateUtil.getHumidity(world, new BlockPos(x, y, z)));
|
||||
return AlleleManager.climateHelper.isWithinLimits(biomeTemperature, biomeHumidity,
|
||||
getGenome().getPrimary().getTemperature(), getGenome().getToleranceTemp(),
|
||||
getGenome().getPrimary().getHumidity(), getGenome().getToleranceHumid());
|
||||
|
||||
Reference in new issue
Block a user