diff --git a/lang b/lang index f5300f059..52791479e 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit f5300f059b2a0e55ecea645536acde0406152559 +Subproject commit 52791479e340f8c8c699cd865f66a6a5215dcf63 diff --git a/src/main/java/forestry/api/climate/IClimateManager.java b/src/main/java/forestry/api/climate/IClimateManager.java index f5710a12d..afcc18d44 100644 --- a/src/main/java/forestry/api/climate/IClimateManager.java +++ b/src/main/java/forestry/api/climate/IClimateManager.java @@ -5,23 +5,11 @@ ******************************************************************************/ package forestry.api.climate; -import javax.annotation.Nullable; -import java.util.Collection; - import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.greenhouse.Position2D; - public interface IClimateManager { - /** - * @return The current state of a container at this position if one exists. - * @since 5.3.4 - */ - @Nullable - IClimateContainer getContainer(World world, BlockPos pos); - /** * Gets the current state of a container at this position or setSettings one with the datas from the biome. * @since 5.3.4 @@ -37,11 +25,4 @@ public interface IClimateManager { * @return Create a climate manager. */ IClimateProvider getDefaultClimate(World world, BlockPos pos); - - void addSource(IClimateSourceOwner owner); - - void removeSource(IClimateSourceOwner owner); - - Collection getSources(World world, Position2D position); - } diff --git a/src/main/java/forestry/api/climate/IClimateState.java b/src/main/java/forestry/api/climate/IClimateState.java index c50d12064..d4c3a5e06 100644 --- a/src/main/java/forestry/api/climate/IClimateState.java +++ b/src/main/java/forestry/api/climate/IClimateState.java @@ -14,7 +14,7 @@ import forestry.api.core.INbtWritable; * * The range of the value of this two goes from 0.0F to 2.0F. And is oriented on the values of {@link Biome#getTemperature()} and {@link Biome#getRainfall()}. * - * Default inmplementations are: {@link ImmutableClimateState}, {@link ClimateState} and {@link ClimateChange}. + * Default inmplementations are: {@link ImmutableClimateState}, {@link ClimateState}. */ public interface IClimateState extends INbtWritable { diff --git a/src/main/java/forestry/api/core/ForestryAPI.java b/src/main/java/forestry/api/core/ForestryAPI.java index 4f8d4b8d6..ef83df5f7 100644 --- a/src/main/java/forestry/api/core/ForestryAPI.java +++ b/src/main/java/forestry/api/core/ForestryAPI.java @@ -10,7 +10,7 @@ import java.util.Set; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.IClimateFactory; +import forestry.greenhouse.api.climate.IClimateFactory; import forestry.api.climate.IClimateManager; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.ISimpleFarmLogic; diff --git a/src/main/java/forestry/api/climate/IClimateHousing.java b/src/main/java/forestry/api/greenhouse/IClimateHousing.java similarity index 88% rename from src/main/java/forestry/api/climate/IClimateHousing.java rename to src/main/java/forestry/api/greenhouse/IClimateHousing.java index 91ec426d3..89f8472c4 100644 --- a/src/main/java/forestry/api/climate/IClimateHousing.java +++ b/src/main/java/forestry/api/greenhouse/IClimateHousing.java @@ -3,17 +3,14 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.api.greenhouse; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public interface IClimateHousing { +import forestry.api.climate.ImmutableClimateState; - /** - * @return The climate container of this region. - */ - IClimateContainer getClimateContainer(); +public interface IClimateHousing { /** * @return The size of the region in blocks. diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseHousing.java b/src/main/java/forestry/api/greenhouse/IGreenhouseHousing.java index 9c64b2cb4..5689f38e6 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseHousing.java +++ b/src/main/java/forestry/api/greenhouse/IGreenhouseHousing.java @@ -5,9 +5,6 @@ ******************************************************************************/ package forestry.api.greenhouse; -import javax.annotation.Nullable; - -import forestry.api.climate.IClimateHousing; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.IErrorLogicSource; @@ -33,15 +30,4 @@ public interface IGreenhouseHousing extends IErrorLogicSource, IClimateHousing{ * @return The current humidity as an float. Range: 0.0F ~ 2.0F */ float getExactHumidity(); - - /** - * @return the manager of this housing. - */ - IGreenhouseProvider getProvider(); - - /** - * @return the maximal and minimal settings of this housing. - */ - @Nullable - IGreenhouseLimits getLimits(); } diff --git a/src/main/java/forestry/core/climate/ClimateContainer.java b/src/main/java/forestry/core/climate/ClimateContainer.java index 47fd9bd9d..840889787 100644 --- a/src/main/java/forestry/core/climate/ClimateContainer.java +++ b/src/main/java/forestry/core/climate/ClimateContainer.java @@ -27,19 +27,19 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.climate.ClimateState; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateContainerListener; -import forestry.api.climate.IClimateData; -import forestry.api.climate.IClimateHousing; -import forestry.api.climate.IClimateModifier; -import forestry.api.climate.IClimateSource; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; -import forestry.api.greenhouse.GreenhouseManager; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; import forestry.core.network.packets.PacketUpdateClimate; import forestry.core.utils.NetworkUtil; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateContainerListener; +import forestry.greenhouse.api.climate.IClimateData; +import forestry.api.greenhouse.IClimateHousing; +import forestry.greenhouse.api.climate.IClimateModifier; +import forestry.greenhouse.api.climate.IClimateSource; +import forestry.greenhouse.climate.GreenhouseClimateManager; public class ClimateContainer implements IClimateContainer, IStreamable { public static final float CLIMATE_CHANGE = 0.01F; @@ -87,7 +87,7 @@ public class ClimateContainer implements IClimateContainer, IStreamable { }else{ ImmutableClimateState oldState = state.toImmutable(); state = parent.getDefaultClimate().toMutable(); - for(IClimateModifier modifier : GreenhouseManager.greenhouseHelper.getModifiers()){ + for(IClimateModifier modifier : GreenhouseClimateManager.getInstance().getModifiers()){ state = modifier.modifyTarget(this, state, oldState, modifierData).toMutable(); } if(!state.equals(oldState)) { @@ -255,7 +255,7 @@ public class ClimateContainer implements IClimateContainer, IStreamable { } @Override - public void addListaner(IClimateContainerListener listener) { + public void addListener(IClimateContainerListener listener) { listeners.addListaner(listener); } @@ -292,7 +292,7 @@ public class ClimateContainer implements IClimateContainer, IStreamable { @SideOnly(Side.CLIENT) public IClimateData getData() { IClimateData data = new ClimateData(); - for(IClimateModifier modifier : GreenhouseManager.greenhouseHelper.getModifiers()){ + for(IClimateModifier modifier : GreenhouseClimateManager.getInstance().getModifiers()){ modifier.addData(this, state, modifierData, data); } return data; diff --git a/src/main/java/forestry/core/climate/ClimateData.java b/src/main/java/forestry/core/climate/ClimateData.java index 53579ff10..9a946139b 100644 --- a/src/main/java/forestry/core/climate/ClimateData.java +++ b/src/main/java/forestry/core/climate/ClimateData.java @@ -4,7 +4,7 @@ import java.util.LinkedHashMap; import java.util.Map; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateData; +import forestry.greenhouse.api.climate.IClimateData; public class ClimateData implements IClimateData { private final Map temperatureData = new LinkedHashMap<>(); diff --git a/src/main/java/forestry/core/climate/ClimateFactory.java b/src/main/java/forestry/core/climate/ClimateFactory.java index 3751a3c3e..5e2165922 100644 --- a/src/main/java/forestry/core/climate/ClimateFactory.java +++ b/src/main/java/forestry/core/climate/ClimateFactory.java @@ -1,8 +1,8 @@ package forestry.core.climate; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateFactory; -import forestry.api.climate.IClimateHousing; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateFactory; +import forestry.api.greenhouse.IClimateHousing; public class ClimateFactory implements IClimateFactory{ diff --git a/src/main/java/forestry/core/climate/ClimateManager.java b/src/main/java/forestry/core/climate/ClimateManager.java index 9d60a90ea..c1b36ba03 100644 --- a/src/main/java/forestry/core/climate/ClimateManager.java +++ b/src/main/java/forestry/core/climate/ClimateManager.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.core.climate; -import javax.annotation.Nullable; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -20,14 +17,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; -import forestry.api.climate.IClimateContainer; import forestry.api.climate.IClimateManager; import forestry.api.climate.IClimateProvider; -import forestry.api.climate.IClimateSourceOwner; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; -import forestry.api.core.ILocatable; -import forestry.api.greenhouse.Position2D; import forestry.core.DefaultClimateProvider; import forestry.core.utils.World2ObjectMap; @@ -69,53 +62,9 @@ public class ClimateManager implements IClimateManager { return manager.getClimateState(world, pos); } - @Nullable - @Override - public IClimateContainer getContainer(World world, BlockPos pos) { - ClimateWorldManager manager = managers.get(world); - if(manager == null){ - return null; - } - return manager.getContainer(world, pos); - } - - @Nullable - private IClimateContainer getContainer(ILocatable locatable){ - return getContainer(locatable.getWorldObj(), locatable.getCoordinates()); - } - @Override public IClimateProvider getDefaultClimate(World world, BlockPos pos) { return new DefaultClimateProvider(world, pos); } - - @Override - public void addSource(IClimateSourceOwner owner){ - World world = owner.getWorldObj(); - ClimateWorldManager manager = managers.get(world); - if(manager == null){ - return; - } - manager.addSource(owner); - } - - @Override - public void removeSource(IClimateSourceOwner owner){ - World world = owner.getWorldObj(); - ClimateWorldManager manager = managers.get(world); - if(manager == null){ - return; - } - manager.removeSource(owner); - } - - @Override - public Collection getSources(World world, Position2D position) { - ClimateWorldManager manager = managers.get(world); - if(manager == null){ - return Collections.emptyList(); - } - return manager.getSources(position); - } } diff --git a/src/main/java/forestry/core/climate/ClimateSource.java b/src/main/java/forestry/core/climate/ClimateSource.java index aa9c4b701..41fc6148a 100644 --- a/src/main/java/forestry/core/climate/ClimateSource.java +++ b/src/main/java/forestry/core/climate/ClimateSource.java @@ -14,14 +14,14 @@ import javax.annotation.Nullable; import net.minecraft.world.World; -import forestry.api.climate.ClimateChange; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateSource; -import forestry.api.climate.IClimateSourceOwner; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; -import forestry.api.core.ForestryAPI; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.climate.ClimateChange; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateSourceOwner; public abstract class ClimateSource implements IClimateSource { @@ -115,7 +115,7 @@ public abstract class ClimateSource implements IC public void onLoad() { World world = owner.getWorldObj(); if(!addedToManager && !world.isRemote) { - ForestryAPI.climateManager.addSource(owner); + GreenhouseManager.climateManager.addSource(owner); } } @@ -127,7 +127,7 @@ public abstract class ClimateSource implements IC public void onChunkUnload() { World world = owner.getWorldObj(); if(addedToManager &&!world.isRemote) { - ForestryAPI.climateManager.removeSource(owner); + GreenhouseManager.climateManager.removeSource(owner); } } diff --git a/src/main/java/forestry/core/climate/ClimateSourceType.java b/src/main/java/forestry/core/climate/ClimateSourceType.java index 868275a87..daaa4993b 100644 --- a/src/main/java/forestry/core/climate/ClimateSourceType.java +++ b/src/main/java/forestry/core/climate/ClimateSourceType.java @@ -11,7 +11,7 @@ package forestry.core.climate; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateSource; import forestry.api.climate.IClimateState; /** diff --git a/src/main/java/forestry/core/climate/ClimateWorldManager.java b/src/main/java/forestry/core/climate/ClimateWorldManager.java index 5bfd38501..2c91da2da 100644 --- a/src/main/java/forestry/core/climate/ClimateWorldManager.java +++ b/src/main/java/forestry/core/climate/ClimateWorldManager.java @@ -13,34 +13,27 @@ package forestry.core.climate; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import java.util.Collection; -import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; import java.util.concurrent.TimeUnit; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateSourceOwner; import forestry.api.climate.IClimateState; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.Position2D; -import forestry.greenhouse.multiblock.blocks.world.GreenhouseBlockManager; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.greenhouse.Position2D; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IGreenhouseClimateManager; +import forestry.greenhouse.api.climate.IClimateSourceOwner; public class ClimateWorldManager{ - - private final Set containers; + private final Cache stateCache; private final ClimateManager parent; private final Map> owners; public ClimateWorldManager(ClimateManager parent) { - this.containers = new HashSet<>(); this.stateCache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.SECONDS).build(); this.parent = parent; this.owners = new HashMap<>(); @@ -49,7 +42,8 @@ public class ClimateWorldManager{ public IClimateState getClimateState(World world, BlockPos pos) { IClimateState cacheState = stateCache.getIfPresent(pos); if(cacheState == null){ - IClimateContainer container = getContainer(world, pos); + IGreenhouseClimateManager climateSourceManager = GreenhouseManager.climateManager; + IClimateContainer container = climateSourceManager.getContainer(world, pos); if (container != null) { cacheState = container.getState(); @@ -62,42 +56,4 @@ public class ClimateWorldManager{ return cacheState; } - public IClimateContainer getContainer(World world, BlockPos pos) { - IGreenhouseBlock logicBlock = GreenhouseBlockManager.getInstance().getBlock(world, pos); - if(logicBlock != null){ - IGreenhouseProvider provider = logicBlock.getProvider(); - if(!provider.isClosed()) { - return null; - } - return provider.getClimateContainer(); - } - return null; - } - - public Set getContainers() { - return containers; - } - - public void addSource(IClimateSourceOwner owner){ - BlockPos pos = owner.getCoordinates(); - Position2D position = new Position2D(pos); - Map positionedOwners = owners.computeIfAbsent(position, k->new HashMap<>()); - positionedOwners.put(pos.getY(), owner); - } - - public void removeSource(IClimateSourceOwner owner){ - BlockPos pos = owner.getCoordinates(); - Position2D position = new Position2D(pos); - Map positionedOwners = owners.computeIfAbsent(position, k->new HashMap<>()); - positionedOwners.remove(pos.getY()); - } - - public Collection getSources(Position2D position) { - Map positionedOwners = owners.get(position); - if(positionedOwners == null){ - return Collections.emptyList(); - } - return positionedOwners.values(); - } - } \ No newline at end of file diff --git a/src/main/java/forestry/core/network/PacketBufferForestry.java b/src/main/java/forestry/core/network/PacketBufferForestry.java index 84d085015..ef1ec9f26 100644 --- a/src/main/java/forestry/core/network/PacketBufferForestry.java +++ b/src/main/java/forestry/core/network/PacketBufferForestry.java @@ -15,7 +15,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.Position2D; import io.netty.buffer.ByteBuf; diff --git a/src/main/java/forestry/core/network/packets/PacketUpdateClimate.java b/src/main/java/forestry/core/network/packets/PacketUpdateClimate.java index f7961d400..bfb52d89a 100644 --- a/src/main/java/forestry/core/network/packets/PacketUpdateClimate.java +++ b/src/main/java/forestry/core/network/packets/PacketUpdateClimate.java @@ -15,16 +15,18 @@ import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateHousing; +import forestry.api.greenhouse.IClimateHousing; +import forestry.api.multiblock.IGreenhouseComponent; import forestry.core.climate.ClimateContainer; +import forestry.core.multiblock.MultiblockUtil; import forestry.core.network.ForestryPacket; import forestry.core.network.IForestryPacketClient; import forestry.core.network.IForestryPacketHandlerClient; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; -import forestry.core.tiles.TileUtil; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; public class PacketUpdateClimate extends ForestryPacket implements IForestryPacketClient { @@ -51,7 +53,8 @@ public class PacketUpdateClimate extends ForestryPacket implements IForestryPack @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { BlockPos position = data.readBlockPos(); - IClimateHousing housing = TileUtil.getTile(player.world, position, IClimateHousing.class); + //TODO:Greenhouse Api + /*IClimateHousing housing = TileUtil.getTile(player.world, position, IClimateHousing.class); if(housing != null){ IClimateContainer container = housing.getClimateContainer(); if(container != null && container instanceof IStreamable){ @@ -60,6 +63,17 @@ public class PacketUpdateClimate extends ForestryPacket implements IForestryPack IClimateHousing parent = container.getParent(); parent.onUpdateClimate(); } + }*/ + IGreenhouseControllerInternal controller = MultiblockUtil.getController(player.world, position, IGreenhouseComponent.class); + if(controller == null){ + return; + } + IClimateContainer container = controller.getClimateContainer(); + if(container != null && container instanceof IStreamable){ + IStreamable streamable = (IStreamable) container; + streamable.readData(data); + IClimateHousing parent = container.getParent(); + parent.onUpdateClimate(); } } } diff --git a/src/main/java/forestry/greenhouse/GreenhouseEventHandler.java b/src/main/java/forestry/greenhouse/GreenhouseEventHandler.java index dd0ebd989..423fa6b32 100644 --- a/src/main/java/forestry/greenhouse/GreenhouseEventHandler.java +++ b/src/main/java/forestry/greenhouse/GreenhouseEventHandler.java @@ -34,9 +34,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.greenhouse.IGreenhouseLimits; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.Position2D; import forestry.api.multiblock.IGreenhouseComponent; import forestry.core.multiblock.MultiblockUtil; import forestry.greenhouse.items.ItemGreenhouseScreen; diff --git a/src/main/java/forestry/greenhouse/GreenhouseHelper.java b/src/main/java/forestry/greenhouse/GreenhouseHelper.java index 2975b40ef..f9fcbfa96 100644 --- a/src/main/java/forestry/greenhouse/GreenhouseHelper.java +++ b/src/main/java/forestry/greenhouse/GreenhouseHelper.java @@ -15,27 +15,19 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; -import java.util.TreeSet; import net.minecraft.item.ItemStack; -import forestry.api.climate.IClimateModifier; -import forestry.api.greenhouse.IGreenhouseHelper; import forestry.api.greenhouse.IGreenhouseLogic; import forestry.api.greenhouse.IGreenhouseLogicFactory; import forestry.api.multiblock.IGreenhouseController; +import forestry.greenhouse.api.greenhouse.IGreenhouseHelper; public class GreenhouseHelper implements IGreenhouseHelper { - private final Set modifiers; private List factories = new ArrayList<>(); private Map windowGlasses = new HashMap<>(); - public GreenhouseHelper() { - modifiers = new TreeSet((firstModifier, secondModifier) -> firstModifier.getPriority() > secondModifier.getPriority() ? 1 : -1); - } - @Override public void registerWindowGlass(String name, ItemStack item, String texture) { windowGlasses.put(name, new GreenhouseWindowGlass(name, texture, item)); @@ -78,16 +70,6 @@ public class GreenhouseHelper implements IGreenhouseHelper { return logics; } - @Override - public void registerModifier(IClimateModifier modifier) { - modifiers.add(modifier); - } - - @Override - public Collection getModifiers() { - return modifiers; - } - private final class GreenhouseWindowGlass { ItemStack item; String name; diff --git a/src/main/java/forestry/greenhouse/PluginGreenhouse.java b/src/main/java/forestry/greenhouse/PluginGreenhouse.java index bdd22a6dc..a98a36077 100644 --- a/src/main/java/forestry/greenhouse/PluginGreenhouse.java +++ b/src/main/java/forestry/greenhouse/PluginGreenhouse.java @@ -31,8 +31,6 @@ import forestry.api.climate.ClimateType; import forestry.api.core.CamouflageManager; import forestry.api.core.ForestryAPI; import forestry.api.core.Tabs; -import forestry.api.greenhouse.GreenhouseManager; -import forestry.api.greenhouse.IGreenhouseHelper; import forestry.core.CreativeTabForestry; import forestry.core.PluginCore; import forestry.core.circuits.CircuitLayout; @@ -43,12 +41,16 @@ import forestry.core.items.ItemRegistryCore; import forestry.core.network.IPacketRegistry; import forestry.core.recipes.RecipeUtil; import forestry.core.utils.OreDictUtil; +import forestry.greenhouse.api.climate.IGreenhouseClimateManager; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.greenhouse.IGreenhouseHelper; import forestry.greenhouse.blocks.BlockClimatiserType; import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.blocks.BlockRegistryGreenhouse; import forestry.greenhouse.camouflage.CamouflageAccess; import forestry.greenhouse.camouflage.CamouflageHandlerBlock; import forestry.greenhouse.circuits.CircuitClimateSource; +import forestry.greenhouse.climate.GreenhouseClimateManager; import forestry.greenhouse.climate.modifiers.AltitudeModifier; import forestry.greenhouse.climate.modifiers.ClimateSourceModifier; import forestry.greenhouse.climate.modifiers.TimeModifier; @@ -72,11 +74,6 @@ import forestry.greenhouse.tiles.TileHygroregulator; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.registry.GameRegistry; @ForestryPlugin(pluginID = ForestryPluginUids.GREENHOUSE, name = "Greenhouse", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.plugin.greenhouse.description") public class PluginGreenhouse extends BlankForestryPlugin { @@ -109,8 +106,9 @@ public class PluginGreenhouse extends BlankForestryPlugin { @Override public void setupAPI() { - GreenhouseManager.greenhouseHelper = new GreenhouseHelper(); - GreenhouseManager.greenhouseBlockManager = GreenhouseBlockManager.getInstance(); + GreenhouseManager.helper = new GreenhouseHelper(); + GreenhouseManager.blockManager = GreenhouseBlockManager.getInstance(); + GreenhouseManager.climateManager = GreenhouseClimateManager.getInstance(); CamouflageManager.camouflageAccess = new CamouflageAccess(); } @@ -134,7 +132,7 @@ public class PluginGreenhouse extends BlankForestryPlugin { @Override public void doInit() { super.doInit(); - IGreenhouseHelper helper = GreenhouseManager.greenhouseHelper; + IGreenhouseHelper helper = GreenhouseManager.helper; GameRegistry.registerTileEntity(TileGreenhousePlain.class, "forestry.GreenhousePlain"); GameRegistry.registerTileEntity(TileFan.class, "forestry.GreenhouseFan"); @@ -152,10 +150,11 @@ public class PluginGreenhouse extends BlankForestryPlugin { helper.registerWindowGlass("glass" + dye.getName(), new ItemStack(Blocks.STAINED_GLASS, 1, dye.getMetadata()), "blocks/glass_" + dye.getName()); } - helper.registerModifier(new WeatherModifier()); - helper.registerModifier(new TimeModifier()); - helper.registerModifier(new AltitudeModifier()); - helper.registerModifier(new ClimateSourceModifier()); + IGreenhouseClimateManager climateSourceManager = GreenhouseClimateManager.getInstance(); + climateSourceManager.registerModifier(new WeatherModifier()); + climateSourceManager.registerModifier(new TimeModifier()); + climateSourceManager.registerModifier(new AltitudeModifier()); + climateSourceManager.registerModifier(new ClimateSourceModifier()); Circuits.greenhouseClimatiserTemperature1 = new CircuitClimateSource("climatiser.temperature.1", ClimateType.TEMPERATURE, 0.125F, 0.125F); Circuits.greenhouseClimatiserTemperature2 = new CircuitClimateSource("climatiser.temperature.2", ClimateType.TEMPERATURE, 0.25F, 0.25F); @@ -236,8 +235,8 @@ public class PluginGreenhouse extends BlankForestryPlugin { '#', OreDictUtil.INGOT_TIN, 'T', coreItems.tubes.get(EnumElectronTube.LAPIS, 1)); - for (String glassName : GreenhouseManager.greenhouseHelper.getWindowGlasses()) { - ItemStack glassItem = GreenhouseManager.greenhouseHelper.getGlassItem(glassName); + for (String glassName : GreenhouseManager.helper.getWindowGlasses()) { + ItemStack glassItem = GreenhouseManager.helper.getGlassItem(glassName); ItemStack window = blocks.window.getItem(glassName); ItemStack roodWindow = blocks.roofWindow.getItem(glassName); RecipeUtil.addRecipe("greenhouse_window_" + glassName, roodWindow, diff --git a/src/main/java/forestry/api/climate/BlankClimateModifier.java b/src/main/java/forestry/greenhouse/api/climate/BlankClimateModifier.java similarity index 84% rename from src/main/java/forestry/api/climate/BlankClimateModifier.java rename to src/main/java/forestry/greenhouse/api/climate/BlankClimateModifier.java index fa5bdc107..6fdee2199 100644 --- a/src/main/java/forestry/api/climate/BlankClimateModifier.java +++ b/src/main/java/forestry/greenhouse/api/climate/BlankClimateModifier.java @@ -3,10 +3,13 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import net.minecraft.nbt.NBTTagCompound; +import forestry.api.climate.IClimateState; +import forestry.api.climate.ImmutableClimateState; + public class BlankClimateModifier implements IClimateModifier { @Override public IClimateState modifyTarget(IClimateContainer container, IClimateState newState, ImmutableClimateState oldState, NBTTagCompound data) { diff --git a/src/main/java/forestry/api/climate/ClimateChange.java b/src/main/java/forestry/greenhouse/api/climate/ClimateChange.java similarity index 94% rename from src/main/java/forestry/api/climate/ClimateChange.java rename to src/main/java/forestry/greenhouse/api/climate/ClimateChange.java index e21944f9d..5c818ea4a 100644 --- a/src/main/java/forestry/api/climate/ClimateChange.java +++ b/src/main/java/forestry/greenhouse/api/climate/ClimateChange.java @@ -3,13 +3,16 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import com.google.common.base.MoreObjects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.MathHelper; +import forestry.api.climate.ClimateState; +import forestry.api.climate.IClimateState; +import forestry.api.climate.ImmutableClimateState; import forestry.api.core.INbtReadable; /** diff --git a/src/main/java/forestry/api/climate/GreenhouseState.java b/src/main/java/forestry/greenhouse/api/climate/GreenhouseState.java similarity index 93% rename from src/main/java/forestry/api/climate/GreenhouseState.java rename to src/main/java/forestry/greenhouse/api/climate/GreenhouseState.java index 14626f074..973ac5cbe 100644 --- a/src/main/java/forestry/api/climate/GreenhouseState.java +++ b/src/main/java/forestry/greenhouse/api/climate/GreenhouseState.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; public enum GreenhouseState { CLOSED, diff --git a/src/main/java/forestry/api/climate/IClimateContainer.java b/src/main/java/forestry/greenhouse/api/climate/IClimateContainer.java similarity index 85% rename from src/main/java/forestry/api/climate/IClimateContainer.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateContainer.java index a33c2861d..482f1b6b9 100644 --- a/src/main/java/forestry/api/climate/IClimateContainer.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateContainer.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import javax.annotation.Nullable; import java.util.Collection; @@ -13,8 +13,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.climate.IClimateState; +import forestry.api.climate.ImmutableClimateState; import forestry.api.core.INbtReadable; import forestry.api.core.INbtWritable; +import forestry.api.greenhouse.IClimateHousing; public interface IClimateContainer extends INbtReadable, INbtWritable, IClimateSourceContainer { @@ -38,7 +41,7 @@ public interface IClimateContainer extends INbtReadable, INbtWritable, IClimateS /** * Add a listener to this container. */ - void addListaner(IClimateContainerListener listener); + void addListener(IClimateContainerListener listener); /** * Remove a listener to this container. diff --git a/src/main/java/forestry/api/climate/IClimateContainerListener.java b/src/main/java/forestry/greenhouse/api/climate/IClimateContainerListener.java similarity index 92% rename from src/main/java/forestry/api/climate/IClimateContainerListener.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateContainerListener.java index c45849880..0b6af7ced 100644 --- a/src/main/java/forestry/api/climate/IClimateContainerListener.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateContainerListener.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; public interface IClimateContainerListener { diff --git a/src/main/java/forestry/api/climate/IClimateData.java b/src/main/java/forestry/greenhouse/api/climate/IClimateData.java similarity index 84% rename from src/main/java/forestry/api/climate/IClimateData.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateData.java index c3ff6c7db..08a9066c3 100644 --- a/src/main/java/forestry/api/climate/IClimateData.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateData.java @@ -3,10 +3,12 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import java.util.Map; +import forestry.api.climate.ClimateType; + public interface IClimateData { IClimateData addData(ClimateType type, String displayName, float value); diff --git a/src/main/java/forestry/api/climate/IClimateFactory.java b/src/main/java/forestry/greenhouse/api/climate/IClimateFactory.java similarity index 84% rename from src/main/java/forestry/api/climate/IClimateFactory.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateFactory.java index 931591e7a..a11ebc809 100644 --- a/src/main/java/forestry/api/climate/IClimateFactory.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateFactory.java @@ -3,7 +3,9 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; + +import forestry.api.greenhouse.IClimateHousing; public interface IClimateFactory { diff --git a/src/main/java/forestry/api/climate/IClimateModifier.java b/src/main/java/forestry/greenhouse/api/climate/IClimateModifier.java similarity index 91% rename from src/main/java/forestry/api/climate/IClimateModifier.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateModifier.java index 6118e4f02..0c29318ad 100644 --- a/src/main/java/forestry/api/climate/IClimateModifier.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateModifier.java @@ -3,13 +3,16 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.climate.IClimateState; +import forestry.api.climate.ImmutableClimateState; + /** * This modifier is used by {@link IClimateContainer}s. */ diff --git a/src/main/java/forestry/api/climate/IClimateSource.java b/src/main/java/forestry/greenhouse/api/climate/IClimateSource.java similarity index 88% rename from src/main/java/forestry/api/climate/IClimateSource.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateSource.java index dc09d4bb1..1c4044ddd 100644 --- a/src/main/java/forestry/api/climate/IClimateSource.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateSource.java @@ -3,12 +3,16 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import javax.annotation.Nullable; +import forestry.api.climate.ClimateType; +import forestry.api.climate.IClimateState; +import forestry.api.climate.ImmutableClimateState; + /** - * A climate source is stored in a {@link IClimateSourceOwner}. It is used by the {@link IClimateSourceContainer}s to change the climate of a {@link IClimateContainer}. + * A climate source is stored in a {@link IClimateSourceOwner}. It is used by the {@link IClimateSourceContainer}s to change the climate of a {@link IClimateContainer}. * One {@link IClimateSource} can only be used by one {@link IClimateSourceContainer} at the same time. *

* In forestry it is used in a part of a {@link IClimateModifier}. diff --git a/src/main/java/forestry/api/climate/IClimateSourceCircuitable.java b/src/main/java/forestry/greenhouse/api/climate/IClimateSourceCircuitable.java similarity index 87% rename from src/main/java/forestry/api/climate/IClimateSourceCircuitable.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateSourceCircuitable.java index d22039d28..49c792ed0 100644 --- a/src/main/java/forestry/api/climate/IClimateSourceCircuitable.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateSourceCircuitable.java @@ -3,9 +3,10 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import forestry.api.circuits.ICircuit; +import forestry.api.climate.ClimateType; public interface IClimateSourceCircuitable extends IClimateSource { /** diff --git a/src/main/java/forestry/api/climate/IClimateSourceContainer.java b/src/main/java/forestry/greenhouse/api/climate/IClimateSourceContainer.java similarity index 94% rename from src/main/java/forestry/api/climate/IClimateSourceContainer.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateSourceContainer.java index afffe8ffa..452c2c478 100644 --- a/src/main/java/forestry/api/climate/IClimateSourceContainer.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateSourceContainer.java @@ -3,10 +3,12 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import java.util.Collection; +import forestry.api.climate.IClimateState; + /** * @since 5.3.4 * diff --git a/src/main/java/forestry/api/climate/IClimateSourceOwner.java b/src/main/java/forestry/greenhouse/api/climate/IClimateSourceOwner.java similarity index 95% rename from src/main/java/forestry/api/climate/IClimateSourceOwner.java rename to src/main/java/forestry/greenhouse/api/climate/IClimateSourceOwner.java index b2e87091c..3e85aaa91 100644 --- a/src/main/java/forestry/api/climate/IClimateSourceOwner.java +++ b/src/main/java/forestry/greenhouse/api/climate/IClimateSourceOwner.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.climate; +package forestry.greenhouse.api.climate; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/greenhouse/api/climate/IGreenhouseClimateManager.java b/src/main/java/forestry/greenhouse/api/climate/IGreenhouseClimateManager.java new file mode 100644 index 000000000..ce5bc6831 --- /dev/null +++ b/src/main/java/forestry/greenhouse/api/climate/IGreenhouseClimateManager.java @@ -0,0 +1,27 @@ +package forestry.greenhouse.api.climate; + +import javax.annotation.Nullable; +import java.util.Collection; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import forestry.greenhouse.api.greenhouse.Position2D; + +public interface IGreenhouseClimateManager { + /** + * @return The current state of a container at this position if one exists. + */ + @Nullable + IClimateContainer getContainer(World world, BlockPos pos); + + void addSource(IClimateSourceOwner owner); + + void removeSource(IClimateSourceOwner owner); + + Collection getSources(World world, Position2D position); + + void registerModifier(IClimateModifier modifier); + + Collection getModifiers(); +} diff --git a/src/main/java/forestry/api/greenhouse/GreenhouseManager.java b/src/main/java/forestry/greenhouse/api/climate/package-info.java similarity index 59% rename from src/main/java/forestry/api/greenhouse/GreenhouseManager.java rename to src/main/java/forestry/greenhouse/api/climate/package-info.java index 1a00d99e3..d9e3463f6 100644 --- a/src/main/java/forestry/api/greenhouse/GreenhouseManager.java +++ b/src/main/java/forestry/greenhouse/api/climate/package-info.java @@ -3,12 +3,10 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.greenhouse.api.climate; -public class GreenhouseManager { +import javax.annotation.ParametersAreNonnullByDefault; - public static IGreenhouseHelper greenhouseHelper; - - public static IGreenhouseBlockManager greenhouseBlockManager; - -} +import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java b/src/main/java/forestry/greenhouse/api/greenhouse/DefaultGreenhouseListener.java similarity index 84% rename from src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java rename to src/main/java/forestry/greenhouse/api/greenhouse/DefaultGreenhouseListener.java index 77c40ad7b..62f773366 100644 --- a/src/main/java/forestry/api/greenhouse/DefaultGreenhouseListener.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/DefaultGreenhouseListener.java @@ -3,8 +3,9 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; +import forestry.api.greenhouse.IGreenhouseListener; import forestry.api.multiblock.IGreenhouseController; public class DefaultGreenhouseListener implements IGreenhouseListener { diff --git a/src/main/java/forestry/greenhouse/api/greenhouse/GreenhouseManager.java b/src/main/java/forestry/greenhouse/api/greenhouse/GreenhouseManager.java new file mode 100644 index 000000000..2dea89d24 --- /dev/null +++ b/src/main/java/forestry/greenhouse/api/greenhouse/GreenhouseManager.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.greenhouse.api.greenhouse; + +import javax.annotation.Nullable; + +import forestry.greenhouse.api.climate.IGreenhouseClimateManager; + +public class GreenhouseManager { + + @Nullable + public static IGreenhouseHelper helper; + @Nullable + public static IGreenhouseBlockManager blockManager; + @Nullable + public static IGreenhouseClimateManager climateManager; + +} diff --git a/src/main/java/forestry/api/greenhouse/IBlankBlock.java b/src/main/java/forestry/greenhouse/api/greenhouse/IBlankBlock.java similarity index 95% rename from src/main/java/forestry/api/greenhouse/IBlankBlock.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IBlankBlock.java index ec5d7da32..f2bfb3efb 100644 --- a/src/main/java/forestry/api/greenhouse/IBlankBlock.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IBlankBlock.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseBlock.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlock.java similarity index 96% rename from src/main/java/forestry/api/greenhouse/IGreenhouseBlock.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlock.java index fb04a2e35..b9a9a8dcf 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseBlock.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlock.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; import java.util.Set; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseBlockHandler.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockHandler.java similarity index 96% rename from src/main/java/forestry/api/greenhouse/IGreenhouseBlockHandler.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockHandler.java index e55e50f7c..aec958fbe 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseBlockHandler.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockHandler.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; import java.util.List; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseBlockManager.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockManager.java similarity index 98% rename from src/main/java/forestry/api/greenhouse/IGreenhouseBlockManager.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockManager.java index 8920a9a03..571b97774 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseBlockManager.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockManager.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; import java.util.List; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseBlockStorage.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockStorage.java similarity index 95% rename from src/main/java/forestry/api/greenhouse/IGreenhouseBlockStorage.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockStorage.java index 1d73adaa4..7a36d74e5 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseBlockStorage.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseBlockStorage.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseChunk.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseChunk.java similarity index 97% rename from src/main/java/forestry/api/greenhouse/IGreenhouseChunk.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseChunk.java index 57f286210..d519fd5d3 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseChunk.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseChunk.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; import java.util.Collection; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseHelper.java similarity index 81% rename from src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseHelper.java index e22868ce4..46381a8a0 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseHelper.java @@ -3,13 +3,14 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import java.util.Collection; import net.minecraft.item.ItemStack; -import forestry.api.climate.IClimateModifier; +import forestry.api.greenhouse.IGreenhouseLogic; +import forestry.api.greenhouse.IGreenhouseLogicFactory; import forestry.api.multiblock.IGreenhouseController; public interface IGreenhouseHelper { @@ -25,9 +26,5 @@ public interface IGreenhouseHelper { void registerLogic(IGreenhouseLogicFactory logicFactory); Collection createLogics(IGreenhouseController controller); - - void registerModifier(IClimateModifier modifier); - - Collection getModifiers(); } diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseLimits.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseLimits.java similarity index 95% rename from src/main/java/forestry/api/greenhouse/IGreenhouseLimits.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseLimits.java index d5f5c67e3..0da18383f 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseLimits.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseLimits.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; /** * The limits that a greenhouse has. Used in the {@link IGreenhouseProvider} to test if the greenhouse is tested. diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseProvider.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseProvider.java similarity index 94% rename from src/main/java/forestry/api/greenhouse/IGreenhouseProvider.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseProvider.java index 1a09900af..a1623736d 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseProvider.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseProvider.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import javax.annotation.Nullable; import java.util.Collection; @@ -11,8 +11,8 @@ import java.util.Collection; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.climate.GreenhouseState; -import forestry.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.GreenhouseState; +import forestry.greenhouse.api.climate.IClimateContainer; import forestry.greenhouse.multiblock.blocks.GreenhouseException; /** diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseProviderListener.java b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseProviderListener.java similarity index 90% rename from src/main/java/forestry/api/greenhouse/IGreenhouseProviderListener.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseProviderListener.java index 452dfeb9d..686da54db 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseProviderListener.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IGreenhouseProviderListener.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import net.minecraft.util.math.BlockPos; diff --git a/src/main/java/forestry/api/greenhouse/IWallBlock.java b/src/main/java/forestry/greenhouse/api/greenhouse/IWallBlock.java similarity index 84% rename from src/main/java/forestry/api/greenhouse/IWallBlock.java rename to src/main/java/forestry/greenhouse/api/greenhouse/IWallBlock.java index fbf1b6289..794503c47 100644 --- a/src/main/java/forestry/api/greenhouse/IWallBlock.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/IWallBlock.java @@ -3,11 +3,11 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import net.minecraft.util.EnumFacing; -import forestry.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateSource; public interface IWallBlock extends IGreenhouseBlock { diff --git a/src/main/java/forestry/api/greenhouse/Position2D.java b/src/main/java/forestry/greenhouse/api/greenhouse/Position2D.java similarity index 98% rename from src/main/java/forestry/api/greenhouse/Position2D.java rename to src/main/java/forestry/greenhouse/api/greenhouse/Position2D.java index 1f18e26b5..3ea32591c 100644 --- a/src/main/java/forestry/api/greenhouse/Position2D.java +++ b/src/main/java/forestry/greenhouse/api/greenhouse/Position2D.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.greenhouse; +package forestry.greenhouse.api.greenhouse; import com.google.common.base.MoreObjects; diff --git a/src/main/java/forestry/greenhouse/api/greenhouse/package-info.java b/src/main/java/forestry/greenhouse/api/greenhouse/package-info.java new file mode 100644 index 000000000..cd72fdbda --- /dev/null +++ b/src/main/java/forestry/greenhouse/api/greenhouse/package-info.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@API(apiVersion = "5.2.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse") +package forestry.greenhouse.api.greenhouse; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraftforge.fml.common.API; + +import mcp.MethodsReturnNonnullByDefault; diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java index b68456c71..bec10f0eb 100755 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java @@ -49,7 +49,7 @@ import net.minecraftforge.common.property.IUnlistedProperty; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateContainer; import forestry.api.climate.IClimateState; import forestry.api.core.EnumTemperature; import forestry.api.core.ICamouflageHandler; @@ -57,7 +57,7 @@ import forestry.api.core.ICamouflagedTile; import forestry.api.core.IModelManager; import forestry.api.core.ISpriteRegister; import forestry.api.core.ITextureManager; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.api.multiblock.IGreenhouseComponent; import forestry.api.multiblock.IMultiblockComponent; import forestry.api.multiblock.IMultiblockController; diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseWindow.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseWindow.java index d830aaae0..efcde6195 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseWindow.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseWindow.java @@ -49,7 +49,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.core.IItemModelRegister; import forestry.api.core.IModelManager; -import forestry.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; import forestry.core.blocks.IBlockRotatable; import forestry.core.blocks.properties.UnlistedBlockAccess; import forestry.core.blocks.properties.UnlistedBlockPos; @@ -197,7 +197,7 @@ public class BlockGreenhouseWindow extends Block implements IBlockRotatable, ITi @Override public void getSubBlocks(CreativeTabs tab, NonNullList list) { - for (String glass : GreenhouseManager.greenhouseHelper.getWindowGlasses()) { + for (String glass : GreenhouseManager.helper.getWindowGlasses()) { list.add(getItem(glass)); } } diff --git a/src/main/java/forestry/greenhouse/circuits/CircuitClimateSource.java b/src/main/java/forestry/greenhouse/circuits/CircuitClimateSource.java index defa5cb60..23ae76c1d 100644 --- a/src/main/java/forestry/greenhouse/circuits/CircuitClimateSource.java +++ b/src/main/java/forestry/greenhouse/circuits/CircuitClimateSource.java @@ -13,9 +13,9 @@ package forestry.greenhouse.circuits; import javax.annotation.Nullable; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateSource; -import forestry.api.climate.IClimateSourceCircuitable; -import forestry.api.climate.IClimateSourceOwner; +import forestry.greenhouse.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateSourceCircuitable; +import forestry.greenhouse.api.climate.IClimateSourceOwner; import forestry.core.circuits.Circuit; public class CircuitClimateSource extends Circuit { diff --git a/src/main/java/forestry/greenhouse/climate/ClimateSourceCircuitable.java b/src/main/java/forestry/greenhouse/climate/ClimateSourceCircuitable.java index b2b71202b..2e53144ed 100644 --- a/src/main/java/forestry/greenhouse/climate/ClimateSourceCircuitable.java +++ b/src/main/java/forestry/greenhouse/climate/ClimateSourceCircuitable.java @@ -11,8 +11,8 @@ package forestry.greenhouse.climate; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateSourceCircuitable; -import forestry.api.climate.IClimateSourceOwner; +import forestry.greenhouse.api.climate.IClimateSourceCircuitable; +import forestry.greenhouse.api.climate.IClimateSourceOwner; import forestry.core.climate.ClimateSource; import forestry.core.climate.ClimateSourceType; diff --git a/src/main/java/forestry/greenhouse/climate/ClimateSourceClimatiser.java b/src/main/java/forestry/greenhouse/climate/ClimateSourceClimatiser.java index 1ef55911b..330a2d786 100644 --- a/src/main/java/forestry/greenhouse/climate/ClimateSourceClimatiser.java +++ b/src/main/java/forestry/greenhouse/climate/ClimateSourceClimatiser.java @@ -10,10 +10,10 @@ ******************************************************************************/ package forestry.greenhouse.climate; -import forestry.api.climate.ClimateChange; +import forestry.greenhouse.api.climate.ClimateChange; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateHousing; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.api.greenhouse.IClimateHousing; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.api.core.IErrorLogic; diff --git a/src/main/java/forestry/greenhouse/climate/ClimateSourceHygroregulator.java b/src/main/java/forestry/greenhouse/climate/ClimateSourceHygroregulator.java index c6b5348f5..7d66b0a64 100644 --- a/src/main/java/forestry/greenhouse/climate/ClimateSourceHygroregulator.java +++ b/src/main/java/forestry/greenhouse/climate/ClimateSourceHygroregulator.java @@ -12,7 +12,7 @@ package forestry.greenhouse.climate; import net.minecraftforge.fluids.FluidStack; -import forestry.api.climate.ClimateChange; +import forestry.greenhouse.api.climate.ClimateChange; import forestry.api.climate.ClimateType; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; diff --git a/src/main/java/forestry/greenhouse/climate/ClimateSourceWindow.java b/src/main/java/forestry/greenhouse/climate/ClimateSourceWindow.java index e885a8581..9c9891f0b 100644 --- a/src/main/java/forestry/greenhouse/climate/ClimateSourceWindow.java +++ b/src/main/java/forestry/greenhouse/climate/ClimateSourceWindow.java @@ -10,7 +10,7 @@ ******************************************************************************/ package forestry.greenhouse.climate; -import forestry.api.climate.ClimateChange; +import forestry.greenhouse.api.climate.ClimateChange; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.api.core.ForestryAPI; diff --git a/src/main/java/forestry/greenhouse/climate/ClimateSourceWorldManager.java b/src/main/java/forestry/greenhouse/climate/ClimateSourceWorldManager.java new file mode 100644 index 000000000..2c9678b38 --- /dev/null +++ b/src/main/java/forestry/greenhouse/climate/ClimateSourceWorldManager.java @@ -0,0 +1,43 @@ +package forestry.greenhouse.climate; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.util.math.BlockPos; + +import forestry.greenhouse.api.greenhouse.Position2D; +import forestry.greenhouse.api.climate.IClimateSourceOwner; + +public class ClimateSourceWorldManager{ + + private final Map> owners; + + public ClimateSourceWorldManager() { + this.owners = new HashMap<>(); + } + + public void addSource(IClimateSourceOwner owner){ + BlockPos pos = owner.getCoordinates(); + Position2D position = new Position2D(pos); + Map positionedOwners = owners.computeIfAbsent(position, k -> new HashMap<>()); + positionedOwners.put(pos.getY(), owner); + } + + public void removeSource(IClimateSourceOwner owner){ + BlockPos pos = owner.getCoordinates(); + Position2D position = new Position2D(pos); + Map positionedOwners = owners.computeIfAbsent(position, k -> new HashMap<>()); + positionedOwners.remove(pos.getY()); + } + + public Collection getSources(Position2D position) { + Map positionedOwners = owners.get(position); + if(positionedOwners == null){ + return Collections.emptyList(); + } + return positionedOwners.values(); + } + +} diff --git a/src/main/java/forestry/greenhouse/climate/GreenhouseClimateManager.java b/src/main/java/forestry/greenhouse/climate/GreenhouseClimateManager.java new file mode 100644 index 000000000..6a58a1ff1 --- /dev/null +++ b/src/main/java/forestry/greenhouse/climate/GreenhouseClimateManager.java @@ -0,0 +1,89 @@ +package forestry.greenhouse.climate; + +import java.util.Collection; +import java.util.Collections; +import java.util.Set; +import java.util.TreeSet; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import forestry.core.utils.World2ObjectMap; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateModifier; +import forestry.greenhouse.api.climate.IClimateSourceOwner; +import forestry.greenhouse.api.climate.IGreenhouseClimateManager; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.Position2D; +import forestry.greenhouse.multiblock.blocks.world.GreenhouseBlockManager; + +public class GreenhouseClimateManager implements IGreenhouseClimateManager { + + private static final GreenhouseClimateManager INSTANCE = new GreenhouseClimateManager(); + + private final World2ObjectMap managers; + private final Set modifiers; + + private GreenhouseClimateManager() { + managers = new World2ObjectMap(world->new ClimateSourceWorldManager()); + modifiers = new TreeSet((firstModifier, secondModifier) -> firstModifier.getPriority() > secondModifier.getPriority() ? 1 : -1); + } + + public static GreenhouseClimateManager getInstance(){ + return INSTANCE; + } + + @Override + public IClimateContainer getContainer(World world, BlockPos pos) { + IGreenhouseBlock logicBlock = GreenhouseBlockManager.getInstance().getBlock(world, pos); + if(logicBlock != null){ + IGreenhouseProvider provider = logicBlock.getProvider(); + if(!provider.isClosed()) { + return null; + } + return provider.getClimateContainer(); + } + return null; + } + + @Override + public void addSource(IClimateSourceOwner owner){ + World world = owner.getWorldObj(); + ClimateSourceWorldManager manager = managers.get(world); + if(manager == null){ + return; + } + manager.addSource(owner); + } + + @Override + public void removeSource(IClimateSourceOwner owner){ + World world = owner.getWorldObj(); + ClimateSourceWorldManager manager = managers.get(world); + if(manager == null){ + return; + } + manager.removeSource(owner); + } + + @Override + public Collection getSources(World world, Position2D position) { + ClimateSourceWorldManager manager = managers.get(world); + if(manager == null){ + return Collections.emptyList(); + } + return manager.getSources(position); + } + + @Override + public void registerModifier(IClimateModifier modifier) { + modifiers.add(modifier); + } + + @Override + public Collection getModifiers() { + return modifiers; + } + +} diff --git a/src/main/java/forestry/greenhouse/climate/modifiers/AltitudeModifier.java b/src/main/java/forestry/greenhouse/climate/modifiers/AltitudeModifier.java index c1f1fdbf6..f4179649f 100644 --- a/src/main/java/forestry/greenhouse/climate/modifiers/AltitudeModifier.java +++ b/src/main/java/forestry/greenhouse/climate/modifiers/AltitudeModifier.java @@ -17,11 +17,11 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.BlankClimateModifier; +import forestry.greenhouse.api.climate.BlankClimateModifier; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateData; -import forestry.api.climate.IClimateHousing; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateData; +import forestry.api.greenhouse.IClimateHousing; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.core.utils.Translator; diff --git a/src/main/java/forestry/greenhouse/climate/modifiers/ClimateSourceModifier.java b/src/main/java/forestry/greenhouse/climate/modifiers/ClimateSourceModifier.java index 58b53488c..d6f3fa94a 100644 --- a/src/main/java/forestry/greenhouse/climate/modifiers/ClimateSourceModifier.java +++ b/src/main/java/forestry/greenhouse/climate/modifiers/ClimateSourceModifier.java @@ -17,14 +17,14 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.BlankClimateModifier; -import forestry.api.climate.ClimateChange; +import forestry.greenhouse.api.climate.BlankClimateModifier; +import forestry.greenhouse.api.climate.ClimateChange; import forestry.api.climate.ClimateState; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateData; -import forestry.api.climate.IClimateHousing; -import forestry.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateData; +import forestry.api.greenhouse.IClimateHousing; +import forestry.greenhouse.api.climate.IClimateSource; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.core.config.Config; diff --git a/src/main/java/forestry/greenhouse/climate/modifiers/TimeModifier.java b/src/main/java/forestry/greenhouse/climate/modifiers/TimeModifier.java index 58156e88e..7d63aa7ce 100644 --- a/src/main/java/forestry/greenhouse/climate/modifiers/TimeModifier.java +++ b/src/main/java/forestry/greenhouse/climate/modifiers/TimeModifier.java @@ -18,10 +18,10 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.BlankClimateModifier; +import forestry.greenhouse.api.climate.BlankClimateModifier; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateData; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateData; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.core.utils.Translator; diff --git a/src/main/java/forestry/greenhouse/climate/modifiers/WeatherModifier.java b/src/main/java/forestry/greenhouse/climate/modifiers/WeatherModifier.java index f3caeef18..09bff589a 100644 --- a/src/main/java/forestry/greenhouse/climate/modifiers/WeatherModifier.java +++ b/src/main/java/forestry/greenhouse/climate/modifiers/WeatherModifier.java @@ -16,10 +16,10 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.BlankClimateModifier; +import forestry.greenhouse.api.climate.BlankClimateModifier; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateData; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateData; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.core.utils.Translator; diff --git a/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java b/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java index a51ebd1fd..8484d4f4b 100755 --- a/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java +++ b/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java @@ -16,8 +16,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateData; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateData; import forestry.api.climate.ImmutableClimateState; import forestry.core.config.Constants; import forestry.core.gui.GuiForestryTitled; diff --git a/src/main/java/forestry/greenhouse/gui/widgets/WidgetClimatePanel.java b/src/main/java/forestry/greenhouse/gui/widgets/WidgetClimatePanel.java index 260f9b971..352fc1259 100644 --- a/src/main/java/forestry/greenhouse/gui/widgets/WidgetClimatePanel.java +++ b/src/main/java/forestry/greenhouse/gui/widgets/WidgetClimatePanel.java @@ -23,7 +23,7 @@ import net.minecraft.client.renderer.GlStateManager; import org.lwjgl.input.Keyboard; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateData; +import forestry.greenhouse.api.climate.IClimateData; import forestry.core.gui.tables.Table; import forestry.core.gui.widgets.Widget; import forestry.core.gui.widgets.WidgetManager; diff --git a/src/main/java/forestry/greenhouse/items/ItemGreenhouseScreen.java b/src/main/java/forestry/greenhouse/items/ItemGreenhouseScreen.java index 07a41c6b8..2f6714e5e 100644 --- a/src/main/java/forestry/greenhouse/items/ItemGreenhouseScreen.java +++ b/src/main/java/forestry/greenhouse/items/ItemGreenhouseScreen.java @@ -31,7 +31,7 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateContainer; import forestry.api.climate.IClimateState; import forestry.api.core.EnumTemperature; import forestry.api.multiblock.IGreenhouseComponent; diff --git a/src/main/java/forestry/greenhouse/models/ModelGreenhouseWindow.java b/src/main/java/forestry/greenhouse/models/ModelGreenhouseWindow.java index 6b6fa1a57..843c12694 100644 --- a/src/main/java/forestry/greenhouse/models/ModelGreenhouseWindow.java +++ b/src/main/java/forestry/greenhouse/models/ModelGreenhouseWindow.java @@ -25,7 +25,7 @@ import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; import forestry.core.blocks.properties.UnlistedBlockAccess; import forestry.core.blocks.properties.UnlistedBlockPos; import forestry.core.models.DefaultTextureGetter; @@ -68,7 +68,7 @@ public class ModelGreenhouseWindow extends ModelBlockCustomCached textures = ImmutableMap.builder(); - String texture = GreenhouseManager.greenhouseHelper.getGlassTexture(key.glassName); + String texture = GreenhouseManager.helper.getGlassTexture(key.glassName); textures.put("texture", texture); textures.put("particle", texture); diff --git a/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java index a5e99c149..ac92cdb30 100644 --- a/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java @@ -17,10 +17,10 @@ import java.util.Set; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; -import forestry.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateContainer; import forestry.api.climate.ImmutableClimateState; -import forestry.api.greenhouse.IGreenhouseLimits; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.api.multiblock.IGreenhouseComponent.Listener; import forestry.core.multiblock.FakeMultiblockController; import forestry.energy.EnergyManager; diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java index ad656cd84..c5a58d168 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java @@ -26,21 +26,21 @@ import net.minecraft.world.biome.Biome; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.GreenhouseState; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateContainerListener; +import forestry.greenhouse.api.climate.GreenhouseState; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateContainerListener; import forestry.api.climate.ImmutableClimateState; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ICamouflagedTile; -import forestry.api.greenhouse.GreenhouseManager; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; import forestry.api.greenhouse.IGreenhouseListener; import forestry.api.greenhouse.IGreenhouseLogic; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.IGreenhouseProviderListener; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProviderListener; +import forestry.greenhouse.api.greenhouse.Position2D; import forestry.api.multiblock.IGreenhouseComponent; import forestry.api.multiblock.IGreenhouseComponent.Active; import forestry.api.multiblock.IGreenhouseComponent.Listener; @@ -99,7 +99,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im this.camouflage = getDefaultCamouflageBlock(); this.climateContainer = new ClimateContainer(this); - this.climateContainer.addListaner(this); + this.climateContainer.addListener(this); this.centerPos = BlockPos.ORIGIN; if (world.isRemote) { provider = new GreenhouseProviderClient(world, climateContainer); @@ -107,7 +107,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im provider = new GreenhouseProviderServer(world, climateContainer); } provider.addListener(this); - this.logics = GreenhouseManager.greenhouseHelper.createLogics(this); + this.logics = GreenhouseManager.helper.createLogics(this); for (IGreenhouseLogic logic : logics) { if (logic instanceof IGreenhouseProviderListener) { this.provider.addListener((IGreenhouseProviderListener) logic); diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimits.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimits.java index 4b744a292..c73dd30d3 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimits.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimits.java @@ -14,8 +14,8 @@ import java.io.IOException; import net.minecraft.nbt.NBTTagCompound; -import forestry.api.greenhouse.IGreenhouseLimits; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.Position2D; import forestry.core.network.PacketBufferForestry; public class GreenhouseLimits implements IGreenhouseLimits { diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimitsBuilder.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimitsBuilder.java index a01504a86..d0f3d80ba 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimitsBuilder.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseLimitsBuilder.java @@ -12,7 +12,7 @@ package forestry.greenhouse.multiblock; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.Position2D; public class GreenhouseLimitsBuilder { public BlockPos.MutableBlockPos maximumCoordinates; diff --git a/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java b/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java index 6fb326624..cd34aadac 100644 --- a/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java +++ b/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java @@ -10,6 +10,7 @@ ******************************************************************************/ package forestry.greenhouse.multiblock; +import javax.annotation.Nullable; import java.util.Set; import forestry.api.multiblock.IGreenhouseComponent; @@ -18,6 +19,9 @@ import forestry.core.multiblock.IMultiblockControllerInternal; import forestry.core.network.IStreamableGui; import forestry.core.owner.IOwnedTile; import forestry.energy.EnergyManager; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; public interface IGreenhouseControllerInternal extends IGreenhouseController, IMultiblockControllerInternal, IOwnedTile, IStreamableGui { @@ -35,4 +39,26 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM * @return A Set with listener componets. */ Set getListenerComponents(); + + //TODO: Move back to api + /***************************************/ + /* IClimateHousing */ + + /** + * @return The climate container of this region. + */ + IClimateContainer getClimateContainer(); + + /* IGreenhouseHousing */ + /** + * @return the manager of this housing. + */ + IGreenhouseProvider getProvider(); + + /** + * @return the maximal and minimal settings of this housing. + */ + @Nullable + IGreenhouseLimits getLimits(); + /**************************************/ } diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlock.java b/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlock.java index 54df7dc57..979bed222 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlock.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlock.java @@ -18,10 +18,10 @@ import java.util.Set; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockStorage; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockStorage; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; public abstract class GreenhouseBlock

implements IGreenhouseBlock { protected final BlockPos pos; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlockCache.java b/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlockCache.java index af3c12a47..ba241ae08 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlockCache.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/GreenhouseBlockCache.java @@ -18,7 +18,7 @@ import java.util.Set; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; import forestry.greenhouse.network.packets.PacketGreenhouseData; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlock.java b/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlock.java index f9e7ad7ea..fd38720c4 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlock.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlock.java @@ -13,9 +13,9 @@ package forestry.greenhouse.multiblock.blocks.blank; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.greenhouse.multiblock.blocks.GreenhouseBlock; public class BlankBlock extends GreenhouseBlock implements IBlankBlock { diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlockHandler.java b/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlockHandler.java index 233040008..2d0a3c1d7 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlockHandler.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/blank/BlankBlockHandler.java @@ -16,11 +16,11 @@ import java.util.List; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseBlockStorage; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockStorage; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.greenhouse.multiblock.blocks.GreenhouseException; public class BlankBlockHandler implements IGreenhouseBlockHandler { diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlock.java b/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlock.java index 76ff5b89d..d59c1cf28 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlock.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlock.java @@ -15,8 +15,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.greenhouse.multiblock.blocks.GreenhouseBlock; /** diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlockHandler.java b/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlockHandler.java index 74f5f8aaf..27f7263fc 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlockHandler.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/client/ClientBlockHandler.java @@ -17,9 +17,9 @@ import java.util.List; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseBlockStorage; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockStorage; import forestry.greenhouse.multiblock.blocks.GreenhouseException; public class ClientBlockHandler implements IGreenhouseBlockHandler { diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseBlockStorage.java b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseBlockStorage.java index 52d7bc6d7..562ea9da2 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseBlockStorage.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseBlockStorage.java @@ -24,12 +24,12 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockStorage; -import forestry.api.greenhouse.IGreenhouseChunk; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockStorage; +import forestry.greenhouse.api.greenhouse.IGreenhouseChunk; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.Position2D; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; import forestry.greenhouse.multiblock.blocks.GreenhouseBlockCache; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseChunk.java b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseChunk.java index 9ebc55198..f7d31736b 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseChunk.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseChunk.java @@ -17,9 +17,9 @@ import java.util.Set; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseChunk; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseChunk; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; public class GreenhouseChunk implements IGreenhouseChunk { diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProvider.java b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProvider.java index 5a25b5543..a6b49386a 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProvider.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProvider.java @@ -18,11 +18,11 @@ import java.util.Set; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.climate.GreenhouseState; -import forestry.api.climate.IClimateContainer; -import forestry.api.greenhouse.IGreenhouseLimits; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.IGreenhouseProviderListener; +import forestry.greenhouse.api.climate.GreenhouseState; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProviderListener; import forestry.core.network.IStreamable; import forestry.greenhouse.multiblock.blocks.GreenhouseException; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderClient.java b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderClient.java index aae945ff6..837e83a43 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderClient.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderClient.java @@ -18,11 +18,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.climate.GreenhouseState; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateHousing; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.climate.GreenhouseState; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.api.greenhouse.IClimateHousing; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.Position2D; import forestry.api.multiblock.IGreenhouseController; import forestry.core.network.PacketBufferForestry; import forestry.greenhouse.multiblock.GreenhouseLimits; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderServer.java b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderServer.java index 94a838cc1..a87e1780a 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderServer.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/storage/GreenhouseProviderServer.java @@ -28,18 +28,18 @@ import net.minecraft.util.math.ChunkPos; import net.minecraft.util.text.TextComponentString; import net.minecraft.world.World; -import forestry.api.climate.GreenhouseState; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateHousing; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseLimits; -import forestry.api.greenhouse.Position2D; +import forestry.api.greenhouse.IClimateHousing; import forestry.api.multiblock.IGreenhouseController; import forestry.core.network.PacketBufferForestry; import forestry.core.utils.NetworkUtil; import forestry.core.utils.Translator; +import forestry.greenhouse.api.climate.GreenhouseState; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseLimits; +import forestry.greenhouse.api.greenhouse.Position2D; import forestry.greenhouse.multiblock.GreenhouseLimits; import forestry.greenhouse.multiblock.GreenhouseLimitsBuilder; import forestry.greenhouse.multiblock.blocks.GreenhouseException; @@ -50,8 +50,8 @@ import forestry.greenhouse.network.packets.PacketGreenhouseData; public class GreenhouseProviderServer extends GreenhouseProvider { private static final List HANDLERS = new ArrayList<>(); - private static final int TIME_BETWEEN_UPDATES = 100; - private static final int UPDATE_DELAY = 35; + private static final int TIME_BETWEEN_UPDATES = 25; + private static final int UPDATE_DELAY = 50; private final Set unloadedChunks; @@ -175,7 +175,8 @@ public class GreenhouseProviderServer extends GreenhouseProvider { public void onBlockChange() { long totalWorldTime = world.getTotalWorldTime(); if (totalWorldTime >= previousUpdateTick + TIME_BETWEEN_UPDATES) { - GreenhouseBlockManager.getInstance().scheduleUpdate(world, container.getParent().getCoordinates(), this, UPDATE_DELAY); + GreenhouseBlockManager blockManager = GreenhouseBlockManager.getInstance(); + blockManager.scheduleUpdate(world, container.getParent().getCoordinates(), this, UPDATE_DELAY); previousUpdateTick = totalWorldTime; } } diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlock.java b/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlock.java index f86919d24..2e0d7e77d 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlock.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlock.java @@ -16,15 +16,15 @@ import java.util.List; import net.minecraft.util.math.BlockPos; -import forestry.api.climate.IClimateContainer; -import forestry.api.climate.IClimateSource; -import forestry.api.climate.IClimateSourceOwner; -import forestry.api.core.ForestryAPI; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.IWallBlock; -import forestry.api.greenhouse.Position2D; +import forestry.greenhouse.api.greenhouse.GreenhouseManager; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IWallBlock; +import forestry.greenhouse.api.greenhouse.Position2D; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateSourceOwner; import forestry.greenhouse.multiblock.blocks.GreenhouseBlock; public class WallBlock extends GreenhouseBlock implements IWallBlock { @@ -44,7 +44,7 @@ public class WallBlock extends GreenhouseBlock implements IWallBloc @Override public void onCreate() { IClimateContainer container = provider.getClimateContainer(); - for (IClimateSourceOwner sourceOwner : ForestryAPI.climateManager.getSources(provider.getWorld(), new Position2D(pos))) { + for (IClimateSourceOwner sourceOwner : GreenhouseManager.climateManager.getSources(provider.getWorld(), new Position2D(pos))) { IClimateSource source = sourceOwner.getClimateSource(); sources.add(source); container.addClimateSource(source); diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlockHandler.java b/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlockHandler.java index f1aef109c..e4d90a26f 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlockHandler.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/wall/WallBlockHandler.java @@ -21,13 +21,13 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.greenhouse.IBlankBlock; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockHandler; -import forestry.api.greenhouse.IGreenhouseBlockStorage; -import forestry.api.greenhouse.IGreenhouseProvider; -import forestry.api.greenhouse.IGreenhouseProviderListener; -import forestry.api.greenhouse.IWallBlock; +import forestry.greenhouse.api.greenhouse.IBlankBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockHandler; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockStorage; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProviderListener; +import forestry.greenhouse.api.greenhouse.IWallBlock; import forestry.greenhouse.multiblock.blocks.GreenhouseException; public class WallBlockHandler implements IGreenhouseBlockHandler { diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkManager.java b/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkManager.java index d5494c7f5..b2699cccb 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkManager.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkManager.java @@ -24,7 +24,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkThread.java b/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkThread.java index ea4ad7f48..1fe3836de 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkThread.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/world/ChunkThread.java @@ -24,7 +24,7 @@ import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.core.utils.Log; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/world/GreenhouseBlockManager.java b/src/main/java/forestry/greenhouse/multiblock/blocks/world/GreenhouseBlockManager.java index 67f280807..0258e0966 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/world/GreenhouseBlockManager.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/world/GreenhouseBlockManager.java @@ -18,10 +18,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; -import forestry.api.greenhouse.IGreenhouseBlock; -import forestry.api.greenhouse.IGreenhouseBlockManager; -import forestry.api.greenhouse.IGreenhouseChunk; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlockManager; +import forestry.greenhouse.api.greenhouse.IGreenhouseChunk; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; import forestry.core.utils.World2ObjectMap; import forestry.greenhouse.multiblock.blocks.blank.BlankBlockHandler; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseChunk; diff --git a/src/main/java/forestry/greenhouse/multiblock/blocks/world/NextTickEntry.java b/src/main/java/forestry/greenhouse/multiblock/blocks/world/NextTickEntry.java index 9a5ea49f9..60a997637 100644 --- a/src/main/java/forestry/greenhouse/multiblock/blocks/world/NextTickEntry.java +++ b/src/main/java/forestry/greenhouse/multiblock/blocks/world/NextTickEntry.java @@ -12,7 +12,7 @@ package forestry.greenhouse.multiblock.blocks.world; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; class NextTickEntry implements Comparable { private final IGreenhouseProvider provider; diff --git a/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseData.java b/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseData.java index a1ce6ecea..8fd70c3cb 100644 --- a/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseData.java +++ b/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseData.java @@ -15,18 +15,19 @@ import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.math.BlockPos; -import forestry.api.greenhouse.IGreenhouseProvider; import forestry.api.multiblock.IGreenhouseComponent; -import forestry.api.multiblock.IGreenhouseController; import forestry.core.multiblock.MultiblockUtil; import forestry.core.network.ForestryPacket; import forestry.core.network.IForestryPacketClient; import forestry.core.network.IForestryPacketHandlerClient; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; +import forestry.greenhouse.api.greenhouse.IGreenhouseProvider; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProvider; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProviderClient; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProviderServer; +import forestry.greenhouse.multiblock.blocks.world.GreenhouseBlockManager; public class PacketGreenhouseData extends ForestryPacket implements IForestryPacketClient { @@ -57,7 +58,7 @@ public class PacketGreenhouseData extends ForestryPacket implements IForestryPac @Override public void onPacketData(PacketBufferForestry data, EntityPlayer player) throws IOException { BlockPos pos = data.readBlockPos(); - IGreenhouseController controller = MultiblockUtil.getController(player.world, pos, IGreenhouseComponent.class); + IGreenhouseControllerInternal controller = MultiblockUtil.getController(player.world, pos, IGreenhouseComponent.class); if (controller == null) { return; } @@ -66,9 +67,9 @@ public class PacketGreenhouseData extends ForestryPacket implements IForestryPac GreenhouseProviderClient providerClient = (GreenhouseProviderClient) provider; providerClient.readData(data); } - //GreenhouseBlockManager manager = GreenhouseBlockManager.getInstance(); - provider.onBlockChange(); - //manager.markProviderDirty(player.world, controller.getProvider().getCenterPos(), provider); + GreenhouseBlockManager manager = GreenhouseBlockManager.getInstance(); + //provider.recreate(); + manager.markProviderDirty(player.world, controller.getProvider().getCenterPos(), provider); } } } diff --git a/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseDataRequest.java b/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseDataRequest.java index 62adfec2f..e406f0285 100644 --- a/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseDataRequest.java +++ b/src/main/java/forestry/greenhouse/network/packets/PacketGreenhouseDataRequest.java @@ -17,7 +17,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.multiblock.IGreenhouseComponent; -import forestry.api.multiblock.IGreenhouseController; import forestry.core.multiblock.MultiblockUtil; import forestry.core.network.ForestryPacket; import forestry.core.network.IForestryPacketHandlerServer; @@ -25,6 +24,7 @@ import forestry.core.network.IForestryPacketServer; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdServer; import forestry.core.utils.NetworkUtil; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.greenhouse.multiblock.blocks.storage.GreenhouseProviderServer; public class PacketGreenhouseDataRequest extends ForestryPacket implements IForestryPacketServer { @@ -50,7 +50,7 @@ public class PacketGreenhouseDataRequest extends ForestryPacket implements IFore public void onPacketData(PacketBufferForestry data, EntityPlayerMP player) throws IOException { BlockPos position = data.readBlockPos(); World world = player.world; - IGreenhouseController controller = MultiblockUtil.getController(world, position, IGreenhouseComponent.class); + IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, position, IGreenhouseComponent.class); if (controller != null) { NetworkUtil.sendToPlayer(new PacketGreenhouseData(position, (GreenhouseProviderServer) controller.getProvider()), player); } diff --git a/src/main/java/forestry/greenhouse/network/packets/PacketSelectClimateTargeted.java b/src/main/java/forestry/greenhouse/network/packets/PacketSelectClimateTargeted.java index eae3acc5b..328934f05 100644 --- a/src/main/java/forestry/greenhouse/network/packets/PacketSelectClimateTargeted.java +++ b/src/main/java/forestry/greenhouse/network/packets/PacketSelectClimateTargeted.java @@ -15,17 +15,17 @@ import java.io.IOException; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.math.BlockPos; -import forestry.api.climate.IClimateContainer; import forestry.api.climate.IClimateState; import forestry.api.climate.ImmutableClimateState; import forestry.api.multiblock.IGreenhouseComponent; -import forestry.api.multiblock.IGreenhouseController; import forestry.core.multiblock.MultiblockUtil; import forestry.core.network.ForestryPacket; import forestry.core.network.IForestryPacketHandlerServer; import forestry.core.network.IForestryPacketServer; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdServer; +import forestry.greenhouse.api.climate.IClimateContainer; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; public class PacketSelectClimateTargeted extends ForestryPacket implements IForestryPacketServer { private final BlockPos pos; @@ -55,7 +55,7 @@ public class PacketSelectClimateTargeted extends ForestryPacket implements IFore float temperature = data.readFloat(); float humidity = data.readFloat(); - IGreenhouseController controller = MultiblockUtil.getController(player.world, pos, IGreenhouseComponent.class); + IGreenhouseControllerInternal controller = MultiblockUtil.getController(player.world, pos, IGreenhouseComponent.class); if (controller != null) { IClimateContainer container = controller.getClimateContainer(); container.setTargetedState(new ImmutableClimateState(temperature, humidity)); diff --git a/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java b/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java index b90d395ae..1ad570238 100644 --- a/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java +++ b/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java @@ -28,9 +28,9 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.IClimateContainer; +import forestry.greenhouse.api.climate.IClimateContainer; import forestry.api.climate.IClimateState; -import forestry.api.greenhouse.IGreenhouseBlock; +import forestry.greenhouse.api.greenhouse.IGreenhouseBlock; import forestry.core.models.BlockModelEntry; import forestry.core.models.ModelEntry; import forestry.core.models.ModelManager; diff --git a/src/main/java/forestry/greenhouse/tiles/TileClimatiser.java b/src/main/java/forestry/greenhouse/tiles/TileClimatiser.java index 8a88575af..ff60f0fe8 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileClimatiser.java +++ b/src/main/java/forestry/greenhouse/tiles/TileClimatiser.java @@ -27,8 +27,8 @@ import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitBoard; import forestry.api.circuits.ICircuitSocketType; import forestry.api.climate.ClimateType; -import forestry.api.climate.IClimateSource; -import forestry.api.climate.IClimateSourceOwner; +import forestry.greenhouse.api.climate.IClimateSource; +import forestry.greenhouse.api.climate.IClimateSourceOwner; import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflagedTile; import forestry.apiculture.network.packets.PacketActiveUpdate; diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java index f98bfc90d..08f1adf2f 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.greenhouse.tiles; -import javax.annotation.Nullable; import java.io.IOException; import net.minecraft.client.gui.inventory.GuiContainer; @@ -23,7 +22,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -import forestry.api.climate.IClimateContainer; import forestry.api.climate.ImmutableClimateState; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -32,8 +30,6 @@ import forestry.api.core.ICamouflagedTile; import forestry.api.core.IErrorLogic; import forestry.api.core.IErrorLogicSource; import forestry.api.greenhouse.IGreenhouseHousing; -import forestry.api.greenhouse.IGreenhouseLimits; -import forestry.api.greenhouse.IGreenhouseProvider; import forestry.api.multiblock.IGreenhouseComponent; import forestry.api.multiblock.IMultiblockController; import forestry.core.multiblock.MultiblockTileEntityForestry; @@ -179,11 +175,11 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry