mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-25 22:34:33 +00:00
Update System
This commit is contained in:
1 parent
23c9b2071b
commit
725d85181d
16 files changed
+219
-119
No files matched your search
@@ -29,7 +29,11 @@ public interface IClimateWorld {
|
||||
|
||||
IClimatedPosition getPosition(BlockPos pos);
|
||||
|
||||
void setChunk(ClimateChunk climateChunk);
|
||||
IClimatedPosition createPosition(BlockPos pos);
|
||||
|
||||
void addChunk(ClimateChunk climateChunk);
|
||||
|
||||
void removeChunk(ChunkPos pos);
|
||||
|
||||
@Nonnull
|
||||
Map<ChunkPos, ClimateChunk> getClimateChunks();
|
||||
@@ -52,6 +56,14 @@ public interface IClimateWorld {
|
||||
this.world = world;
|
||||
this.chunkPos = chunkPos;
|
||||
climates = new HashMap<>();
|
||||
for(int x = chunkPos.getXStart();x < chunkPos.getXEnd();x++){
|
||||
for(int y = 0;y < world.getWorld().getActualHeight();y++){
|
||||
for(int z = chunkPos.getZStart();z < chunkPos.getZEnd();z++){
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
climates.put(pos, world.createPosition(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addPosition(IClimatedPosition position){
|
||||
|
||||
@@ -22,6 +22,10 @@ public interface IClimatedPosition extends INbtReadable, INbtWritable {
|
||||
@Nonnull
|
||||
BlockPos getPos();
|
||||
|
||||
void addHandler(IClimateHandler climateHandler);
|
||||
|
||||
void removeHandler(IClimateHandler climateHandler);
|
||||
|
||||
void setTemperature(float temperature);
|
||||
|
||||
float getTemperature();
|
||||
|
||||
@@ -2,7 +2,7 @@ package forestry.core.climate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import java.util.Map.Entry;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimateWorld.ClimateChunk;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
@@ -22,10 +22,11 @@ public class ClimateEventHandler {
|
||||
int dimensionID = event.getWorld().provider.getDimension();
|
||||
World world = event.getWorld();
|
||||
Chunk chunk = event.getChunk();
|
||||
ChunkPos chunkPos = new ChunkPos(event.getChunk().xPosition, event.getChunk().zPosition);
|
||||
IClimateWorld climateWorld = ClimateManager.getOrCreateWorld(world);
|
||||
|
||||
if(climateWorld != null){
|
||||
ClimateChunk climateChunk = climateWorld.getClimateChunks().get(new ChunkPos(event.getChunk().xPosition, event.getChunk().zPosition));
|
||||
ClimateChunk climateChunk = climateWorld.getClimateChunks().get(chunkPos);
|
||||
if(climateChunk != null){
|
||||
NBTTagCompound forestryTag = new NBTTagCompound();
|
||||
event.getData().setTag("Forestry", forestryTag);
|
||||
@@ -45,10 +46,13 @@ public class ClimateEventHandler {
|
||||
}
|
||||
|
||||
forestryTag.setTag("Positions", forestryTag);
|
||||
if(!chunk.isLoaded()){
|
||||
climateWorld.removeChunk(chunkPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void chunkLoad(ChunkDataEvent.Load event){
|
||||
int dimensionID = event.getWorld().provider.getDimension();
|
||||
@@ -82,11 +86,14 @@ public class ClimateEventHandler {
|
||||
if(climateChunk == null){
|
||||
climateChunk = new ClimateChunk(climateWorld, chunkPos);
|
||||
}else{
|
||||
climateChunk.getClimates().clear();
|
||||
for(Entry<BlockPos, IClimatedPosition> entry : positions.entrySet()){
|
||||
climateChunk.getClimates().replace(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
climateChunk.getClimates().putAll(positions);
|
||||
climateWorld.setChunk(climateChunk);
|
||||
climateWorld.addChunk(climateChunk);
|
||||
}else{
|
||||
climateWorld.addChunk(new ClimateChunk(climateWorld, chunkPos));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,6 @@ 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.greenhouse.GreenhouseManager;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
@@ -64,6 +61,9 @@ public class ClimateManager implements IClimateManager{
|
||||
}
|
||||
|
||||
public static IClimateWorld getOrCreateWorld(World world){
|
||||
if(world == null){
|
||||
return null;
|
||||
}
|
||||
IClimateWorld climateWorld = ForestryAPI.climateManager.getClimateWorlds().get(Integer.valueOf(world.provider.getDimension()));
|
||||
|
||||
if(climateWorld == null){
|
||||
|
||||
@@ -21,8 +21,7 @@ public class ClimateWorld implements IClimateWorld{
|
||||
|
||||
@Override
|
||||
public void addPosition(BlockPos pos){
|
||||
Biome biome = world.getBiome(pos);
|
||||
addPosition(new ClimatedPosition(this, pos, biome.getTemperature(), biome.getRainfall()));
|
||||
addPosition(createPosition(pos));
|
||||
}
|
||||
|
||||
protected ClimateChunk getOrCreateChunk(ChunkPos chunkPos){
|
||||
@@ -33,6 +32,12 @@ public class ClimateWorld implements IClimateWorld{
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimatedPosition createPosition(BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
return new ClimatedPosition(this, pos, biome.getTemperature(), biome.getRainfall());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPositions(BlockPos minPos, BlockPos maxPos) {
|
||||
@@ -79,6 +84,14 @@ public class ClimateWorld implements IClimateWorld{
|
||||
}
|
||||
climateChunks.put(climateChunk.getChunkPos(), climateChunk);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChunk(ChunkPos chunkPos) {
|
||||
if(chunkPos == null){
|
||||
return;
|
||||
}
|
||||
climateChunks.remove(chunkPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<ChunkPos, ClimateChunk> getClimateChunks() {
|
||||
|
||||
@@ -11,22 +11,20 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.api.multiblock.IMultiblockLogic;
|
||||
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;
|
||||
|
||||
@@ -38,6 +36,7 @@ public class ClimatedPosition implements IClimatedPosition {
|
||||
protected final BlockPos pos;
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
protected List<IClimateHandler> handlers;
|
||||
|
||||
public ClimatedPosition(IClimateWorld climateWorld, BlockPos pos) {
|
||||
this.climateWorld = climateWorld;
|
||||
@@ -101,6 +100,22 @@ public class ClimatedPosition implements IClimatedPosition {
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHandler(IClimateHandler climateHandler) {
|
||||
if(climateHandler == null){
|
||||
return;
|
||||
}
|
||||
handlers.add(climateHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHandler(IClimateHandler climateHandler) {
|
||||
if(climateHandler == null){
|
||||
return;
|
||||
}
|
||||
handlers.remove(climateHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate() {
|
||||
boolean canHold = false;
|
||||
@@ -112,22 +127,7 @@ public class ClimatedPosition implements IClimatedPosition {
|
||||
}
|
||||
}
|
||||
}
|
||||
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{
|
||||
if(!canHold){
|
||||
Biome biome = climateWorld.getWorld().getBiome(pos);
|
||||
float biomeTemperature = biome.getTemperature();
|
||||
float biomeHumidity = biome.getRainfall();
|
||||
@@ -148,6 +148,13 @@ public class ClimatedPosition implements IClimatedPosition {
|
||||
}
|
||||
}
|
||||
}
|
||||
for(IClimateHandler handler : getHandlers()){
|
||||
if(handler != null){
|
||||
if(handler.canHandle(this)){
|
||||
handler.updateClimate(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,10 +173,19 @@ public class ClimatedPosition implements IClimatedPosition {
|
||||
}
|
||||
}
|
||||
IGreenhouseController greenhouse = GreenhouseManager.greenhouseHelper.getGreenhouseController(climateWorld.getWorld(), pos);
|
||||
|
||||
if(greenhouse != null){
|
||||
handlers.add(greenhouse);
|
||||
}
|
||||
}
|
||||
handlers.addAll(this.handlers);
|
||||
Iterator<IClimateHandler> iHandlers = handlers.iterator();
|
||||
while(iHandlers.hasNext()){
|
||||
IClimateHandler handler = iHandlers.next();
|
||||
if(!handler.canHandle(this)){
|
||||
iHandlers.remove();
|
||||
}
|
||||
}
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ public interface IClimateHandler {
|
||||
|
||||
boolean canHandle(IClimatedPosition position);
|
||||
|
||||
void updateClimate(IClimatedPosition position);
|
||||
|
||||
boolean canHoldClimate(IClimatedPosition position);
|
||||
|
||||
}
|
||||
@@ -103,13 +103,18 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldClimate(IClimatedPosition position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(IClimatedPosition position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldClimate(IClimatedPosition position) {
|
||||
return false;
|
||||
public void updateClimate(IClimatedPosition position) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,6 @@ import net.minecraftforge.fluids.FluidRegistry;
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
@@ -51,7 +50,6 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.core.access.EnumAccess;
|
||||
import forestry.core.climate.ClimateManager;
|
||||
import forestry.core.climate.ClimateWorld;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
@@ -396,14 +394,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
super.onMachineAssembled();
|
||||
|
||||
createLogics();
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
IClimateWorld climateWorld = ClimateManager.getOrCreateWorld(worldObj);
|
||||
|
||||
for(IInternalBlock internalBlock : internalBlocks){
|
||||
if(climateWorld.getPosition(internalBlock.getPos()) != null){
|
||||
climateWorld.addPosition(internalBlock.getPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -720,4 +710,53 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
protected void isBlockGoodForInterior(World world, BlockPos pos) throws MultiblockValidationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return getReferenceCoord();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateWorld getWorld() {
|
||||
return ClimateManager.getOrCreateWorld(worldObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(IClimatedPosition position) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate(IClimatedPosition position) {
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos facePos = position.getPos().offset(facing);
|
||||
if(isInternalBlock(facePos)){
|
||||
IClimatedPosition climatedPosition = position.getClimateWorld().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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInternalBlock(BlockPos pos){
|
||||
for(IInternalBlock internalBlock : internalBlocks){
|
||||
if(internalBlock != null && internalBlock.getPos().equals(pos)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHoldClimate(IClimatedPosition position) {
|
||||
return isInternalBlock(position.getPos());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,7 +103,7 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry<Multib
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,18 +36,10 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
}
|
||||
|
||||
protected interface IClimitiserDefinition {
|
||||
float getChangePerTransfer();
|
||||
|
||||
float getBoundaryUp();
|
||||
|
||||
float getBoundaryDown();
|
||||
|
||||
float getMaxChange();
|
||||
float getChange();
|
||||
|
||||
int getClimitiseRange();
|
||||
|
||||
float getClimitiseBonus();
|
||||
|
||||
ClimitiserType getType();
|
||||
}
|
||||
|
||||
@@ -130,9 +122,9 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
int maxDistance = definition.getClimitiseRange();
|
||||
if(distance <= maxDistance){
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
position.setTemperature(position.getTemperature() + (float) (definition.getMaxChange() / (distance / definition.getClimitiseBonus())));
|
||||
position.setTemperature(position.getTemperature() + (float) (definition.getChange() / distance));
|
||||
}else{
|
||||
position.setHumidity(position.getHumidity() + (float) (definition.getMaxChange() / (distance / definition.getClimitiseBonus())));
|
||||
position.setHumidity(position.getHumidity() + (float) (definition.getChange() / distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,18 +21,13 @@ public class TileGreenhouseDryer extends TileGreenhouseClimatiser {
|
||||
private static class DryerDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return -0.01f;
|
||||
public float getChange() {
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
public int getClimitiseRange() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,18 +22,13 @@ public class TileGreenhouseFan extends TileGreenhouseClimatiser {
|
||||
private static class FanDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return -0.01f;
|
||||
public float getChange() {
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
public int getClimitiseRange() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -151,7 +151,7 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase<MultiblockLogi
|
||||
Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type));
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,26 +19,21 @@ public class TileGreenhouseHeater extends TileGreenhouseClimatiser {
|
||||
}
|
||||
|
||||
private static class HeaterDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return 0.01f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimitiserType getType() {
|
||||
return ClimitiserType.TEMPERATURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChange() {
|
||||
return 0.15F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClimitiseRange() {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,15 +14,16 @@ import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
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.climate.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.core.climate.IClimateWorld;
|
||||
import forestry.api.core.climate.IClimatedPosition;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.climate.ClimateManager;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -51,19 +52,48 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tick, G greenhouse) {
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) greenhouse;
|
||||
if (workingTime < 20 && consumeWaterToDoWork(WORK_CYCLES, WATER_PER_OPERATION, (StandardTank) greenhouseInternal.getTankManager().getTank(0))) {
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += WATER_PER_OPERATION * 2;
|
||||
public void changeClimate(int tick, IGreenhouseController greenhouse) {
|
||||
if(minPos != null && maxPos != null){
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) greenhouse;
|
||||
if (workingTime == 0 && consumeWaterToDoWork(WORK_CYCLES, WATER_PER_OPERATION, (StandardTank) greenhouseInternal.getTankManager().getTank(0))) {
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
IClimateWorld climateWorld = ClimateManager.getOrCreateWorld(worldObj);
|
||||
|
||||
for(BlockPos pos : BlockPos.getAllInBox(maxPos, minPos)){
|
||||
IClimatedPosition position = climateWorld.getPosition(pos);
|
||||
if(position != null){
|
||||
if(position.getHumidity() >= 2.0F){
|
||||
if(position.getHumidity() > 2.0F){
|
||||
position.setHumidity(2.0F);
|
||||
}
|
||||
continue;
|
||||
}else if(position.getHumidity() <= 0.0F){
|
||||
if(position.getHumidity() < 0.0F){
|
||||
position.setHumidity(0.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
double distance = pos.distanceSq(pos);
|
||||
int maxDistance = definition.getClimitiseRange();
|
||||
if(distance <= maxDistance){
|
||||
position.setHumidity(position.getHumidity() + (float) (definition.getChange() / distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += WATER_PER_OPERATION * 2;
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}else if(isActive()){
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
greenhouse.addHumidityChange(definition.getChangePerTransfer(), definition.getBoundaryDown(), definition.getBoundaryUp());
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -122,26 +152,21 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {
|
||||
}
|
||||
|
||||
private static class SprinklerDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChangePerTransfer() {
|
||||
return 0.02f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClimitiserType getType() {
|
||||
return ClimitiserType.HUMIDITY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getChange() {
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClimitiseRange() {
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user