mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-17 02:45:17 +00:00
Revert greenhouse climate changes. Close #1319
This commit is contained in:
1 parent
8639148f20
commit
f400241ff4
47 files changed
+515
-952
No files matched your search
@@ -11,6 +11,7 @@
|
||||
package forestry;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
@@ -26,7 +27,6 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.climate.ClimateEventHandler;
|
||||
import forestry.core.config.Config;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.config.GameMode;
|
||||
@@ -83,7 +83,6 @@ public class Forestry {
|
||||
EventHandlerCore eventHandlerCore = new EventHandlerCore();
|
||||
MinecraftForge.EVENT_BUS.register(eventHandlerCore);
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ClimateEventHandler());
|
||||
|
||||
configFolder = new File(event.getModConfigurationDirectory(), Constants.MOD_ID);
|
||||
Config.load();
|
||||
@@ -91,7 +90,7 @@ public class Forestry {
|
||||
PluginManager.runSetup(event);
|
||||
|
||||
ForestryAPI.activeMode = new GameMode(Config.gameMode);
|
||||
|
||||
|
||||
PluginManager.runPreInit();
|
||||
|
||||
Proxies.render.registerModels();
|
||||
|
||||
@@ -7,7 +7,6 @@ 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;
|
||||
|
||||
|
||||
+8
-3
@@ -1,9 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
* 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
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.api.core.climate;
|
||||
package forestry.api.core;
|
||||
|
||||
public interface IClimateControlled {
|
||||
/**
|
||||
+6
-15
@@ -3,24 +3,15 @@
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core.climate;
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* A climate source is used to change the climate in a region.
|
||||
*/
|
||||
public interface IClimateSource {
|
||||
|
||||
/**
|
||||
* @param tickCount The current tick count.
|
||||
* @param region The climate region, in that the source stands.
|
||||
*/
|
||||
void changeClimate(int tickCount, IClimateRegion region);
|
||||
|
||||
World getWorld();
|
||||
|
||||
BlockPos getPos();
|
||||
public interface IClimateManager {
|
||||
|
||||
float getTemperature(World world, BlockPos pos);
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateManager {
|
||||
|
||||
float getTemperature(World world, BlockPos pos);
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
void addRegion(IClimateRegion region);
|
||||
|
||||
void removeRegion(IClimateRegion region);
|
||||
|
||||
void addSource(IClimateSource source);
|
||||
|
||||
void removeSource(IClimateSource source);
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegionForPos(World world, BlockPos pos);
|
||||
|
||||
@Nonnull
|
||||
Map<Integer, List<IClimateRegion>> getRegions();
|
||||
|
||||
@Nonnull
|
||||
Map<Integer, Map<BlockPos, IClimateSource>> getSources();
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public interface IClimatePosition extends INbtReadable, INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
IClimateRegion getClimateRegion();
|
||||
|
||||
@Nonnull
|
||||
BlockPos getPos();
|
||||
|
||||
void setTemperature(float temperature);
|
||||
|
||||
void addTemperature(float temperature);
|
||||
|
||||
float getTemperature();
|
||||
|
||||
void setHumidity(float humidity);
|
||||
|
||||
void addHumidity(float humidity);
|
||||
|
||||
float getHumidity();
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.INbtReadable;
|
||||
import forestry.api.core.INbtWritable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateRegion extends INbtReadable, INbtWritable {
|
||||
|
||||
@Nonnull
|
||||
World getWorld();
|
||||
|
||||
/**
|
||||
* Update the climate in a region, all 20 world ticks.
|
||||
*/
|
||||
void updateClimate();
|
||||
|
||||
@Nonnull
|
||||
Map<BlockPos, IClimatePosition> getPositions();
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public class DefaultGreenhouseListener implements IGreenhouseListener {
|
||||
|
||||
@Override
|
||||
public boolean canWork(IGreenhouseController greenhouse, boolean canWork) {
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,14 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.ICamouflagedTile;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
|
||||
public class GreenhouseEvents extends Event {
|
||||
|
||||
@Nullable
|
||||
public final IGreenhouseController controller;
|
||||
public final IGreenhouseState state;
|
||||
|
||||
public GreenhouseEvents(@Nullable IGreenhouseController state) {
|
||||
this.controller = state;
|
||||
public GreenhouseEvents(@Nullable IGreenhouseState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public static class CamouflageChangeEvent extends GreenhouseEvents{
|
||||
@@ -38,8 +37,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public final EnumCamouflageType camouflageType;
|
||||
|
||||
public CamouflageChangeEvent(IGreenhouseController controller, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull EnumCamouflageType camouflageType) {
|
||||
super(controller);
|
||||
public CamouflageChangeEvent(IGreenhouseState state, @Nullable ICamouflagedTile camouflagedBlock, @Nonnull ICamouflageHandler camouflageHandler, @Nonnull EnumCamouflageType camouflageType) {
|
||||
super(state);
|
||||
|
||||
this.camouflagedBlock = camouflagedBlock;
|
||||
this.camouflageHandler = camouflageHandler;
|
||||
@@ -52,8 +51,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public IInternalBlock internalBlock;
|
||||
|
||||
public InternalBlockEvent(IGreenhouseController controller, @Nonnull IInternalBlock internalBlock) {
|
||||
super(controller);
|
||||
public InternalBlockEvent(IGreenhouseState state, @Nonnull IInternalBlock internalBlock) {
|
||||
super(state);
|
||||
|
||||
this.internalBlock = internalBlock;
|
||||
}
|
||||
@@ -61,8 +60,8 @@ public class GreenhouseEvents extends Event {
|
||||
|
||||
public static class CreateInternalBlockEvent extends InternalBlockEvent{
|
||||
|
||||
public CreateInternalBlockEvent(IGreenhouseController controller, IInternalBlock internalBlock) {
|
||||
super(controller, internalBlock);
|
||||
public CreateInternalBlockEvent(IGreenhouseState state, IInternalBlock internalBlock) {
|
||||
super(state, internalBlock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +70,8 @@ public class GreenhouseEvents extends Event {
|
||||
@Nonnull
|
||||
public final IInternalBlockFace face;
|
||||
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseController controller, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
|
||||
super(controller, internalBlock);
|
||||
public CheckInternalBlockFaceEvent(IGreenhouseState state, IInternalBlock internalBlock, @Nonnull IInternalBlockFace face) {
|
||||
super(state, internalBlock);
|
||||
|
||||
this.face = face;
|
||||
}
|
||||
|
||||
@@ -5,15 +5,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IGreenhouseHelper {
|
||||
|
||||
/**
|
||||
* @return A {@link IGreenhouseController} of a greenhouse, when the pos is a greenhouse
|
||||
* @return A {@link IGreenhouseState} of a greenhouse, when the pos is a greenhouse
|
||||
*/
|
||||
IGreenhouseController getGreenhouseController(World world, BlockPos pos);
|
||||
IGreenhouseState getGreenhouseState(World world, BlockPos pos);
|
||||
|
||||
}
|
||||
@@ -10,12 +10,12 @@ import forestry.api.multiblock.IGreenhouseController;
|
||||
public interface IGreenhouseListener {
|
||||
|
||||
/**
|
||||
* Called before the greenhouse update the climate system.
|
||||
* Called before the greenhouse work.
|
||||
*
|
||||
* @param greenhouse The greenhouse of the listener.
|
||||
* @param greenhouse The greenhouse multiblock.
|
||||
* @param canWork The actual {@link Boolean} value.
|
||||
* @return True if the greenhouse can update the climate.
|
||||
* @return True if the greenhouse can work.
|
||||
*/
|
||||
boolean canWork(IGreenhouseController greenhouse, boolean canWork);
|
||||
<G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.greenhouse;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
|
||||
public interface IGreenhouseState {
|
||||
|
||||
EnumTemperature getTemperature();
|
||||
|
||||
EnumHumidity getHumidity();
|
||||
|
||||
float getExactTemperature();
|
||||
|
||||
float getExactHumidity();
|
||||
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
Collection<IMultiblockComponent> getGreenhouseComponents();
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ package forestry.api.greenhouse;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@@ -7,7 +7,7 @@ package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.apiculture.IBeeListener;
|
||||
import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
|
||||
/**
|
||||
* Needs to be implemented by TileEntities that want to be part of an alveary.
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.multiblock;
|
||||
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseListener;
|
||||
import forestry.api.lepidopterology.IButterflyCocoon;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -21,7 +22,8 @@ public interface IGreenhouseComponent<T extends IMultiblockLogicGreenhouse> exte
|
||||
interface Door extends IGreenhouseComponent {
|
||||
}
|
||||
|
||||
interface Climatiser extends IGreenhouseComponent, IClimateSource {
|
||||
interface Climatiser extends IGreenhouseComponent {
|
||||
<G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tickCount, G greenhouse);
|
||||
}
|
||||
|
||||
interface ButterflyHatch extends IGreenhouseComponent {
|
||||
|
||||
@@ -7,15 +7,13 @@ package forestry.api.multiblock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import forestry.api.core.ICamouflageHandler;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler {
|
||||
public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlled {
|
||||
|
||||
/**
|
||||
* Handle change events.
|
||||
@@ -26,8 +24,5 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous
|
||||
* @return The logics of the greenhouse.
|
||||
*/
|
||||
List<IGreenhouseLogic> getLogics();
|
||||
|
||||
@Nullable
|
||||
IClimateRegion getRegion();
|
||||
|
||||
}
|
||||
@@ -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.climate.IClimateControlled;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.apiculture.AlvearyBeeModifier;
|
||||
|
||||
@@ -14,7 +14,8 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import forestry.api.core.climate.IClimateControlled;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.network.packets.PacketActiveUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -21,7 +21,8 @@ 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.climate.IClimateControlled;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.apiculture.blocks.BlockAlvearyType;
|
||||
import forestry.apiculture.gui.ContainerAlvearyHygroregulator;
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.BlockHorizontal;
|
||||
import net.minecraft.block.BlockFenceGate;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.BlockSlab;
|
||||
import net.minecraft.block.BlockStairs;
|
||||
@@ -57,8 +57,9 @@ import forestry.apiculture.flowers.Flower;
|
||||
import forestry.apiculture.flowers.FlowerRegistry;
|
||||
import forestry.apiculture.tiles.TileBeeHouse;
|
||||
import forestry.arboriculture.PluginArboriculture;
|
||||
import forestry.arboriculture.blocks.log.BlockArbLog;
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.blocks.BlockBase;
|
||||
import forestry.core.blocks.BlockCore;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.tiles.TileUtil;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
@@ -142,9 +143,9 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
fillWithBlocks(world, structBoundingBox, 8, 1, 6, 8, 1, 10, fence, fence, false);
|
||||
fillWithBlocks(world, structBoundingBox, 2, 1, 10, 7, 1, 10, fence, fence, false);
|
||||
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockHorizontal.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.EAST), 8, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.EAST), 1, 1, 8, structBoundingBox);
|
||||
setBlockState(world, fenceGate.withProperty(BlockFenceGate.FACING, EnumFacing.NORTH), 4, 1, 10, structBoundingBox);
|
||||
|
||||
// Flowers
|
||||
plantFlowerGarden(world, structBoundingBox, 2, 1, 5, 7, 1, 9);
|
||||
@@ -173,7 +174,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
IBlockState slabCeiling = slabs.withProperty(BlockSlab.HALF, BlockSlab.EnumBlockHalf.TOP);
|
||||
fillWithBlocks(world, structBoundingBox, 1, 4, 1, 7, 4, 4, slabCeiling, slabCeiling, false);
|
||||
|
||||
IBlockState logBracing = logs.withProperty(BlockLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
IBlockState logBracing = logs.withProperty(BlockArbLog.LOG_AXIS, BlockLog.EnumAxis.X);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 1, 8, 4, 1, logBracing, logBracing, false);
|
||||
fillWithBlocks(world, structBoundingBox, 0, 4, 4, 8, 4, 4, logBracing, logBracing, false);
|
||||
|
||||
@@ -221,7 +222,7 @@ public class VillageApiaristHouse extends StructureVillagePieces.House1 {
|
||||
|
||||
// Escritoire
|
||||
if (random.nextInt(2) == 0) {
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockBase.FACING, EnumFacing.EAST);
|
||||
IBlockState escritoireBlock = PluginCore.blocks.escritoire.getDefaultState().withProperty(BlockCore.FACING, EnumFacing.EAST);
|
||||
setBlockState(world, escritoireBlock, 1, 1, 3, structBoundingBox);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*******************************************************************************
|
||||
* 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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,6 @@ 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;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
public class ClimateEventHandler {
|
||||
|
||||
Map<Integer, Integer> serverTicks;
|
||||
|
||||
public ClimateEventHandler() {
|
||||
serverTicks = new HashMap<>();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
int dim = event.world.provider.getDimension();
|
||||
if (event.phase == TickEvent.Phase.END) {
|
||||
if(!serverTicks.containsKey(Integer.valueOf(dim))){
|
||||
serverTicks.put(Integer.valueOf(dim), 1);
|
||||
}
|
||||
int ticks = serverTicks.get(Integer.valueOf(dim));
|
||||
if(ticks % 20 == 0){
|
||||
for(IClimateRegion region : ForestryAPI.climateManager.getRegions().get(Integer.valueOf(dim))){
|
||||
region.updateClimate();
|
||||
}
|
||||
}
|
||||
if(ForestryAPI.climateManager.getSources().get(Integer.valueOf(dim)) != null){
|
||||
for(IClimateSource source : ForestryAPI.climateManager.getSources().get(Integer.valueOf(dim)).values()){
|
||||
source.changeClimate(ticks, ForestryAPI.climateManager.getRegionForPos(event.world, source.getPos()));
|
||||
}
|
||||
}
|
||||
serverTicks.put(Integer.valueOf(dim), ticks+1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,144 +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 net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.climate.IClimateManager;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
protected Map<Integer, List<IClimateRegion>> regions;
|
||||
protected Map<Integer, Map<BlockPos, IClimateSource>> sources;
|
||||
|
||||
public ClimateManager() {
|
||||
regions = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRegion(IClimateRegion region) {
|
||||
if(region == null){
|
||||
return;
|
||||
}
|
||||
List<IClimateRegion> regions = getOrCreateRegions(region.getWorld());
|
||||
Set<BlockPos> positions = region.getPositions().keySet();
|
||||
for(IClimateRegion otherRegion : regions){
|
||||
for(BlockPos pos : otherRegion.getPositions().keySet()){
|
||||
if(positions.contains(pos)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!regions.contains(region)){
|
||||
regions.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRegion(IClimateRegion region) {
|
||||
if(region == null){
|
||||
return;
|
||||
}
|
||||
List<IClimateRegion> regions = getOrCreateRegions(region.getWorld());
|
||||
if(regions.contains(region)){
|
||||
regions.remove(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSource(IClimateSource source) {
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())) == null){
|
||||
sources.put(Integer.valueOf(source.getWorld().provider.getDimension()), new HashMap<>());
|
||||
}
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).keySet().contains(source.getPos())){
|
||||
sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).remove(source.getPos(), source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSource(IClimateSource source) {
|
||||
if(sources.get(Integer.valueOf(source.getWorld().provider.getDimension())) == null){
|
||||
sources.put(Integer.valueOf(source.getWorld().provider.getDimension()), new HashMap<>());
|
||||
}
|
||||
if(!sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).keySet().contains(source.getPos())){
|
||||
sources.get(Integer.valueOf(source.getWorld().provider.getDimension())).put(source.getPos(), source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
|
||||
if(position != null){
|
||||
return position.getTemperature();
|
||||
}
|
||||
}
|
||||
return biome.getTemperature();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
Biome biome = world.getBiome(pos);
|
||||
IClimateRegion region = getRegionForPos(world, pos);
|
||||
if(region!= null){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
|
||||
if(position != null){
|
||||
return position.getHumidity();
|
||||
}
|
||||
}
|
||||
return biome.getRainfall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, List<IClimateRegion>> getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegionForPos(World world, BlockPos pos){
|
||||
for(IClimateRegion region : getOrCreateRegions(world)){
|
||||
if(region.getPositions().keySet().contains(pos)){
|
||||
return region;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<IClimateRegion> getOrCreateRegions(World world){
|
||||
List<IClimateRegion> regions = this.regions.get(Integer.valueOf(world.provider.getDimension()));
|
||||
if(regions == null){
|
||||
regions = new ArrayList<>();
|
||||
this.regions.put(Integer.valueOf(world.provider.getDimension()), regions);
|
||||
}
|
||||
return regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, Map<BlockPos, IClimateSource>> getSources() {
|
||||
return sources;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,96 +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 javax.annotation.Nonnull;
|
||||
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class ClimatePosition implements IClimatePosition {
|
||||
|
||||
@Nonnull
|
||||
protected final IClimateRegion climateRegion;
|
||||
@Nonnull
|
||||
protected final BlockPos pos;
|
||||
protected float temperature;
|
||||
protected float humidity;
|
||||
|
||||
public ClimatePosition(IClimateRegion climateRegion, BlockPos pos) {
|
||||
this.climateRegion = climateRegion;
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public ClimatePosition(@Nonnull IClimateRegion climateRegion, @Nonnull BlockPos pos, float temperature, float humidity) {
|
||||
this.climateRegion = climateRegion;
|
||||
this.pos = pos;
|
||||
this.temperature = temperature;
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IClimateRegion getClimateRegion() {
|
||||
return climateRegion;
|
||||
}
|
||||
|
||||
@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 addTemperature(float temperature) {
|
||||
setTemperature(getTemperature() + temperature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addHumidity(float humidity) {
|
||||
setHumidity(getHumidity() + humidity);
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("Temperature", temperature);
|
||||
nbt.setFloat("Humidity", humidity);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
package forestry.core.climate;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
public class ClimateRoom implements IClimateRegion {
|
||||
|
||||
protected World world;
|
||||
protected IGreenhouseController controller;
|
||||
protected Map<BlockPos, IClimatePosition> positions;
|
||||
|
||||
public ClimateRoom(ClimateRoom room, Map<BlockPos, IClimatePosition> innerPositions) {
|
||||
this.world = room.getWorld();
|
||||
this.controller = room.controller;
|
||||
Map<BlockPos, IClimatePosition> newPositions = new HashMap<>();
|
||||
for(Entry<BlockPos, IClimatePosition> positionEntry : innerPositions.entrySet()){
|
||||
IClimatePosition position = this.positions.get(positionEntry.getKey());
|
||||
if(position == null){
|
||||
newPositions.put(positionEntry.getKey(), positionEntry.getValue());
|
||||
}else{
|
||||
newPositions.put(positionEntry.getKey(), position);
|
||||
}
|
||||
}
|
||||
this.positions = newPositions;
|
||||
}
|
||||
|
||||
public ClimateRoom(IGreenhouseController controller, Map<BlockPos, IClimatePosition> innerPositions) {
|
||||
this.world = controller.getWorldObj();
|
||||
this.controller = controller;
|
||||
this.positions = innerPositions;
|
||||
}
|
||||
|
||||
public ClimateRoom(IGreenhouseController controller, NBTTagCompound nbtTag) {
|
||||
this.world = controller.getWorldObj();
|
||||
this.controller = controller;
|
||||
this.positions = new HashMap<>();
|
||||
readFromNBT(nbtTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateClimate() {
|
||||
for(Entry<BlockPos, IClimatePosition> position : positions.entrySet()){
|
||||
BlockPos pos = position.getKey();
|
||||
if(world.isBlockLoaded(pos)){
|
||||
updateSides(pos);
|
||||
if(!controller.isAssembled()){
|
||||
Biome biome = world.getBiome(pos);
|
||||
|
||||
float biomeTemperature = biome.getTemperature();
|
||||
float biomeHumidity = biome.getRainfall();
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
|
||||
if(climatedInfo.getTemperature() != biomeTemperature){
|
||||
if(climatedInfo.getTemperature() > biomeTemperature){
|
||||
climatedInfo.addTemperature(-0.01F);
|
||||
}else{
|
||||
climatedInfo.addTemperature(0.01F);
|
||||
}
|
||||
}
|
||||
|
||||
if(climatedInfo.getHumidity() != biomeHumidity){
|
||||
if(climatedInfo.getHumidity() > biomeHumidity){
|
||||
climatedInfo.addHumidity(-0.01F);
|
||||
}else{
|
||||
climatedInfo.addHumidity(0.01F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSides(BlockPos pos){
|
||||
IClimatePosition climatedInfo = positions.get(pos);
|
||||
for(EnumFacing facing : EnumFacing.VALUES){
|
||||
BlockPos facePos = pos.offset(facing);
|
||||
IClimatePosition climatedInfoFace = positions.get(facePos);
|
||||
if(climatedInfoFace != null){
|
||||
if(climatedInfo.getTemperature() > climatedInfoFace.getTemperature() + 0.01F){
|
||||
climatedInfo.addTemperature(-0.01F);
|
||||
climatedInfoFace.addTemperature(0.01F);
|
||||
}
|
||||
if(climatedInfo.getHumidity() > climatedInfoFace.getHumidity() + 0.01F){
|
||||
climatedInfo.addHumidity(-0.01F);
|
||||
climatedInfoFace.addHumidity(0.01F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
NBTTagList positionList = new NBTTagList();
|
||||
for(Entry<BlockPos, IClimatePosition> entry : positions.entrySet()){
|
||||
BlockPos pos = entry.getKey();
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("XPos", pos.getX());
|
||||
tag.setInteger("YPos", pos.getY());
|
||||
tag.setInteger("ZPos", pos.getZ());
|
||||
positionList.appendTag(entry.getValue().writeToNBT(tag));
|
||||
}
|
||||
nbt.setTag("Positions", positionList);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
NBTTagList positionList = nbt.getTagList("Positions", 10);
|
||||
for(int i = 0;i < positionList.tagCount();i++){
|
||||
NBTTagCompound positionTag = positionList.getCompoundTagAt(i);
|
||||
int xPos = positionTag.getInteger("XPos");
|
||||
int yPos = positionTag.getInteger("YPos");
|
||||
int zPos = positionTag.getInteger("ZPos");
|
||||
BlockPos pos = new BlockPos(xPos, yPos, zPos);
|
||||
ClimatePosition position = new ClimatePosition(this, pos);
|
||||
position.readFromNBT(positionTag);
|
||||
positions.put(pos, position);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BlockPos, IClimatePosition> getPositions() {
|
||||
return positions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -413,7 +413,7 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.assemblyState != AssemblyState.Assembled) {
|
||||
if (onlyUpdateWhenAssembled() && this.assemblyState != AssemblyState.Assembled) {
|
||||
// Not assembled - don't run game logic
|
||||
return;
|
||||
}
|
||||
@@ -842,4 +842,8 @@ public abstract class MultiblockControllerBase implements IMultiblockControllerI
|
||||
private static boolean isInvalid(IMultiblockComponent part) {
|
||||
return part instanceof TileEntity && ((TileEntity) part).isInvalid();
|
||||
}
|
||||
|
||||
protected boolean onlyUpdateWhenAssembled(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ import java.io.IOException;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
|
||||
@@ -23,6 +23,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.terraingen.PopulateChunkEvent;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import forestry.core.PluginCore;
|
||||
import forestry.core.blocks.BlockResourceOre;
|
||||
import forestry.core.blocks.EnumResourceType;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
|
||||
public class FakeGreenhouseState implements IGreenhouseState {
|
||||
|
||||
public static final FakeGreenhouseState instance = new FakeGreenhouseState();
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IMultiblockComponent> getGreenhouseComponents() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseHelper;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.multiblock.IMultiblockControllerInternal;
|
||||
import forestry.core.multiblock.MultiblockRegistry;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
@@ -24,13 +24,13 @@ import forestry.greenhouse.multiblock.InternalBlockCheck;
|
||||
public class GreenhouseHelper implements IGreenhouseHelper {
|
||||
|
||||
@Override
|
||||
public IGreenhouseController getGreenhouseController(World world, BlockPos pos) {
|
||||
public IGreenhouseState getGreenhouseState(World world, BlockPos pos) {
|
||||
if (MultiblockRegistry.getControllersFromWorld(world) != null) {
|
||||
for (IMultiblockControllerInternal controllerInternal : MultiblockRegistry.getControllersFromWorld(world)) {
|
||||
if (controllerInternal instanceof IGreenhouseControllerInternal) {
|
||||
if (controllerInternal.isAssembled()) {
|
||||
if (isPositionInGreenhouse((IGreenhouseControllerInternal) controllerInternal, pos)) {
|
||||
return (IGreenhouseController) controllerInternal;
|
||||
return ((IGreenhouseControllerInternal) controllerInternal).createState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.greenhouse.multiblock.GreenhouseController;
|
||||
|
||||
public final class GreenhouseState implements IGreenhouseState {
|
||||
|
||||
private final float humidity;
|
||||
private final float temperature;
|
||||
private final Set<IInternalBlock> internalBlocks;
|
||||
private final Collection<IMultiblockComponent> greenhouseComponents;
|
||||
|
||||
public GreenhouseState(float humidity, float temperature, Set<IInternalBlock> internalBlocks, Collection<IMultiblockComponent> greenhouseComponents) {
|
||||
this.humidity = humidity;
|
||||
this.temperature = temperature;
|
||||
this.internalBlocks = internalBlocks;
|
||||
this.greenhouseComponents = greenhouseComponents;
|
||||
}
|
||||
|
||||
public GreenhouseState(GreenhouseController controller) {
|
||||
this(controller.getExactHumidity(), controller.getExactTemperature(), controller.getInternalBlocks(), controller.getComponents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
return EnumTemperature.getFromValue(temperature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHumidity getHumidity() {
|
||||
return EnumHumidity.getFromValue(humidity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
return internalBlocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IMultiblockComponent> getGreenhouseComponents() {
|
||||
return greenhouseComponents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,11 +10,15 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.logics;
|
||||
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import forestry.api.greenhouse.DefaultGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseClimaLogic;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseDoor;
|
||||
|
||||
public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic {
|
||||
|
||||
@@ -26,7 +30,7 @@ public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implem
|
||||
|
||||
@Override
|
||||
public void work() {
|
||||
/*if (controller == null || !controller.isAssembled()) {
|
||||
if (controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
if (workTimer++ > 20) {
|
||||
@@ -42,7 +46,7 @@ public class GreenhouseLogicGreenhouseDoor extends DefaultGreenhouseLogic implem
|
||||
controller.addTemperatureChange(-0.0001F * openDoors, 0.05F, 2.5F);
|
||||
controller.addHumidityChange(-0.0001F * openDoors, 0.05F, 2.5F);
|
||||
workTimer = 0;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic impl
|
||||
|
||||
@Override
|
||||
public void work() {
|
||||
/*if (controller == null || !controller.isAssembled()) {
|
||||
if (controller == null || !controller.isAssembled()) {
|
||||
return;
|
||||
}
|
||||
if (controller.getWorldObj().isDaytime()) {
|
||||
@@ -44,7 +44,7 @@ public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic impl
|
||||
controller.addTemperatureChange(lightTransmittance / 100, 0F, 2.5F);
|
||||
workTimer = 0;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,17 +19,17 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.core.EnumCamouflageType;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseComponent.Listener;
|
||||
import forestry.core.fluids.FakeTankManager;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
import forestry.core.inventory.FakeInventoryAdapter;
|
||||
import forestry.core.inventory.IInventoryAdapter;
|
||||
import forestry.core.multiblock.FakeMultiblockController;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.greenhouse.FakeGreenhouseState;
|
||||
|
||||
public class FakeGreenhouseController extends FakeMultiblockController implements IGreenhouseControllerInternal {
|
||||
public static final FakeGreenhouseController instance = new FakeGreenhouseController();
|
||||
@@ -82,6 +82,20 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
@Override
|
||||
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() {
|
||||
return FakeGreenhouseState.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IInternalBlock> getInternalBlocks() {
|
||||
@@ -92,18 +106,4 @@ public class FakeGreenhouseController extends FakeMultiblockController implement
|
||||
public String getUnlocalizedType() {
|
||||
return "for.multiblock.greenhouse.type";
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Listener> getListenerComponents() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,11 @@ import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -28,23 +27,22 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.core.climate.IClimateSource;
|
||||
import forestry.api.greenhouse.EnumGreenhouseEventType;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CheckInternalBlockFaceEvent;
|
||||
import forestry.api.greenhouse.GreenhouseEvents.CreateInternalBlockEvent;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseLogic;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.greenhouse.IInternalBlockFace;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
@@ -52,8 +50,6 @@ 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.ClimateRoom;
|
||||
import forestry.core.climate.ClimatePosition;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.TankManager;
|
||||
import forestry.core.fluids.tanks.FilteredTank;
|
||||
@@ -72,6 +68,7 @@ import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.core.utils.Translator;
|
||||
import forestry.energy.EnergyManager;
|
||||
import forestry.greenhouse.GreenhouseState;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.inventory.InventoryGreenhouse;
|
||||
@@ -82,9 +79,13 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
private final Set<IInternalBlock> internalBlocks = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Listener> listenerComponents = new HashSet<>();
|
||||
private final Set<IGreenhouseComponent.Climatiser> climatiserComponents = new HashSet<>();
|
||||
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;
|
||||
@@ -94,10 +95,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
private ItemStack camouflagePlainBlock;
|
||||
private ItemStack camouflageGlassBlock;
|
||||
private ItemStack camouflageDoorBlock;
|
||||
private ClimateRoom region;
|
||||
|
||||
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);
|
||||
@@ -115,6 +117,14 @@ 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() {
|
||||
@@ -123,31 +133,45 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
|
||||
float temperature = 0.0F;
|
||||
|
||||
for(IInternalBlock internalBlock : internalBlocks){
|
||||
IClimatePosition position = region.getPositions().get(internalBlock.getPos());
|
||||
if(position != null){
|
||||
temperature+=position.getTemperature();
|
||||
}
|
||||
}
|
||||
return temperature / internalBlocks.size();
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords) + tempChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
float humidity = 0.0F;
|
||||
|
||||
for(IInternalBlock internalBlock : internalBlocks){
|
||||
IClimatePosition position = region.getPositions().get(internalBlock.getPos());
|
||||
if(position != null){
|
||||
humidity+=position.getHumidity();
|
||||
}
|
||||
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;
|
||||
}
|
||||
return humidity / internalBlocks.size();
|
||||
|
||||
change *= 0.95f;
|
||||
if (change <= 0.001f && change >= -0.001f) {
|
||||
change = 0;
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -166,6 +190,8 @@ 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);
|
||||
@@ -179,10 +205,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
logic.writeToNBT(nbtTag);
|
||||
data.setTag("logic" + logic.getName(), nbtTag);
|
||||
}
|
||||
|
||||
if(region != null){
|
||||
data.setTag("Region", region.writeToNBT(data));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -191,6 +213,8 @@ 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);
|
||||
@@ -206,11 +230,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
for (IGreenhouseLogic logic : getLogics()) {
|
||||
logic.readFromNBT(data.getCompoundTag("logic" + logic.getName()));
|
||||
}
|
||||
|
||||
if(data.hasKey("Region")){
|
||||
NBTTagCompound nbtTag = data.getCompoundTag("Region");
|
||||
region = new ClimateRoom(this, nbtTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -245,6 +264,8 @@ 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);
|
||||
@@ -255,6 +276,8 @@ 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);
|
||||
@@ -310,7 +333,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
}
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, null, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(createState(), null, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,6 +366,12 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
/* GREENHOUSE */
|
||||
@Nonnull
|
||||
@Override
|
||||
public IGreenhouseState createState() {
|
||||
return new GreenhouseState(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(EnumGreenhouseEventType type, Object event) {
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
@@ -404,26 +433,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
super.onMachineAssembled();
|
||||
|
||||
createLogics();
|
||||
if(region != null){
|
||||
Map<BlockPos, IClimatePosition> internalPositions = new HashMap<>();
|
||||
for(IInternalBlock block : internalBlocks){
|
||||
if(block != null){
|
||||
internalPositions.put(block.getPos(), new ClimatePosition(region, block.getPos()));
|
||||
}
|
||||
}
|
||||
ForestryAPI.climateManager.removeRegion(region);
|
||||
region = new ClimateRoom(region, internalPositions);
|
||||
ForestryAPI.climateManager.addRegion(region);
|
||||
}else{
|
||||
Map<BlockPos, IClimatePosition> internalPositions = new HashMap<>();
|
||||
for(IInternalBlock block : internalBlocks){
|
||||
if(block != null){
|
||||
internalPositions.put(block.getPos(), new ClimatePosition(region, block.getPos()));
|
||||
}
|
||||
}
|
||||
region = new ClimateRoom(this, internalPositions);
|
||||
ForestryAPI.climateManager.addRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -439,7 +448,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (newPart instanceof IGreenhouseComponent.Listener) {
|
||||
listenerComponents.add((IGreenhouseComponent.Listener) newPart);
|
||||
} else if (newPart instanceof IGreenhouseComponent.Climatiser) {
|
||||
ForestryAPI.climateManager.addSource((IClimateSource) newPart);
|
||||
climatiserComponents.add((IGreenhouseComponent.Climatiser) newPart);
|
||||
} else if (newPart instanceof IGreenhouseComponent.Active) {
|
||||
activeComponents.add((IGreenhouseComponent.Active) newPart);
|
||||
}
|
||||
@@ -450,7 +459,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
if (oldPart instanceof IGreenhouseComponent.Listener) {
|
||||
listenerComponents.remove(oldPart);
|
||||
} else if (oldPart instanceof IGreenhouseComponent.Climatiser) {
|
||||
ForestryAPI.climateManager.removeSource((IClimateSource) oldPart);
|
||||
climatiserComponents.remove(oldPart);
|
||||
} else if (oldPart instanceof IGreenhouseComponent.Active) {
|
||||
activeComponents.remove(oldPart);
|
||||
}
|
||||
@@ -458,38 +467,65 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
@Override
|
||||
protected void onAssimilate(IMultiblockControllerInternal assimilated) {
|
||||
if(assimilated != null && ((IGreenhouseControllerInternal)assimilated).getRegion() != null){
|
||||
IGreenhouseControllerInternal internal = (IGreenhouseControllerInternal) assimilated;
|
||||
if(region != null){
|
||||
ForestryAPI.climateManager.removeRegion(region);
|
||||
region = new ClimateRoom(region,internal.getRegion().getPositions());
|
||||
ForestryAPI.climateManager.addRegion(region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAssimilated(IMultiblockControllerInternal assimilator) {
|
||||
if(region != null){
|
||||
ForestryAPI.climateManager.removeRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean updateServer(int tickCount) {
|
||||
if (updateOnInterval(20)) {
|
||||
inventory.drainCan(tankManager);
|
||||
}
|
||||
|
||||
for (IGreenhouseLogic logic : logics) {
|
||||
logic.work();
|
||||
}
|
||||
|
||||
for (IGreenhouseComponent.Active activeComponent : activeComponents) {
|
||||
activeComponent.updateServer(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) {
|
||||
|
||||
return false;
|
||||
for (IGreenhouseComponent.Climatiser climatiser : climatiserComponents) {
|
||||
climatiser.changeClimate(tickCount, this);
|
||||
}
|
||||
|
||||
tempChange = equalizeChange(tempChange);
|
||||
humidChange = equalizeChange(humidChange);
|
||||
}
|
||||
|
||||
return canWork;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -661,7 +697,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
|
||||
isBlockGoodForInterior(worldObj, posRoot);
|
||||
for (IInternalBlockFace faceToCheck : blockToCheck.getFaces()) {
|
||||
CheckInternalBlockFaceEvent checkEvent = new CheckInternalBlockFaceEvent(this, blockToCheck, faceToCheck);
|
||||
CheckInternalBlockFaceEvent checkEvent = new CheckInternalBlockFaceEvent(createState(), blockToCheck, faceToCheck);
|
||||
MinecraftForge.EVENT_BUS.post(checkEvent);
|
||||
|
||||
if (!faceToCheck.isTested()) {
|
||||
@@ -699,7 +735,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
private IInternalBlock createInternalBlock(IInternalBlock internalBlock) {
|
||||
CreateInternalBlockEvent createEvent = new CreateInternalBlockEvent(this, internalBlock);
|
||||
CreateInternalBlockEvent createEvent = new CreateInternalBlockEvent(createState(), internalBlock);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(createEvent);
|
||||
|
||||
@@ -713,11 +749,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
}
|
||||
|
||||
public static ButterflyHatch getGreenhouseButterflyHatch(World world, BlockPos pos) {
|
||||
if (GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos) == null) {
|
||||
if (GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos) == null) {
|
||||
return null;
|
||||
}
|
||||
IGreenhouseController controller = GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos);
|
||||
for (IMultiblockComponent greenhouse : controller.getComponents()) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
for (IMultiblockComponent greenhouse : state.getGreenhouseComponents()) {
|
||||
if (greenhouse instanceof ButterflyHatch) {
|
||||
return (ButterflyHatch) greenhouse;
|
||||
}
|
||||
@@ -739,19 +775,4 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im
|
||||
protected void isBlockGoodForInterior(World world, BlockPos pos) throws MultiblockValidationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClimateRegion getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRegion() {
|
||||
region = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IGreenhouseComponent.Listener> getListenerComponents() {
|
||||
return listenerComponents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.access.IRestrictedAccess;
|
||||
import forestry.core.fluids.ITankManager;
|
||||
@@ -45,15 +45,15 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM
|
||||
@Nullable
|
||||
EnergyManager getEnergyManager();
|
||||
|
||||
|
||||
/**
|
||||
* @return The current state of the greenhouse controller.
|
||||
*/
|
||||
@Nonnull
|
||||
IGreenhouseState createState();
|
||||
|
||||
/**
|
||||
* @return All internal blocks of the greenhouse.
|
||||
*/
|
||||
Set<IInternalBlock> getInternalBlocks();
|
||||
|
||||
/**
|
||||
* Set the region to null.
|
||||
*/
|
||||
void clearRegion();
|
||||
|
||||
Set<IGreenhouseComponent.Listener> getListenerComponents();
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import forestry.api.greenhouse.IInternalBlock;
|
||||
import forestry.api.greenhouse.IInternalBlockFace;
|
||||
|
||||
|
||||
@@ -15,14 +15,13 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
|
||||
import net.minecraftforge.client.model.animation.AnimationTESR;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.greenhouse.PluginGreenhouse;
|
||||
import forestry.greenhouse.blocks.BlockGreenhouseType;
|
||||
import forestry.greenhouse.models.ModelGreenhouse;
|
||||
import forestry.greenhouse.tiles.TileGreenhouseSprinkler;
|
||||
import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public class ProxyGreenhouseClient extends ProxyGreenhouse {
|
||||
|
||||
@@ -34,10 +33,6 @@ public class ProxyGreenhouseClient extends ProxyGreenhouse {
|
||||
} else if (greenhouseType == BlockGreenhouseType.SPRINKLER) {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileGreenhouseSprinkler.class, new AnimationTESR<>());
|
||||
continue;
|
||||
}else if(greenhouseType == BlockGreenhouseType.BUTTERFLY_HATCH){
|
||||
if(!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Proxies.render.registerBlockModel(new BlockModelIndex(new ModelResourceLocation("forestry:greenhouse." + greenhouseType),
|
||||
new ModelResourceLocation("forestry:greenhouse", "inventory"), new ModelGreenhouse(),
|
||||
|
||||
@@ -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(), this, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,11 @@ package forestry.greenhouse.tiles;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import forestry.api.core.climate.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.apiculture.network.packets.PacketActiveUpdate;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.tiles.IActivatable;
|
||||
@@ -34,20 +33,17 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
}
|
||||
|
||||
protected interface IClimitiserDefinition {
|
||||
float getChange();
|
||||
|
||||
int getClimitiseRange();
|
||||
float getChangePerTransfer();
|
||||
|
||||
float getBoundaryUp();
|
||||
|
||||
float getBoundaryDown();
|
||||
|
||||
ClimitiserType getType();
|
||||
}
|
||||
|
||||
private final IClimitiserDefinition definition;
|
||||
|
||||
protected EnumFacing inwards;
|
||||
protected EnumFacing leftwards;
|
||||
protected BlockPos maxPos;
|
||||
protected BlockPos minPos;
|
||||
|
||||
protected int workingTime = 0;
|
||||
|
||||
private boolean active;
|
||||
@@ -57,95 +53,23 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineBroken() {
|
||||
inwards = null;
|
||||
leftwards = null;
|
||||
|
||||
minPos = null;
|
||||
maxPos = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMachineAssembled(IMultiblockController multiblockController, BlockPos minCoord, BlockPos maxCoord) {
|
||||
recalculateDirections(minCoord, maxCoord);
|
||||
|
||||
if(leftwards != null){
|
||||
maxPos = getPos().offset(inwards, definition.getClimitiseRange() / 2).offset(leftwards, definition.getClimitiseRange() / 2).offset(EnumFacing.UP, definition.getClimitiseRange() / 2);
|
||||
minPos = getPos().offset(inwards).offset(leftwards.getOpposite(), definition.getClimitiseRange() / 2).offset(EnumFacing.DOWN, definition.getClimitiseRange() / 2);
|
||||
|
||||
}else{
|
||||
maxPos = getPos().offset(inwards, definition.getClimitiseRange() / 2).offset(EnumFacing.EAST, definition.getClimitiseRange() / 2).offset(EnumFacing.NORTH, definition.getClimitiseRange() / 2);
|
||||
minPos = getPos().offset(inwards).offset(EnumFacing.WEST, definition.getClimitiseRange() / 2).offset(EnumFacing.SOUTH, definition.getClimitiseRange() / 2);
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing & IClimateControlled> void changeClimate(int tick, G greenhouse) {
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) greenhouse;
|
||||
if (workingTime < 20 && greenhouseInternal.getEnergyManager().consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += ENERGY_PER_OPERATION / 10;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tick, IClimateRegion region) {
|
||||
IMultiblockController controller = getMultiblockLogic().getController();
|
||||
if(getMultiblockLogic().isConnected() && controller != null && controller.isAssembled() && minPos != null && maxPos != null && region != null){
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
boolean canWork = true;
|
||||
for (IGreenhouseComponent.Listener listenerComponent : greenhouseInternal.getListenerComponents()) {
|
||||
if(canWork){
|
||||
canWork = listenerComponent.getGreenhouseListener().canWork(greenhouseInternal, canWork);
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
greenhouse.addTemperatureChange(definition.getChangePerTransfer(), definition.getBoundaryDown(), definition.getBoundaryUp());
|
||||
} else if (definition.getType() == ClimitiserType.HUMIDITY) {
|
||||
greenhouse.addHumidityChange(definition.getChangePerTransfer(), definition.getBoundaryDown(), definition.getBoundaryUp());
|
||||
}
|
||||
if (canWork && workingTime == 0 && greenhouseInternal.getEnergyManager().consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION)) {
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
|
||||
for(BlockPos pos : BlockPos.getAllInBox(maxPos, minPos)){
|
||||
IClimatePosition position = region.getPositions().get(pos);
|
||||
if(position != null){
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
if(position.getTemperature() >= 2.0F){
|
||||
if(position.getTemperature() > 2.0F){
|
||||
position.setTemperature(2.0F);
|
||||
}
|
||||
continue;
|
||||
}else if(position.getTemperature() <= 0.0F){
|
||||
if(position.getTemperature() < 0.0F){
|
||||
position.setTemperature(0.0F);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
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){
|
||||
if (definition.getType() == ClimitiserType.TEMPERATURE) {
|
||||
position.setTemperature(position.getTemperature() + (float) (definition.getChange() / distance));
|
||||
}else{
|
||||
position.setHumidity(position.getHumidity() + (float) (definition.getChange() / distance));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// one tick of work for every 10 RF
|
||||
workingTime += ENERGY_PER_OPERATION / 10;
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}else if(isActive()){
|
||||
setActive(false);
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}
|
||||
|
||||
/* LOADING & SAVING */
|
||||
@@ -183,41 +107,6 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat
|
||||
return active;
|
||||
}
|
||||
|
||||
public void recalculateDirections(BlockPos minCoord, BlockPos maxCoord) {
|
||||
inwards = null;
|
||||
leftwards = null;
|
||||
|
||||
int facesMatching = 0;
|
||||
if (maxCoord.getX() == getPos().getX() || minCoord.getX() == getPos().getX()) {
|
||||
facesMatching++;
|
||||
}
|
||||
if (maxCoord.getY() == getPos().getY() || minCoord.getY() == getPos().getY()) {
|
||||
facesMatching++;
|
||||
}
|
||||
if (maxCoord.getZ() == getPos().getZ() || minCoord.getZ() == getPos().getZ()) {
|
||||
facesMatching++;
|
||||
}
|
||||
if (facesMatching == 1) {
|
||||
if (maxCoord.getX() == getPos().getX()) {
|
||||
inwards = EnumFacing.WEST;
|
||||
leftwards = EnumFacing.SOUTH;
|
||||
} else if (minCoord.getX() == getPos().getX()) {
|
||||
inwards = EnumFacing.EAST;
|
||||
leftwards = EnumFacing.NORTH;
|
||||
} else if (maxCoord.getZ() == getPos().getZ()) {
|
||||
inwards = EnumFacing.NORTH;
|
||||
leftwards = EnumFacing.WEST;
|
||||
} else if (minCoord.getZ() == getPos().getZ()) {
|
||||
inwards = EnumFacing.SOUTH;
|
||||
leftwards = EnumFacing.EAST;
|
||||
} else if (maxCoord.getY() == getPos().getY()) {
|
||||
inwards = EnumFacing.DOWN;
|
||||
} else {
|
||||
inwards = EnumFacing.UP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IClimitiserDefinition getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouse
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWork(IGreenhouseController greenhouse, boolean canWork) {
|
||||
public <G extends IGreenhouseController & IGreenhouseHousing> boolean canWork(G greenhouse, boolean canWork) {
|
||||
return canWork && !hasRedstoneSignal();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,13 +21,18 @@ public class TileGreenhouseDryer extends TileGreenhouseClimatiser {
|
||||
private static class DryerDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChange() {
|
||||
return 0.15F;
|
||||
public float getChangePerTransfer() {
|
||||
return -0.01f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClimitiseRange() {
|
||||
return 5;
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,13 +22,18 @@ public class TileGreenhouseFan extends TileGreenhouseClimatiser {
|
||||
private static class FanDefinition implements IClimitiserDefinition {
|
||||
|
||||
@Override
|
||||
public float getChange() {
|
||||
return 0.15F;
|
||||
public float getChangePerTransfer() {
|
||||
return -0.01f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getClimitiseRange() {
|
||||
return 5;
|
||||
public float getBoundaryUp() {
|
||||
return 2.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBoundaryDown() {
|
||||
return 0.05f;
|
||||
}
|
||||
|
||||
@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(), this, this, type));
|
||||
MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(getMultiblockLogic().getController().createState(), this, this, type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,21 +19,26 @@ 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,16 +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.IClimatePosition;
|
||||
import forestry.api.core.climate.IClimateRegion;
|
||||
import forestry.api.multiblock.IGreenhouseComponent;
|
||||
import forestry.api.multiblock.IMultiblockController;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.greenhouse.IGreenhouseHousing;
|
||||
import forestry.api.multiblock.IGreenhouseController;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.proxy.Proxies;
|
||||
@@ -52,54 +52,19 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeClimate(int tick, IClimateRegion region) {
|
||||
IMultiblockController controller = getMultiblockLogic().getController();
|
||||
if(getMultiblockLogic().isConnected() && controller != null && controller.isAssembled() && minPos != null && maxPos != null && region != null){
|
||||
IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller;
|
||||
boolean canWork = true;
|
||||
for (IGreenhouseComponent.Listener listenerComponent : greenhouseInternal.getListenerComponents()) {
|
||||
if(canWork){
|
||||
canWork = listenerComponent.getGreenhouseListener().canWork(greenhouseInternal, canWork);
|
||||
}
|
||||
}
|
||||
if (canWork && workingTime == 0 && consumeWaterToDoWork(WORK_CYCLES, WATER_PER_OPERATION, (StandardTank) greenhouseInternal.getTankManager().getTank(0))) {
|
||||
int dimensionID = worldObj.provider.getDimension();
|
||||
|
||||
for(BlockPos pos : BlockPos.getAllInBox(maxPos, minPos)){
|
||||
IClimatePosition position = region.getPositions().get(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);
|
||||
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;
|
||||
}
|
||||
|
||||
if (workingTime > 0) {
|
||||
workingTime--;
|
||||
greenhouse.addHumidityChange(definition.getChangePerTransfer(), definition.getBoundaryDown(), definition.getBoundaryUp());
|
||||
}
|
||||
|
||||
setActive(workingTime > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -158,21 +123,26 @@ 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