diff --git a/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java b/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java index 4cf2b935c..5568d7380 100644 --- a/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java +++ b/src/main/java/forestry/api/arboriculture/EnumFruitFamily.java @@ -8,7 +8,6 @@ package forestry.api.arboriculture; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IFruitFamily; import forestry.core.utils.Translator; -import net.minecraft.util.text.translation.I18n; public enum EnumFruitFamily implements IFruitFamily { PRUNES("prunes", "Prunus domestica"), diff --git a/src/main/java/forestry/api/greenhouse/DefaultGreenhouseLogic.java b/src/main/java/forestry/api/greenhouse/DefaultGreenhouseLogic.java deleted file mode 100644 index b90b25b56..000000000 --- a/src/main/java/forestry/api/greenhouse/DefaultGreenhouseLogic.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright 2011-2014 SirSengir - * - * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. - ******************************************************************************/ -package forestry.api.greenhouse; - -import forestry.api.multiblock.IGreenhouseController; -import net.minecraft.nbt.NBTTagCompound; - -public class DefaultGreenhouseLogic implements IGreenhouseLogic { - - public final IGreenhouseController controller; - private final String name; - - public DefaultGreenhouseLogic(IGreenhouseController controller, String name) { - this.controller = controller; - this.name = name; - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - return nbt; - } - - @Override - public void readFromNBT(NBTTagCompound nbt) { - } - - @Override - public void work() { - } - - @Override - public void onEvent(EnumGreenhouseEventType type, Object event) { - } - - @Override - public IGreenhouseController getController() { - return controller; - } - - @Override - public String getName() { - return name; - } - - @Override - public void onMachineAssembled() { - } - - @Override - public void onMachineDisassembled() { - } - -} diff --git a/src/main/java/forestry/api/greenhouse/EnumGreenhouseEventType.java b/src/main/java/forestry/api/greenhouse/EnumGreenhouseEventType.java deleted file mode 100644 index 837b8afd0..000000000 --- a/src/main/java/forestry/api/greenhouse/EnumGreenhouseEventType.java +++ /dev/null @@ -1,12 +0,0 @@ -/******************************************************************************* - * Copyright 2011-2014 SirSengir - * - * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. - ******************************************************************************/ -package forestry.api.greenhouse; - -public enum EnumGreenhouseEventType { - - CAMOUFLAGE - -} diff --git a/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java b/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java index f6d4716c2..c560ab91d 100644 --- a/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java +++ b/src/main/java/forestry/api/greenhouse/GreenhouseEvents.java @@ -5,10 +5,6 @@ ******************************************************************************/ package forestry.api.greenhouse; -import javax.annotation.Nullable; - -import forestry.api.core.ICamouflageHandler; -import forestry.api.core.ICamouflagedTile; import forestry.api.multiblock.IGreenhouseController; import net.minecraftforge.fml.common.eventhandler.Event; @@ -20,24 +16,6 @@ public class GreenhouseEvents extends Event { this.controller = state; } - public static class CamouflageChangeEvent extends GreenhouseEvents { - - @Nullable - public final ICamouflagedTile camouflagedBlock; - - public final ICamouflageHandler camouflageHandler; - - public final String camouflageType; - - public CamouflageChangeEvent(IGreenhouseController controller, @Nullable ICamouflagedTile camouflagedBlock, ICamouflageHandler camouflageHandler, String camouflageType) { - super(controller); - - this.camouflagedBlock = camouflagedBlock; - this.camouflageHandler = camouflageHandler; - this.camouflageType = camouflageType; - } - } - public static class InternalBlockEvent extends GreenhouseEvents { public final IInternalBlock internalBlock; diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseClimaLogic.java b/src/main/java/forestry/api/greenhouse/IGreenhouseClimaLogic.java deleted file mode 100644 index 556f3f442..000000000 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseClimaLogic.java +++ /dev/null @@ -1,11 +0,0 @@ -/******************************************************************************* - * Copyright 2011-2014 SirSengir - * - * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. - ******************************************************************************/ -package forestry.api.greenhouse; - -public interface IGreenhouseClimaLogic extends IGreenhouseLogic { - - -} diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java b/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java index b6bf7e255..a36a4a4e4 100644 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java +++ b/src/main/java/forestry/api/greenhouse/IGreenhouseHelper.java @@ -6,12 +6,7 @@ package forestry.api.greenhouse; import javax.annotation.Nullable; -import java.util.List; - -import forestry.api.climate.IClimateInfo; import forestry.api.multiblock.IGreenhouseController; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -23,14 +18,4 @@ public interface IGreenhouseHelper { @Nullable IGreenhouseController getGreenhouseController(World world, BlockPos pos); - void registerGreenhouseLogic(Class logic); - - List> getGreenhouseLogics(); - - void registerTerrainRecipe(Block inputBlock, IBlockState outputState, IClimateInfo minClimate, IClimateInfo maxClimate, float chance); - - void registerTerrainRecipe(IBlockState inputState, IBlockState outputState, IClimateInfo minClimate, IClimateInfo maxClimate, float chance); - - ITerrainRecipe getValidTerrainRecipe(IBlockState blockState, IClimateInfo climateInfo); - } diff --git a/src/main/java/forestry/api/greenhouse/IGreenhouseLogic.java b/src/main/java/forestry/api/greenhouse/IGreenhouseLogic.java deleted file mode 100644 index aa302abd2..000000000 --- a/src/main/java/forestry/api/greenhouse/IGreenhouseLogic.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.api.greenhouse; - -import forestry.api.core.INbtReadable; -import forestry.api.core.INbtWritable; -import forestry.api.multiblock.IGreenhouseController; - -public interface IGreenhouseLogic extends INbtWritable, INbtReadable { - - void work(); - - void onEvent(EnumGreenhouseEventType type, Object event); - - void onMachineAssembled(); - - void onMachineDisassembled(); - - IGreenhouseController getController(); - - String getName(); - -} diff --git a/src/main/java/forestry/api/greenhouse/IOvergrowth.java b/src/main/java/forestry/api/greenhouse/IOvergrowth.java deleted file mode 100644 index 6d53f23d8..000000000 --- a/src/main/java/forestry/api/greenhouse/IOvergrowth.java +++ /dev/null @@ -1,18 +0,0 @@ -/******************************************************************************* - * Copyright 2011-2014 SirSengir - * - * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. - ******************************************************************************/ -package forestry.api.greenhouse; - -import forestry.api.climate.IClimateInfo; - -public interface IOvergrowth { - - IClimateInfo getMinClimate(); - - IClimateInfo getMaxClimate(); - - float getChance(); - -} diff --git a/src/main/java/forestry/api/greenhouse/ITerrainRecipe.java b/src/main/java/forestry/api/greenhouse/ITerrainRecipe.java deleted file mode 100644 index c6f5bc4c5..000000000 --- a/src/main/java/forestry/api/greenhouse/ITerrainRecipe.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright 2011-2014 SirSengir - * - * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. - ******************************************************************************/ -package forestry.api.greenhouse; - -import forestry.api.climate.IClimateInfo; -import net.minecraft.block.state.IBlockState; - -public interface ITerrainRecipe { - - boolean matches(IBlockState blockState); - - IBlockState getResult(); - - IClimateInfo getMinClimate(); - - IClimateInfo getMaxClimate(); - - float getChance(); - -} diff --git a/src/main/java/forestry/api/multiblock/IGreenhouseController.java b/src/main/java/forestry/api/multiblock/IGreenhouseController.java index ac96cb70c..c64af0986 100644 --- a/src/main/java/forestry/api/multiblock/IGreenhouseController.java +++ b/src/main/java/forestry/api/multiblock/IGreenhouseController.java @@ -5,28 +5,15 @@ ******************************************************************************/ package forestry.api.multiblock; -import java.util.List; import java.util.Set; import forestry.api.climate.IClimateControlProvider; import forestry.api.climate.IClimateRegion; import forestry.api.core.ICamouflageHandler; -import forestry.api.greenhouse.EnumGreenhouseEventType; import forestry.api.greenhouse.IGreenhouseHousing; -import forestry.api.greenhouse.IGreenhouseLogic; import forestry.api.greenhouse.IInternalBlock; public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlProvider { - - /** - * Handle change events. - */ - void onChange(EnumGreenhouseEventType type, Object event); - - /** - * @return The logics of the greenhouse. - */ - List getLogics(); /** * @return All internal blocks of the greenhouse. diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 4a943014d..3d7bfb76c 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -75,8 +75,8 @@ public class Config { // Performance public static boolean enableBackpackResupply = true; - public static int planterThrottle = 10; - public static int harvesterThrottle = 200; + //public static int planterThrottle = 10; + //public static int harvesterThrottle = 200; // Customization private static boolean craftingBronzeEnabled = true; @@ -213,10 +213,10 @@ public class Config { enableBackpackResupply = configCommon.getBooleanLocalized("performance", "backpacks.resupply", enableBackpackResupply); - planterThrottle = configCommon.getIntLocalized("performance", "performance.planter", planterThrottle, 1, 2000); + //planterThrottle = configCommon.getIntLocalized("performance", "performance.planter", planterThrottle, 1, 2000); //propThrottle.Comment = "higher numbers increase working speeds of planters but also increase cpu load."; - harvesterThrottle = configCommon.getIntLocalized("performance", "performance.harvester", harvesterThrottle, 1, 2000); + //harvesterThrottle = configCommon.getIntLocalized("performance", "performance.harvester", harvesterThrottle, 1, 2000); //propThrottle.Comment = "higher numbers increase working speeds of harvesters but also increase cpu load."; mailAlertEnabled = configCommon.getBooleanLocalized("tweaks.gui.mail.alert", "enabled", mailAlertEnabled); diff --git a/src/main/java/forestry/greenhouse/EventHandlerGreenhouse.java b/src/main/java/forestry/greenhouse/EventHandlerGreenhouse.java deleted file mode 100644 index fd56303fe..000000000 --- a/src/main/java/forestry/greenhouse/EventHandlerGreenhouse.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.greenhouse; - -import forestry.api.core.ICamouflageHandler; -import forestry.api.greenhouse.EnumGreenhouseEventType; -import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent; -import forestry.api.multiblock.IGreenhouseComponent; -import forestry.api.multiblock.IGreenhouseController; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; - -public class EventHandlerGreenhouse { - - @SubscribeEvent - public void onCamouflageChance(CamouflageChangeEvent event) { - ICamouflageHandler handler = event.camouflageHandler; - - IGreenhouseController controller = null; - if (handler instanceof IGreenhouseController) { - controller = (IGreenhouseController) handler; - } - - if (handler instanceof IGreenhouseComponent) { - IGreenhouseComponent component = (IGreenhouseComponent) handler; - controller = component.getMultiblockLogic().getController(); - } - - if (controller != null) { - controller.onChange(EnumGreenhouseEventType.CAMOUFLAGE, event); - } - } - -} diff --git a/src/main/java/forestry/greenhouse/GreenhouseHelper.java b/src/main/java/forestry/greenhouse/GreenhouseHelper.java index e502787c6..8d0a186a0 100644 --- a/src/main/java/forestry/greenhouse/GreenhouseHelper.java +++ b/src/main/java/forestry/greenhouse/GreenhouseHelper.java @@ -12,32 +12,18 @@ package forestry.greenhouse; import javax.annotation.Nullable; -import com.google.common.base.Preconditions; - -import java.util.ArrayList; -import java.util.List; - -import forestry.api.climate.IClimateInfo; import forestry.api.greenhouse.IGreenhouseHelper; -import forestry.api.greenhouse.IGreenhouseLogic; import forestry.api.greenhouse.IInternalBlock; -import forestry.api.greenhouse.ITerrainRecipe; import forestry.api.multiblock.IGreenhouseController; import forestry.core.multiblock.IMultiblockControllerInternal; import forestry.core.multiblock.MultiblockRegistry; -import forestry.core.utils.ClimateUtil; import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.greenhouse.multiblock.InternalBlockCheck; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class GreenhouseHelper implements IGreenhouseHelper { - private final List> greenhouseLogics = new ArrayList<>(); - private final List terrainRecipes = new ArrayList<>(); - @Override @Nullable public IGreenhouseController getGreenhouseController(World world, BlockPos pos) { @@ -56,46 +42,4 @@ public class GreenhouseHelper implements IGreenhouseHelper { return controller.getInternalBlocks().contains(checkBlock); } - @Override - public void registerGreenhouseLogic(Class logic) { - if (!greenhouseLogics.contains(logic)) { - greenhouseLogics.add(logic); - } - } - - @Override - public List> getGreenhouseLogics() { - return greenhouseLogics; - } - - @Override - public void registerTerrainRecipe(IBlockState inputState, IBlockState outputState, IClimateInfo minClimate, IClimateInfo maxClimate, float chance) { - Preconditions.checkNotNull(inputState); - Preconditions.checkNotNull(outputState); - Preconditions.checkNotNull(minClimate); - Preconditions.checkNotNull(maxClimate); - terrainRecipes.add(new TerrainRecipeState(inputState, outputState, minClimate, maxClimate, chance)); - } - - @Override - public void registerTerrainRecipe(Block inputBlock, IBlockState outputState, IClimateInfo minClimate, IClimateInfo maxClimate, float chance) { - Preconditions.checkNotNull(inputBlock); - Preconditions.checkNotNull(outputState); - Preconditions.checkNotNull(minClimate); - Preconditions.checkNotNull(maxClimate); - terrainRecipes.add(new TerrainRecipeBlock(inputBlock, outputState, minClimate, maxClimate, chance)); - } - - @Override - public ITerrainRecipe getValidTerrainRecipe(IBlockState blockState, IClimateInfo climateInfo) { - for(ITerrainRecipe recipe : terrainRecipes){ - if(recipe.matches(blockState)){ - if(ClimateUtil.isWithinLimits(recipe.getMinClimate(), recipe.getMaxClimate(), climateInfo)){ - return recipe; - } - } - } - return null; - } - } diff --git a/src/main/java/forestry/greenhouse/PluginGreenhouse.java b/src/main/java/forestry/greenhouse/PluginGreenhouse.java index 50c27a766..bd210f931 100644 --- a/src/main/java/forestry/greenhouse/PluginGreenhouse.java +++ b/src/main/java/forestry/greenhouse/PluginGreenhouse.java @@ -16,7 +16,6 @@ import com.google.common.base.Preconditions; import forestry.api.core.ForestryAPI; import forestry.api.greenhouse.GreenhouseManager; import forestry.core.PluginCore; -import forestry.core.climate.ClimateInfo; import forestry.core.config.Constants; import forestry.core.items.EnumElectronTube; import forestry.core.items.ItemRegistryCore; @@ -24,8 +23,6 @@ import forestry.core.recipes.RecipeUtil; import forestry.core.utils.OreDictUtil; import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.blocks.BlockRegistryGreenhouse; -import forestry.greenhouse.logics.GreenhouseLogicGreenhouseEffect; -import forestry.greenhouse.logics.GreenhouseLogicTerrain; import forestry.greenhouse.proxy.ProxyGreenhouse; import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch; import forestry.greenhouse.tiles.TileGreenhouseClimateControl; @@ -46,7 +43,6 @@ import forestry.plugins.ForestryPluginUids; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -77,16 +73,7 @@ public class PluginGreenhouse extends BlankForestryPlugin { @Override public void preInit() { - MinecraftForge.EVENT_BUS.register(new EventHandlerGreenhouse()); - proxy.initializeModels(); - - GreenhouseManager.greenhouseHelper.registerGreenhouseLogic(GreenhouseLogicGreenhouseEffect.class); - GreenhouseManager.greenhouseHelper.registerGreenhouseLogic(GreenhouseLogicTerrain.class); - - GreenhouseManager.greenhouseHelper.registerTerrainRecipe(Blocks.DIRT, Blocks.SAND.getDefaultState(), new ClimateInfo(1.2F, -1.0F), new ClimateInfo(-1.0F, -1.0F), 0.5F); - GreenhouseManager.greenhouseHelper.registerTerrainRecipe(Blocks.GRASS, Blocks.SAND.getDefaultState(), new ClimateInfo(1.2F, -1.0F), new ClimateInfo(-1.0F, -1.0F), 0.5F); - GreenhouseManager.greenhouseHelper.registerTerrainRecipe(Blocks.FARMLAND, Blocks.SAND.getDefaultState(), new ClimateInfo(1.2F, -1.0F), new ClimateInfo(-1.0F, -1.0F), 0.5F); } @Override diff --git a/src/main/java/forestry/greenhouse/TerrainRecipe.java b/src/main/java/forestry/greenhouse/TerrainRecipe.java deleted file mode 100644 index 69947dbf8..000000000 --- a/src/main/java/forestry/greenhouse/TerrainRecipe.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.greenhouse; - -import forestry.api.climate.IClimateInfo; -import forestry.api.greenhouse.ITerrainRecipe; -import net.minecraft.block.state.IBlockState; - -public abstract class TerrainRecipe implements ITerrainRecipe { - - public IBlockState result; - public IClimateInfo minClimate, maxClimate; - public float chance; - - public TerrainRecipe(IBlockState result, IClimateInfo minClimate, IClimateInfo maxClimate, float chance) { - this.result = result; - this.minClimate = minClimate; - this.maxClimate = maxClimate; - this.chance = chance; - } - - @Override - public IBlockState getResult() { - return result; - } - - @Override - public IClimateInfo getMinClimate() { - return minClimate; - } - - @Override - public IClimateInfo getMaxClimate() { - return maxClimate; - } - - @Override - public float getChance() { - return chance; - } - -} diff --git a/src/main/java/forestry/greenhouse/TerrainRecipeBlock.java b/src/main/java/forestry/greenhouse/TerrainRecipeBlock.java deleted file mode 100644 index 24a8a1c43..000000000 --- a/src/main/java/forestry/greenhouse/TerrainRecipeBlock.java +++ /dev/null @@ -1,21 +0,0 @@ -package forestry.greenhouse; - -import forestry.api.climate.IClimateInfo; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; - -public class TerrainRecipeBlock extends TerrainRecipe { - - private Block input; - - public TerrainRecipeBlock(Block input, IBlockState result, IClimateInfo minClimate, IClimateInfo maxClimate, float chance) { - super(result, minClimate, maxClimate, chance); - this.input = input; - } - - @Override - public boolean matches(IBlockState blockState) { - return blockState.getBlock() == input; - } - -} diff --git a/src/main/java/forestry/greenhouse/TerrainRecipeState.java b/src/main/java/forestry/greenhouse/TerrainRecipeState.java deleted file mode 100644 index 88acf2d7d..000000000 --- a/src/main/java/forestry/greenhouse/TerrainRecipeState.java +++ /dev/null @@ -1,20 +0,0 @@ -package forestry.greenhouse; - -import forestry.api.climate.IClimateInfo; -import net.minecraft.block.state.IBlockState; - -public class TerrainRecipeState extends TerrainRecipe { - - private IBlockState input; - - public TerrainRecipeState(IBlockState input, IBlockState result, IClimateInfo minClimate, IClimateInfo maxClimate, float chance) { - super(result, minClimate, maxClimate, chance); - this.input = input; - } - - @Override - public boolean matches(IBlockState blockState) { - return blockState == input; - } - -} diff --git a/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java b/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java deleted file mode 100644 index e735eaf73..000000000 --- a/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011-2014 SirSengir. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v3 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/lgpl-3.0.txt - * - * Various Contributors including, but not limited to: - * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges - ******************************************************************************/ -package forestry.greenhouse.logics; - -import forestry.api.core.CamouflageManager; -import forestry.api.core.ICamouflageItemHandler; -import forestry.api.core.ICamouflagedTile; -import forestry.api.greenhouse.DefaultGreenhouseLogic; -import forestry.api.greenhouse.EnumGreenhouseEventType; -import forestry.api.greenhouse.IGreenhouseClimaLogic; -import forestry.api.multiblock.IGreenhouseController; -import forestry.api.multiblock.IMultiblockComponent; -import forestry.core.utils.CamouflageUtil; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic { - - private float lightTransmittance; - private int workTimer; - - public GreenhouseLogicGreenhouseEffect(IGreenhouseController controller) { - super(controller, "GreenhouseEffect"); - - } - - @Override - public void work() { - /*if (controller == null || !controller.isAssembled()) { - return; - } - if (controller.getWorldObj().isDaytime()) { - if (workTimer++ > 20) { - controller.addTemperatureChange(lightTransmittance / 100, 0F, 2.5F); - workTimer = 0; - } - }*/ - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setInteger("workTimer", workTimer); - nbt.setFloat("lightTransmittance", lightTransmittance); - return nbt; - } - - @Override - public void readFromNBT(NBTTagCompound nbt) { - workTimer = nbt.getInteger("workTimer"); - lightTransmittance = nbt.getFloat("lightTransmittance"); - } - - @Override - public void onEvent(EnumGreenhouseEventType type, Object event) { - if (type == EnumGreenhouseEventType.CAMOUFLAGE) { - if (!controller.isAssembled()) { - return; - } - float lightTransmittance = 0F; - int i = 0; - - World world = controller.getWorldObj(); - for (IMultiblockComponent component : controller.getComponents()) { - if (component instanceof ICamouflagedTile) { - ICamouflagedTile block = (ICamouflagedTile) component; - if (block.getCamouflageType().equals(CamouflageManager.GLASS)) { - if (world.canBlockSeeSky(component.getCoordinates())) { - ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, component.getCoordinates()); - ICamouflageItemHandler handler = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflageStack); - if (handler != null) { - float camouflageLightTransmittance = handler.getLightTransmittance(camouflageStack, controller); - if (camouflageLightTransmittance < 1 && camouflageLightTransmittance > 0) { - lightTransmittance = lightTransmittance + camouflageLightTransmittance; - i++; - } - } - } - } - } - } - if (i != 0) { - this.lightTransmittance = lightTransmittance / i; - } - } - } - -} diff --git a/src/main/java/forestry/greenhouse/logics/GreenhouseLogicTerrain.java b/src/main/java/forestry/greenhouse/logics/GreenhouseLogicTerrain.java deleted file mode 100644 index 666286b86..000000000 --- a/src/main/java/forestry/greenhouse/logics/GreenhouseLogicTerrain.java +++ /dev/null @@ -1,77 +0,0 @@ -package forestry.greenhouse.logics; - -import forestry.api.greenhouse.DefaultGreenhouseLogic; -import forestry.api.greenhouse.GreenhouseManager; -import forestry.api.greenhouse.IInternalBlock; -import forestry.api.greenhouse.ITerrainRecipe; -import forestry.api.multiblock.IGreenhouseController; -import net.minecraft.block.state.IBlockState; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class GreenhouseLogicTerrain extends DefaultGreenhouseLogic { - - private static final int TIME = 160; - - private IInternalBlock[] internalBlocks; - private World world; - private int timeUntilNextTerrain; - - public GreenhouseLogicTerrain(IGreenhouseController controller) { - super(controller, "Terrain"); - this.internalBlocks = new IInternalBlock[0]; - this.world = controller.getWorldObj(); - this.timeUntilNextTerrain = TIME; - } - - @Override - public void work() { - if(this.world.isRemote || controller == null || !controller.isAssembled() || internalBlocks.length == 0){ - return; - } - if(this.timeUntilNextTerrain > 0){ - this.timeUntilNextTerrain--; - if(this.timeUntilNextTerrain <= 0){ - IInternalBlock internalBlock = internalBlocks[world.rand.nextInt(internalBlocks.length)]; - BlockPos blockPos = internalBlock.getPos(); - if(world.isBlockLoaded(blockPos) && !world.isAirBlock(blockPos)){ - IBlockState blockState = world.getBlockState(blockPos); - ITerrainRecipe recipe = GreenhouseManager.greenhouseHelper.getValidTerrainRecipe(blockState, controller.getRegion().getPosition(blockPos).getInfo()); - if(recipe != null){ - if(recipe.getChance() > world.rand.nextFloat()){ - world.setBlockState(blockPos, recipe.getResult()); - } - } - } - timeUntilNextTerrain = TIME; - } - } - } - - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - nbt.setInteger("Time", timeUntilNextTerrain); - return super.writeToNBT(nbt); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); - timeUntilNextTerrain = nbt.getInteger("Time"); - if(timeUntilNextTerrain <= 0){ - timeUntilNextTerrain = TIME; - } - } - - @Override - public void onMachineAssembled() { - this.internalBlocks = controller.getInternalBlocks().toArray(new IInternalBlock[0]); - } - - @Override - public void onMachineDisassembled() { - this.internalBlocks = new IInternalBlock[0]; - } - -} diff --git a/src/main/java/forestry/greenhouse/logics/package-info.java b/src/main/java/forestry/greenhouse/logics/package-info.java deleted file mode 100644 index a74d68291..000000000 --- a/src/main/java/forestry/greenhouse/logics/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -package forestry.greenhouse.logics; - -import javax.annotation.ParametersAreNonnullByDefault; - -import forestry.core.utils.FieldsAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java index c7a48179d..96c5aa21d 100644 --- a/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java @@ -12,13 +12,10 @@ package forestry.greenhouse.multiblock; import javax.annotation.Nullable; import java.util.Collections; -import java.util.List; import java.util.Set; import forestry.api.climate.IClimateInfo; import forestry.api.climate.IClimateRegion; -import forestry.api.greenhouse.EnumGreenhouseEventType; -import forestry.api.greenhouse.IGreenhouseLogic; import forestry.api.greenhouse.IInternalBlock; import forestry.api.multiblock.IGreenhouseComponent.ButterflyHatch; import forestry.api.multiblock.IGreenhouseComponent.Listener; @@ -78,15 +75,6 @@ public class FakeGreenhouseController extends FakeMultiblockController implement return BlockPos.ORIGIN; } - @Override - public List getLogics() { - return Collections.emptyList(); - } - - @Override - public void onChange(EnumGreenhouseEventType type, Object event) { - } - @Override public Set getInternalBlocks() { return Collections.emptySet(); diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java index b5774ef52..fd609fcae 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java @@ -12,7 +12,6 @@ package forestry.greenhouse.multiblock; import javax.annotation.Nullable; import java.io.IOException; -import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -29,19 +28,14 @@ import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; import forestry.api.core.ICamouflagedTile; -import forestry.api.greenhouse.EnumGreenhouseEventType; -import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent; import forestry.api.greenhouse.GreenhouseEvents.CheckInternalBlockFaceEvent; import forestry.api.greenhouse.GreenhouseEvents.CreateInternalBlockEvent; -import forestry.api.greenhouse.GreenhouseManager; -import forestry.api.greenhouse.IGreenhouseLogic; import forestry.api.greenhouse.IInternalBlock; import forestry.api.greenhouse.IInternalBlockFace; import forestry.api.multiblock.IGreenhouseComponent; import forestry.api.multiblock.IGreenhouseComponent.ButterflyHatch; import forestry.api.multiblock.IGreenhouseComponent.ClimateControl; import forestry.api.multiblock.IGreenhouseComponent.Climatiser; -import forestry.api.multiblock.IGreenhouseController; import forestry.api.multiblock.IMultiblockComponent; import forestry.core.climate.ClimateInfo; import forestry.core.climate.ClimatePosition; @@ -62,7 +56,6 @@ import forestry.core.proxy.Proxies; import forestry.core.tiles.ILiquidTankTile; import forestry.core.utils.CamouflageUtil; import forestry.core.utils.ItemStackUtil; -import forestry.core.utils.Log; import forestry.core.utils.Translator; import forestry.energy.EnergyManager; import forestry.greenhouse.inventory.InventoryGreenhouse; @@ -84,7 +77,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im private final Set listenerComponents = new HashSet<>(); private final Set activeComponents = new HashSet<>(); private final Set climatiserComponents = new HashSet<>(); - private final List logics = new ArrayList<>(); @Nullable protected ClimateControl climateControl; @Nullable @@ -109,11 +101,10 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im this.energyManager = new EnergyManager(200, 100000); this.inventory = new InventoryGreenhouse(this); - camouflagePlainBlock = getDefaultCamouflageBlock(CamouflageManager.BLOCK); - camouflageGlassBlock = getDefaultCamouflageBlock(CamouflageManager.GLASS); - camouflageDoorBlock = getDefaultCamouflageBlock(CamouflageManager.DOOR); + this.camouflagePlainBlock = getDefaultCamouflageBlock(CamouflageManager.BLOCK); + this.camouflageGlassBlock = getDefaultCamouflageBlock(CamouflageManager.GLASS); + this.camouflageDoorBlock = getDefaultCamouflageBlock(CamouflageManager.DOOR); this.region = new ClimateRegion(this); - createLogics(); } /* CLIMATE */ @@ -160,12 +151,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.GLASS); CamouflageUtil.writeCamouflageBlockToNBT(data, this, CamouflageManager.DOOR); - for (IGreenhouseLogic logic : getLogics()) { - NBTTagCompound nbtTag = new NBTTagCompound(); - logic.writeToNBT(nbtTag); - data.setTag("logic" + logic.getName(), nbtTag); - } - data.setTag("Region", region.writeToNBT(new NBTTagCompound())); return data; @@ -183,14 +168,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.GLASS); CamouflageUtil.readCamouflageBlockFromNBT(data, this, CamouflageManager.DOOR); - if (logics.isEmpty()) { - createLogics(); - } - - for (IGreenhouseLogic logic : getLogics()) { - logic.readFromNBT(data.getCompoundTag("logic" + logic.getName())); - } - if (data.hasKey("Region")) { NBTTagCompound nbtTag = data.getCompoundTag("Region"); if (region != null) { @@ -285,7 +262,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im } Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.MULTIBLOCK)); } - MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, null, this, type)); return true; } return false; @@ -319,43 +295,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im } } - /* GREENHOUSE */ - @Override - public void onChange(EnumGreenhouseEventType type, Object event) { - for (IGreenhouseLogic logic : logics) { - logic.onEvent(type, event); - } - } - - /* GREENHOUSE LOGICS */ - private void createLogics() { - logics.clear(); - for (Class logicClass : GreenhouseManager.greenhouseHelper.getGreenhouseLogics()) { - IGreenhouseLogic logic = createLogic(logicClass); - if (logic != null) { - logics.add(logic); - } - } - } - - @Nullable - private IGreenhouseLogic createLogic(Class logicClass) { - try { - return logicClass.getConstructor(IGreenhouseController.class).newInstance(this); - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException - | NoSuchMethodException | SecurityException e) { - Log.error("Fail to create a greenhouse logic with the class: {}", logicClass, e); - return null; - } - } - - @Override - public List getLogics() { - return logics; - } - /* MANAGERS */ - @Override public TankManager getTankManager() { return tankManager; @@ -413,9 +353,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im world.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates()); } } - for(IGreenhouseLogic logic : logics){ - logic.onMachineAssembled(); - } } @Override @@ -435,9 +372,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im world.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates()); } } - for(IGreenhouseLogic logic : logics){ - logic.onMachineDisassembled(); - } } @Override @@ -482,10 +416,6 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im inventory.drainCan(tankManager); } - for (IGreenhouseLogic logic : logics) { - logic.work(); - } - for (IGreenhouseComponent.Active activeComponent : activeComponents) { activeComponent.updateServer(tickCount); } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java index 2a42d79b4..5992ed0b5 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java @@ -17,7 +17,6 @@ import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflagedTile; import forestry.api.core.IErrorLogic; import forestry.api.core.IErrorLogicSource; -import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent; import forestry.api.multiblock.IGreenhouseComponent; import forestry.api.multiblock.IMultiblockController; import forestry.core.inventory.IInventoryAdapter; @@ -43,7 +42,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; public abstract class TileGreenhouse extends MultiblockTileEntityForestry implements IGreenhouseComponent, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled, ICamouflageHandler, ICamouflagedTile { protected ItemStack camouflageBlock; @@ -103,7 +101,6 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry