mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 03:15:28 +00:00
Add clima manager and add greenhouse controller to multiblock logic factory
This commit is contained in:
1 parent
a828c6a006
commit
cd4061b1fe
8 files changed
+82
-6
No files matched your search
@@ -46,6 +46,8 @@ public class ForestryAPI {
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static IModelManager modelManager;
|
||||
|
||||
public static IClimateManager climateManager;
|
||||
|
||||
/**
|
||||
* The currently active {@link IGameMode}.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011-2014 SirSengir
|
||||
*
|
||||
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IClimateManager {
|
||||
|
||||
float getTemperature(World world, BlockPos pos);
|
||||
|
||||
float getHumidity(World world, BlockPos pos);
|
||||
|
||||
}
|
||||
@@ -13,4 +13,6 @@ public interface IMultiblockLogicFactory {
|
||||
IMultiblockLogicAlveary createAlvearyLogic();
|
||||
|
||||
IMultiblockLogicFarm createFarmLogic();
|
||||
|
||||
IMultiblockLogicGreenhouse createGreenhouseLogic();
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import forestry.api.apiculture.IBeeModifier;
|
||||
import forestry.api.apiculture.IBeekeepingLogic;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IClimateControlled;
|
||||
import forestry.api.multiblock.IAlvearyComponent;
|
||||
import forestry.api.multiblock.IMultiblockComponent;
|
||||
@@ -351,12 +352,13 @@ public class AlvearyController extends RectangularMultiblockControllerBase imple
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords) + tempChange;
|
||||
return ForestryAPI.climateManager.getTemperature(getWorld(), coords) + tempChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return getBiome().rainfall + humidChange;
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return ForestryAPI.climateManager.getHumidity(getWorld(), coords) + humidChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*******************************************************************************
|
||||
* 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 forestry.api.core.IClimateManager;
|
||||
import forestry.api.greenhouse.GreenhouseManager;
|
||||
import forestry.api.greenhouse.IGreenhouseState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
public class ClimateManager implements IClimateManager{
|
||||
|
||||
@Override
|
||||
public float getTemperature(World world, BlockPos pos) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactTemperature();
|
||||
}
|
||||
return biome.temperature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getHumidity(World world, BlockPos pos) {
|
||||
IGreenhouseState state = GreenhouseManager.greenhouseHelper.getGreenhouseState(world, pos);
|
||||
BiomeGenBase biome = world.getBiomeGenForCoords(pos);
|
||||
|
||||
if(state != null){
|
||||
return state.getExactHumidity();
|
||||
}
|
||||
return biome.rainfall;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,6 +94,7 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
AlleleHelper.instance = new AlleleHelper();
|
||||
|
||||
MultiblockManager.logicFactory = new MultiblockLogicFactory();
|
||||
ForestryAPI.climateManager = new ClimateManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,8 +13,10 @@ package forestry.core.multiblock;
|
||||
import forestry.api.multiblock.IMultiblockLogicAlveary;
|
||||
import forestry.api.multiblock.IMultiblockLogicFactory;
|
||||
import forestry.api.multiblock.IMultiblockLogicFarm;
|
||||
import forestry.api.multiblock.IMultiblockLogicGreenhouse;
|
||||
import forestry.apiculture.multiblock.MultiblockLogicAlveary;
|
||||
import forestry.farming.multiblock.MultiblockLogicFarm;
|
||||
import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse;
|
||||
|
||||
public class MultiblockLogicFactory implements IMultiblockLogicFactory {
|
||||
|
||||
@@ -27,4 +29,9 @@ public class MultiblockLogicFactory implements IMultiblockLogicFactory {
|
||||
public IMultiblockLogicFarm createFarmLogic() {
|
||||
return new MultiblockLogicFarm();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMultiblockLogicGreenhouse createGreenhouseLogic() {
|
||||
return new MultiblockLogicGreenhouse();
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import forestry.api.circuits.ICircuitBoard;
|
||||
import forestry.api.circuits.ICircuitSocketType;
|
||||
import forestry.api.core.EnumHumidity;
|
||||
import forestry.api.core.EnumTemperature;
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IErrorLogic;
|
||||
import forestry.api.farming.FarmDirection;
|
||||
import forestry.api.farming.ICrop;
|
||||
@@ -386,8 +387,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
|
||||
@Override
|
||||
public EnumTemperature getTemperature() {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return EnumTemperature.getFromBiome(getBiome(), coords);
|
||||
return EnumTemperature.getFromValue(getExactTemperature());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -398,12 +398,13 @@ public class FarmController extends RectangularMultiblockControllerBase implemen
|
||||
@Override
|
||||
public float getExactTemperature() {
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return getBiome().getFloatTemperature(coords);
|
||||
return ForestryAPI.climateManager.getTemperature(getWorld(), coords);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExactHumidity() {
|
||||
return getBiome().rainfall;
|
||||
BlockPos coords = getReferenceCoord();
|
||||
return ForestryAPI.climateManager.getHumidity(getWorld(), coords);
|
||||
}
|
||||
|
||||
private int[] coords;
|
||||
|
||||
Reference in new issue
Block a user