diff --git a/src/main/java/forestry/api/core/climate/IClimateManager.java b/src/main/java/forestry/api/core/climate/IClimateManager.java index cbc0d5a66..aed09177f 100644 --- a/src/main/java/forestry/api/core/climate/IClimateManager.java +++ b/src/main/java/forestry/api/core/climate/IClimateManager.java @@ -35,6 +35,6 @@ public interface IClimateManager { Map> getRegions(); @Nonnull - Map> getSources(); + Map> getSources(); } diff --git a/src/main/java/forestry/api/core/climate/IClimateSource.java b/src/main/java/forestry/api/core/climate/IClimateSource.java index de762fadc..467332e07 100644 --- a/src/main/java/forestry/api/core/climate/IClimateSource.java +++ b/src/main/java/forestry/api/core/climate/IClimateSource.java @@ -6,6 +6,7 @@ package forestry.api.core.climate; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; /** * A climate source is used to change the climate in a region. @@ -18,6 +19,8 @@ public interface IClimateSource { */ void changeClimate(int tickCount, IClimateRegion region); + World getWorld(); + BlockPos getPos(); } diff --git a/src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java b/src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java index 598d7b8a0..77c40ad7b 100644 --- a/src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java +++ b/src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java @@ -10,7 +10,7 @@ import forestry.api.multiblock.IGreenhouseController; public class DefaultGreenhouseListener implements IGreenhouseListener { @Override - public boolean canWork(G greenhouse, boolean canWork) { + public boolean canWork(IGreenhouseController greenhouse, boolean canWork) { return true; } diff --git a/src/main/java/forestry/core/climate/ClimateEventHandler.java b/src/main/java/forestry/core/climate/ClimateEventHandler.java index 6aaeeb0a6..58b10c033 100644 --- a/src/main/java/forestry/core/climate/ClimateEventHandler.java +++ b/src/main/java/forestry/core/climate/ClimateEventHandler.java @@ -30,7 +30,7 @@ public class ClimateEventHandler { region.updateClimate(); } } - for(IClimateSource source : ForestryAPI.climateManager.getSources().get(Integer.valueOf(dim))){ + 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); diff --git a/src/main/java/forestry/core/climate/ClimateManager.java b/src/main/java/forestry/core/climate/ClimateManager.java index 5cfd4629d..3bf1eb789 100644 --- a/src/main/java/forestry/core/climate/ClimateManager.java +++ b/src/main/java/forestry/core/climate/ClimateManager.java @@ -23,10 +23,12 @@ 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> regions; + protected Map> sources; public ClimateManager() { regions = new HashMap<>(); @@ -62,6 +64,26 @@ public class ClimateManager implements IClimateManager{ } } + @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); @@ -113,5 +135,10 @@ public class ClimateManager implements IClimateManager{ } return regions; } + + @Override + public Map> getSources() { + return sources; + } } diff --git a/src/main/java/forestry/core/tiles/TileNaturalistChest.java b/src/main/java/forestry/core/tiles/TileNaturalistChest.java index 1fc0e6b06..d55eef40a 100644 --- a/src/main/java/forestry/core/tiles/TileNaturalistChest.java +++ b/src/main/java/forestry/core/tiles/TileNaturalistChest.java @@ -15,6 +15,7 @@ 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; diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java index 248236b8d..8aa42d6cb 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseControl.java @@ -41,7 +41,7 @@ public class TileGreenhouseControl extends TileGreenhouse implements IGreenhouse } @Override - public boolean canWork(G greenhouse, boolean canWork) { + public boolean canWork(IGreenhouseController greenhouse, boolean canWork) { return canWork && !hasRedstoneSignal(); }