mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 19:29:17 +00:00
Work on new climate system for the greenhouse
This commit is contained in:
1 parent
d55d86a3c5
commit
fbf30b1a73
30 files changed
+787
-180
No files matched your search
@@ -11,7 +11,12 @@
|
||||
package forestry;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -76,6 +81,16 @@ public class Forestry {
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
List<BlockPos> POS = Lists.newArrayList();
|
||||
List<BlockPos> POS2 = Lists.newArrayList();
|
||||
for(BlockPos pos : BlockPos.getAllInBox(new BlockPos(0, 10, 0), new BlockPos(20, 10, 20))){
|
||||
double p = pos.getDistance(10, 10, 10);
|
||||
if(p <= 2){
|
||||
POS.add(pos);
|
||||
}
|
||||
POS2.add(pos);
|
||||
}
|
||||
|
||||
packetHandler = new PacketHandler();
|
||||
|
||||
// Register event handler
|
||||
@@ -89,7 +104,7 @@ public class Forestry {
|
||||
PluginManager.runSetup(event);
|
||||
|
||||
ForestryAPI.activeMode = new GameMode(Config.gameMode);
|
||||
|
||||
|
||||
PluginManager.runPreInit();
|
||||
|
||||
Proxies.render.registerModels();
|
||||
|
||||
@@ -7,6 +7,7 @@ package forestry.api.core;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.climate.IClimateManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
package forestry.api.core.climate;
|
||||
|
||||
public interface IClimateControlled {
|
||||
/**
|
||||
+8
-1
@@ -3,8 +3,11 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
package forestry.api.core.climate;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.core.climate.IClimateWorld.ClimateChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -14,4 +17,8 @@ public interface IClimateManager {
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
void registerWorld(IClimateWorld climateWorld);
|
||||
|
||||
Map<Integer, IClimateWorld> getClimateWorlds();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core.climate;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import forestry.core.multiblock.RectangularMultiblockControllerBase;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateMap {
|
||||
|
||||
List<IClimatedPosition> getPositions();
|
||||
|
||||
World getWorld();
|
||||
|
||||
BlockPos getMinimumPos();
|
||||
|
||||
BlockPos getMaximumPos();
|
||||
|
||||
void updateClimate();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package forestry.api.core.climate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.climate.IClimateWorld.ClimateChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateWorld {
|
||||
|
||||
@Nonnull
|
||||
World getWorld();
|
||||
|
||||
int getDimensionID();
|
||||
|
||||
void updateClimate();
|
||||
|
||||
void addPositions(BlockPos minPos, BlockPos maxPos);
|
||||
|
||||
void addPosition(BlockPos pos);
|
||||
|
||||
void addPosition(IClimatedPosition position);
|
||||
|
||||
void addPositions(List<IClimatedPosition> positions);
|
||||
|
||||
IClimatedPosition getPosition(BlockPos pos);
|
||||
|
||||
void setChunk(ClimateChunk climateChunk);
|
||||
|
||||
@Nonnull
|
||||
Map<ChunkPos, ClimateChunk> getClimateChunks();
|
||||
|
||||
@Nonnull
|
||||
List<ClimateChunk> getDirtyClimateChunks();
|
||||
|
||||
void addDirtyClimateChunk(ClimateChunk chunk);
|
||||
|
||||
public static class ClimateChunk{
|
||||
|
||||
@Nonnull
|
||||
protected final Map<BlockPos, IClimatedPosition> climates;
|
||||
@Nonnull
|
||||
protected final IClimateWorld world;
|
||||
@Nonnull
|
||||
protected final ChunkPos chunkPos;
|
||||
|
||||
public ClimateChunk(@Nonnull IClimateWorld world, @Nonnull ChunkPos chunkPos) {
|
||||
this.world = world;
|
||||
this.chunkPos = chunkPos;
|
||||
climates = new HashMap<>();
|
||||
}
|
||||
|
||||
public void addPosition(IClimatedPosition position){
|
||||
world.addDirtyClimateChunk(this);
|
||||
climates.put(position.getPos(), position);
|
||||
}
|
||||
|
||||
public Map<BlockPos, IClimatedPosition> getClimates() {
|
||||
return climates;
|
||||
}
|
||||
|
||||
public IClimateWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public ChunkPos getChunkPos() {
|
||||
return chunkPos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core.climate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import forestry.core.climate.IClimateHandler;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IClimatedPosition extends INbtReadable, INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
IClimateWorld getClimateWorld();
|
||||
|
||||
@Nonnull
|
||||
BlockPos getPos();
|
||||
|
||||
void setTemperature(float temperature);
|
||||
|
||||
float getTemperature();
|
||||
|
||||
void setHumidity(float humidity);
|
||||
|
||||
float getHumidity();
|
||||
|
||||
List<IClimateHandler> getHandlers();
|
||||
|
||||
void updateClimate();
|
||||
|
||||
}
|
||||
@@ -8,14 +8,20 @@ package forestry.api.greenhouse;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IGreenhouseState {
|
||||
|
||||
@Nonnull
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
@Nonnull
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
float getExactTemperature();
|
||||
|
||||
@@ -7,9 +7,13 @@ package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IInternalBlock {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
|
||||
/**
|
||||
* Needs to be implemented by TileEntities that want to be part of an alveary.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.lepidopterology.IButterflyCocoon;
|
||||
@@ -23,7 +23,7 @@ public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> exte
|
||||
}
|
||||
|
||||
interface Climatiser extends IGreenhouseComponent {
|
||||
<G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tickCount, G greenhouse);
|
||||
void changeClimate(int tickCount, IGreenhouseController controller);
|
||||
}
|
||||
|
||||
interface ButterflyHatch extends IGreenhouseComponent {
|
||||
|
||||
@@ -8,12 +8,13 @@ package forestry.api.multiblock;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateMap;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlled {
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler {
|
||||
|
||||
/**
|
||||
* Handle change events.
|
||||
|
||||
@@ -34,7 +34,7 @@ import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.AlvearyBeeModifier;
|
||||
|
||||
@@ -14,8 +14,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.network.packets.PacketActiveUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -21,8 +21,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.blocks.BlockAlvearyType;
|
||||
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
|
||||
@@ -1,45 +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;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import forestry.api.core.IClimateManager;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactTemperature();
|
||||
}
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactHumidity();
|
||||
}
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import forestry.core.blocks.BlockRegistryCore;
|
||||
import forestry.core.blocks.EnumResourceType;
|
||||
import forestry.core.circuits.CircuitRegistry;
|
||||
import forestry.core.circuits.SolderManager;
|
||||
import forestry.core.climate.ClimateManager;
|
||||
import forestry.core.commands.CommandPlugins;
|
||||
import forestry.core.commands.RootCommand;
|
||||
import forestry.core.config.Config;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimateWorld.ClimateChunk;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ClimateEventHandler {
|
||||
|
||||
@SubscribeEvent
|
||||
public void chunkSave(ChunkDataEvent.Save event){
|
||||
int dimensionID = event.getWorld().provider.getDimension();
|
||||
World world = event.getWorld();
|
||||
Chunk chunk = event.getChunk();
|
||||
IClimateWorld climateWorld = ForestryAPI.climateManager.getClimateWorlds().get(Integer.valueOf(dimensionID));
|
||||
|
||||
if(climateWorld != null){
|
||||
ClimateChunk climateChunk = climateWorld.getClimateChunks().get(new ChunkPos(event.getChunk().xPosition, event.getChunk().zPosition));
|
||||
if(climateChunk != null){
|
||||
NBTTagCompound forestryTag = new NBTTagCompound();
|
||||
event.getData().setTag("Forestry", forestryTag);
|
||||
|
||||
NBTTagList posList = new NBTTagList();
|
||||
for(IClimatedPosition position : climateChunk.getClimates().values()) {
|
||||
if(position != null){
|
||||
NBTTagCompound positionTag = position.writeToNBT(new NBTTagCompound());
|
||||
BlockPos pos = position.getPos();
|
||||
|
||||
positionTag.setInteger("PosX", pos.getX());
|
||||
positionTag.setInteger("PosY", pos.getY());
|
||||
positionTag.setInteger("PosZ", pos.getZ());
|
||||
|
||||
posList.appendTag(positionTag);
|
||||
}
|
||||
}
|
||||
|
||||
forestryTag.setTag("Positions", forestryTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void chunkLoad(ChunkDataEvent.Load event){
|
||||
int dimensionID = event.getWorld().provider.getDimension();
|
||||
World world = event.getWorld();
|
||||
Chunk chunk = event.getChunk();
|
||||
|
||||
IClimateWorld climateWorld = ForestryAPI.climateManager.getClimateWorlds().get(Integer.valueOf(dimensionID));
|
||||
|
||||
if(climateWorld == null){
|
||||
climateWorld = new ClimateWorld();
|
||||
ForestryAPI.climateManager.getClimateWorlds().put(Integer.valueOf(dimensionID), climateWorld);
|
||||
}
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos(event.getChunk().xPosition, event.getChunk().zPosition);
|
||||
NBTTagCompound chunkTag = event.getData();
|
||||
|
||||
if(chunkTag.hasKey("Forestry")){
|
||||
NBTTagCompound forestryTag = chunkTag.getCompoundTag("Forestry");
|
||||
|
||||
Map<BlockPos, IClimatedPosition> positions = new HashMap();
|
||||
NBTTagList posList = forestryTag.getTagList("Positions", 10);
|
||||
for(int i = 0;i < posList.tagCount();i++){
|
||||
NBTTagCompound positionTag = posList.getCompoundTagAt(i);
|
||||
|
||||
int posX = positionTag.getInteger("PosX");
|
||||
int posY = positionTag.getInteger("PosY");
|
||||
int posZ = positionTag.getInteger("PosZ");
|
||||
|
||||
BlockPos pos = new BlockPos(posX, posY, posZ);
|
||||
IClimatedPosition position = new ClimatedPosition(climateWorld, pos);
|
||||
position.readFromNBT(positionTag);
|
||||
positions.put(pos, position);
|
||||
}
|
||||
|
||||
ClimateChunk climateChunk = climateWorld.getClimateChunks().get(chunkPos);
|
||||
if(climateChunk == null){
|
||||
climateChunk = new ClimateChunk(climateWorld, chunkPos);
|
||||
}else{
|
||||
climateChunk.getClimates().clear();
|
||||
}
|
||||
|
||||
climateChunk.getClimates().putAll(positions);
|
||||
climateWorld.setChunk(climateChunk);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*******************************************************************************
|
||||
* 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 net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.climate.IClimateManager;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimateWorld.ClimateChunk;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
public Map<Integer, IClimateWorld> climateWorlds;
|
||||
|
||||
public ClimateManager() {
|
||||
climateWorlds = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
if(ForestryAPI.enabledPlugins.contains(ForestryPluginUids.GREENHOUSE)){
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactTemperature();
|
||||
}
|
||||
}
|
||||
Biome biome = world.getBiome(pos);
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
if(ForestryAPI.enabledPlugins.contains(ForestryPluginUids.GREENHOUSE)){
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactHumidity();
|
||||
}
|
||||
}
|
||||
Biome biome = world.getBiome(pos);
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWorld(IClimateWorld climateWorld) {
|
||||
if(!climateWorlds.containsKey(Integer.valueOf(climateWorld.getDimensionID()))){
|
||||
climateWorlds.put(climateWorld.getDimensionID(), climateWorld);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, IClimateWorld> getClimateWorlds() {
|
||||
return climateWorlds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import forestry.api.core.climate.IClimateMap;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimateMap implements IClimateMap {
|
||||
|
||||
protected final List<IClimatedPosition> positions;
|
||||
protected final World world;
|
||||
protected final BlockPos minimumPos;
|
||||
protected final BlockPos maximumPos;
|
||||
|
||||
public ClimateMap(World world, BlockPos minimumPos, BlockPos maximumPos, List<IClimatedPosition> positions) {
|
||||
this.world = world;
|
||||
this.minimumPos = minimumPos;
|
||||
this.maximumPos = maximumPos;
|
||||
this.positions = positions;
|
||||
}
|
||||
|
||||
public ClimateMap(World world, BlockPos minimumPos, BlockPos maximumPos) {
|
||||
this.world = world;
|
||||
this.minimumPos = minimumPos;
|
||||
this.maximumPos = maximumPos;
|
||||
positions = new ArrayList();
|
||||
for(BlockPos pos : BlockPos.getAllInBox(minimumPos, maximumPos)){
|
||||
Biome biome = world.getBiome(pos);
|
||||
positions.add(new ClimatedPosition(this, pos, biome.getTemperature(), biome.getRainfall()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IClimatedPosition> getPositions() {
|
||||
return positions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getMinimumPos() {
|
||||
return minimumPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getMaximumPos() {
|
||||
return maximumPos;
|
||||
}
|
||||
|
||||
protected IClimatedPosition getPosition(BlockPos pos){
|
||||
for(IClimatedPosition climatedPosition : positions){
|
||||
if(climatedPosition.getPos().equals(pos)){
|
||||
return climatedPosition;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate() {
|
||||
for(IClimatedPosition position : positions) {
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos facePos = position.getPos().offset(facing);
|
||||
IClimatedPosition climatedPosition = getPosition(facePos);
|
||||
if(climatedPosition != null){
|
||||
if(position.getTemperature() > climatedPosition.getTemperature() + 0.01F){
|
||||
position.setTemperature(position.getTemperature() - 0.01F);
|
||||
climatedPosition.setTemperature(climatedPosition.getTemperature() + 0.01F);
|
||||
}
|
||||
if(position.getHumidity() > climatedPosition.getHumidity() + 0.01F){
|
||||
position.setHumidity(position.getHumidity() - 0.01F);
|
||||
climatedPosition.setHumidity(climatedPosition.getHumidity() + 0.01F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import net.minecraft.block.state.BlockPistonStructureHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimateWorld implements IClimateWorld{
|
||||
|
||||
protected int dimensionID;
|
||||
protected World world;
|
||||
protected Map<ChunkPos, ClimateChunk> climateChunks = new ConcurrentHashMap();
|
||||
protected List<ClimateChunk> dirtyClimateChunks = new ArrayList<>();
|
||||
|
||||
public void addPosition(BlockPos pos){
|
||||
Biome biome = world.getBiome(pos);
|
||||
addPosition(new ClimatedPosition(this, pos, biome.getTemperature(), biome.getRainfall()));
|
||||
}
|
||||
|
||||
protected ClimateChunk getOrCreateChunk(ChunkPos chunkPos){
|
||||
ClimateChunk chunk = climateChunks.get(chunkPos);
|
||||
if(chunk == null){
|
||||
chunk = new ClimateChunk(this, chunkPos);
|
||||
climateChunks.put(chunkPos, chunk);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPositions(BlockPos minPos, BlockPos maxPos) {
|
||||
for(BlockPos pos : BlockPos.getAllInBox(minPos, maxPos)){
|
||||
addPosition(pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPosition(IClimatedPosition position) {
|
||||
ChunkPos chunkPos = new ChunkPos(position.getPos());
|
||||
getOrCreateChunk(chunkPos).addPosition(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPositions(List<IClimatedPosition> positions) {
|
||||
for(IClimatedPosition position : positions){
|
||||
addPosition(position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimatedPosition getPosition(BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate() {
|
||||
for(ClimateChunk climateChunk : climateChunks.values()){
|
||||
for(IClimatedPosition position : climateChunk.getClimates().values()){
|
||||
position.updateClimate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChunk(ClimateChunk climateChunk) {
|
||||
if(climateChunk == null){
|
||||
return;
|
||||
}
|
||||
climateChunks.put(climateChunk.getChunkPos(), climateChunk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ChunkPos, ClimateChunk> getClimateChunks() {
|
||||
return climateChunks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDimensionID() {
|
||||
return dimensionID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDirtyClimateChunk(ClimateChunk chunk) {
|
||||
this.dirtyClimateChunks.add(chunk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClimateChunk> getDirtyClimateChunks() {
|
||||
return dirtyClimateChunks;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*******************************************************************************
|
||||
* 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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.climate.IClimateMap;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
import forestry.core.tiles.TileEngine;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimatedPosition implements IClimatedPosition {
|
||||
|
||||
@Nonnull
|
||||
protected final IClimateWorld climateWorld;
|
||||
@Nonnull
|
||||
protected final BlockPos pos;
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
|
||||
public ClimatedPosition(IClimateWorld climateWorld, BlockPos pos) {
|
||||
this.climateWorld = climateWorld;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public ClimatedPosition(@Nonnull IClimateWorld climateWorld, @Nonnull BlockPos pos, float temperature, float humidity) {
|
||||
this.climateWorld = climateWorld;
|
||||
this.pos = pos;
|
||||
this.temperature = temperature;
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IClimateWorld getClimateWorld() {
|
||||
return climateWorld;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTemperature(float temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHumidity(float humidity) {
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
temperature = nbt.getFloat("Temperature");
|
||||
humidity = nbt.getFloat("Humidity");
|
||||
NBTTagList handlersNBT = nbt.getTagList("Handlers", 10);
|
||||
for(int i = 0;i < handlersNBT.tagCount();i++){
|
||||
NBTTagCompound handlerNBT = handlersNBT.getCompoundTagAt(i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("Temperature", temperature);
|
||||
nbt.setFloat("Humidity", humidity);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate() {
|
||||
boolean canHold = false;
|
||||
for(IClimateHandler handler : getHandlers()){
|
||||
if(handler != null){
|
||||
if(handler.canHoldClimate(this)){
|
||||
canHold = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(canHold){
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos facePos = pos.offset(facing);
|
||||
IClimatedPosition climatedPosition = climateWorld.getPosition(facePos);
|
||||
if(climatedPosition != null){
|
||||
if(temperature > climatedPosition.getTemperature() + 0.01F){
|
||||
temperature-= 0.01F;
|
||||
climatedPosition.setTemperature(climatedPosition.getTemperature() + 0.01F);
|
||||
}
|
||||
if(humidity > climatedPosition.getHumidity() + 0.01F){
|
||||
humidity-= 0.01F;
|
||||
climatedPosition.setHumidity(climatedPosition.getHumidity() + 0.01F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Biome biome = climateWorld.getWorld().getBiome(pos);
|
||||
float biomeTemperature = biome.getTemperature();
|
||||
float biomeHumidity = biome.getRainfall();
|
||||
|
||||
if(temperature != biomeTemperature){
|
||||
if(temperature > biomeTemperature){
|
||||
temperature-=0.01F;
|
||||
}else{
|
||||
temperature+=0.01F;
|
||||
}
|
||||
}
|
||||
|
||||
if(humidity != biomeHumidity){
|
||||
if(humidity > biomeHumidity){
|
||||
humidity-=0.01F;
|
||||
}else{
|
||||
humidity+=0.01F;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IClimateHandler> getHandlers() {
|
||||
List<IClimateHandler> handlers = new ArrayList<>();
|
||||
TileEntity tile = climateWorld.getWorld().getTileEntity(pos);
|
||||
if(tile != null){
|
||||
if(tile instanceof IClimateHandler){
|
||||
handlers.add((IClimateHandler) tile);
|
||||
}
|
||||
if(tile instanceof IMultiblockComponent){
|
||||
IMultiblockComponent component = (IMultiblockComponent) tile;
|
||||
IMultiblockLogic logic = component.getMultiblockLogic();
|
||||
if(logic.getController() instanceof IClimateHandler){
|
||||
handlers.add((IClimateHandler) logic.getController());
|
||||
}
|
||||
}
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import forestry.api.core.climate.IClimateMap;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IClimateHandler {
|
||||
|
||||
BlockPos getPos();
|
||||
|
||||
IClimateWorld getWorld();
|
||||
|
||||
boolean canHoldClimate(IClimatedPosition position);
|
||||
|
||||
}
|
||||
@@ -413,7 +413,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
return;
|
||||
}
|
||||
|
||||
if (onlyUpdateWhenAssembled() && this.assemblyState != AssemblyState.Assembled) {
|
||||
if (this.assemblyState != AssemblyState.Assembled) {
|
||||
// Not assembled - don't run game logic
|
||||
return;
|
||||
}
|
||||
@@ -842,8 +842,4 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
private static boolean isInvalid(IMultiblockComponent part) {
|
||||
return part instanceof TileEntity && ((TileEntity) part).isInvalid();
|
||||
}
|
||||
|
||||
protected boolean onlyUpdateWhenAssembled(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.greenhouse.multiblock.GreenhouseController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public final class GreenhouseState implements IGreenhouseState {
|
||||
|
||||
|
||||
@@ -83,14 +83,6 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public void onChange(EnumGreenhouseEventType type, Object event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IGreenhouseState createState() {
|
||||
|
||||
@@ -36,6 +36,8 @@ import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.climate.IClimateMap;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CheckInternalBlockFaceEvent;
|
||||
@@ -50,6 +52,8 @@ import forestry.api.multiblock.IGreenhouseComponent.ButterflyHatch;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.climate.ClimateMap;
|
||||
import forestry.core.climate.ClimatedPosition;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
@@ -83,9 +87,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
private final Set<IGreenhouseComponent.Active> activeComponents = new HashSet<>();
|
||||
private final List<IGreenhouseLogic> logics = new ArrayList<>();
|
||||
|
||||
private float tempChange;
|
||||
private float humidChange;
|
||||
private Biome cachedBiome;
|
||||
private final TankManager tankManager;
|
||||
private final StandardTank resourceTank;
|
||||
private final EnergyManager energyManager;
|
||||
@@ -98,8 +99,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
public GreenhouseController(World world) {
|
||||
super(world, GreenhouseMultiblockSizeLimits.instance);
|
||||
this.tempChange = 0;
|
||||
this.humidChange = 0;
|
||||
|
||||
this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER);
|
||||
this.tankManager = new TankManager(this, resourceTank);
|
||||
@@ -117,14 +116,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
}
|
||||
|
||||
private Biome getBiome() {
|
||||
if (cachedBiome == null) {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
cachedBiome = worldObj.getBiome(coords);
|
||||
}
|
||||
return cachedBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
@@ -141,38 +132,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public float getExactHumidity() {
|
||||
return getBiome().getRainfall() + humidChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTemperatureChange(float change, float boundaryDown, float boundaryUp) {
|
||||
BlockPos coordinates = getCoordinates();
|
||||
|
||||
float temperature = getBiome().getFloatTemperature(coordinates);
|
||||
|
||||
tempChange += change;
|
||||
tempChange = Math.max(boundaryDown - temperature, tempChange);
|
||||
tempChange = Math.min(boundaryUp - temperature, tempChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidityChange(float change, float boundaryDown, float boundaryUp) {
|
||||
float humidity = getBiome().getRainfall();
|
||||
|
||||
humidChange += change;
|
||||
humidChange = Math.max(boundaryDown - humidity, humidChange);
|
||||
humidChange = Math.min(boundaryUp - humidity, humidChange);
|
||||
}
|
||||
|
||||
private static float equalizeChange(float change) {
|
||||
if (change == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
change *= 0.95f;
|
||||
if (change <= 0.001f && change >= -0.001f) {
|
||||
change = 0;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedType() {
|
||||
@@ -190,8 +149,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound data) {
|
||||
data = super.writeToNBT(data);
|
||||
|
||||
data.setFloat("Temperature", tempChange);
|
||||
data.setFloat("Humidity", humidChange);
|
||||
tankManager.writeToNBT(data);
|
||||
energyManager.writeToNBT(data);
|
||||
inventory.writeToNBT(data);
|
||||
@@ -213,8 +170,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
public void readFromNBT(NBTTagCompound data) {
|
||||
super.readFromNBT(data);
|
||||
|
||||
tempChange = data.getFloat("Temperature");
|
||||
humidChange = data.getFloat("Humidity");
|
||||
tankManager.readFromNBT(data);
|
||||
energyManager.readFromNBT(data);
|
||||
inventory.readFromNBT(data);
|
||||
@@ -264,8 +219,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
/* GUI DATA */
|
||||
@Override
|
||||
public void writeGuiData(DataOutputStreamForestry data) throws IOException {
|
||||
data.writeVarInt(Math.round(tempChange * 100));
|
||||
data.writeVarInt(Math.round(humidChange * 100));
|
||||
tankManager.writeData(data);
|
||||
energyManager.writeData(data);
|
||||
inventory.writeData(data);
|
||||
@@ -276,8 +229,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
public void readGuiData(DataInputStreamForestry data) throws IOException {
|
||||
tempChange = data.readVarInt() / 100.0F;
|
||||
humidChange = data.readVarInt() / 100.0F;
|
||||
tankManager.readData(data);
|
||||
energyManager.readData(data);
|
||||
inventory.readData(data);
|
||||
@@ -421,7 +372,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
@Override
|
||||
public IInventoryAdapter getInternalInventory() {
|
||||
if (isAssembled()) {
|
||||
return inventory;
|
||||
return inventory;2
|
||||
} else {
|
||||
return FakeInventoryAdapter.instance();
|
||||
}
|
||||
@@ -475,57 +426,31 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
protected boolean updateServer(int tickCount) {
|
||||
if (!isAssembled()) {
|
||||
boolean hasChangeClima = false;
|
||||
if (updateOnInterval(45)) {
|
||||
if (humidChange > 0F) {
|
||||
if (humidChange > 0.25F) {
|
||||
humidChange = -0.25F;
|
||||
} else {
|
||||
humidChange = 0F;
|
||||
}
|
||||
hasChangeClima = true;
|
||||
}
|
||||
if (tempChange > 0F) {
|
||||
if (tempChange > 0.25F) {
|
||||
tempChange = -0.25F;
|
||||
} else {
|
||||
tempChange = 0F;
|
||||
}
|
||||
hasChangeClima = true;
|
||||
}
|
||||
}
|
||||
return hasChangeClima;
|
||||
} else {
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
logic.work();
|
||||
}
|
||||
|
||||
for (IGreenhouseComponent.Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(tickCount);
|
||||
}
|
||||
|
||||
boolean canWork = true;
|
||||
for (IGreenhouseComponent.Listener listenerComponent : listenerComponents) {
|
||||
canWork = listenerComponent.getGreenhouseListener().canWork(this, canWork);
|
||||
}
|
||||
|
||||
if (canWork) {
|
||||
|
||||
for (IGreenhouseComponent.Climatiser climatiser : climatiserComponents) {
|
||||
climatiser.changeClimate(tickCount, this);
|
||||
}
|
||||
|
||||
tempChange = equalizeChange(tempChange);
|
||||
humidChange = equalizeChange(humidChange);
|
||||
}
|
||||
|
||||
return canWork;
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
logic.work();
|
||||
}
|
||||
|
||||
for (IGreenhouseComponent.Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(tickCount);
|
||||
}
|
||||
|
||||
boolean canWork = true;
|
||||
for (IGreenhouseComponent.Listener listenerComponent : listenerComponents) {
|
||||
canWork = listenerComponent.getGreenhouseListener().canWork(this, canWork);
|
||||
}
|
||||
|
||||
if (canWork) {
|
||||
|
||||
for (IGreenhouseComponent.Climatiser climatiser : climatiserComponents) {
|
||||
climatiser.changeClimate(tickCount, this);
|
||||
}
|
||||
}
|
||||
|
||||
return canWork;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,12 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.greenhouse.IInternalBlockFace;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
public class InternalBlock implements IInternalBlock {
|
||||
@Nonnull
|
||||
|
||||
@@ -13,8 +13,7 @@ package forestry.greenhouse.tiles;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
@@ -20,8 +20,7 @@ import net.minecraftforge.common.animation.TimeValues;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.config.Constants;
|
||||
|
||||
Reference in new issue
Block a user