diff --git a/lang b/lang index 4c93562cb..7a992aeb2 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 4c93562cb9043939503ad357ef90309ffa2e1013 +Subproject commit 7a992aeb27f3425858ce2510727400dafe0238c3 diff --git a/src/main/java/forestry/api/apiculture/IBeeHousing.java b/src/main/java/forestry/api/apiculture/IBeeHousing.java index 1379482d2..89ba048bb 100644 --- a/src/main/java/forestry/api/apiculture/IBeeHousing.java +++ b/src/main/java/forestry/api/apiculture/IBeeHousing.java @@ -7,11 +7,11 @@ package forestry.api.apiculture; import javax.annotation.Nonnull; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import com.mojang.authlib.GameProfile; +import forestry.api.climate.IClimateProvider; import forestry.api.core.IErrorLogicSource; import forestry.api.genetics.IHousing; diff --git a/src/main/java/forestry/api/climate/EnumClimatiserModes.java b/src/main/java/forestry/api/climate/EnumClimatiserModes.java new file mode 100644 index 000000000..d7c6ec0f9 --- /dev/null +++ b/src/main/java/forestry/api/climate/EnumClimatiserModes.java @@ -0,0 +1,7 @@ +package forestry.api.climate; + +public enum EnumClimatiserModes { + + POSITIVE, NEGATIVE, NONE + +} diff --git a/src/main/java/forestry/api/climate/EnumClimatiserTypes.java b/src/main/java/forestry/api/climate/EnumClimatiserTypes.java new file mode 100644 index 000000000..954949fe8 --- /dev/null +++ b/src/main/java/forestry/api/climate/EnumClimatiserTypes.java @@ -0,0 +1,7 @@ +package forestry.api.climate; + +public enum EnumClimatiserTypes { + + TEMPERATURE, HUMIDITY, NONE + +} diff --git a/src/main/java/forestry/api/climate/IClimateControl.java b/src/main/java/forestry/api/climate/IClimateControl.java new file mode 100644 index 000000000..5cc9b79a0 --- /dev/null +++ b/src/main/java/forestry/api/climate/IClimateControl.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.climate; + +public interface IClimateControl { + + float getControlTemperature(); + + float getControlHumidity(); + + void setControlTemperature(float temperature); + + void setControlHumidity(float humidity); + +} diff --git a/src/main/java/forestry/api/climate/IClimateControlProvider.java b/src/main/java/forestry/api/climate/IClimateControlProvider.java new file mode 100644 index 000000000..67d279d21 --- /dev/null +++ b/src/main/java/forestry/api/climate/IClimateControlProvider.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.climate; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface IClimateControlProvider { + + IClimateControl getClimateControl(); + + World getWorld(); + + BlockPos getCoordinates(); + +} diff --git a/src/main/java/forestry/api/core/climate/IClimateControlled.java b/src/main/java/forestry/api/climate/IClimateControlled.java similarity index 95% rename from src/main/java/forestry/api/core/climate/IClimateControlled.java rename to src/main/java/forestry/api/climate/IClimateControlled.java index bf4dfb563..c30f06523 100644 --- a/src/main/java/forestry/api/core/climate/IClimateControlled.java +++ b/src/main/java/forestry/api/climate/IClimateControlled.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.core.climate; +package forestry.api.climate; public interface IClimateControlled { /** diff --git a/src/main/java/forestry/api/core/climate/IClimateManager.java b/src/main/java/forestry/api/climate/IClimateManager.java similarity index 79% rename from src/main/java/forestry/api/core/climate/IClimateManager.java rename to src/main/java/forestry/api/climate/IClimateManager.java index 89586a32f..bab0dda72 100644 --- a/src/main/java/forestry/api/core/climate/IClimateManager.java +++ b/src/main/java/forestry/api/climate/IClimateManager.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.core.climate; +package forestry.api.climate; import java.util.List; import java.util.Map; @@ -11,7 +11,6 @@ import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -27,9 +26,9 @@ public interface IClimateManager { void removeRegion(IClimateRegion region); - void addSource(IClimateSource source); + void addSource(IClimateSourceProvider source); - void removeSource(IClimateSource source); + void removeSource(IClimateSourceProvider source); @Nullable IClimateRegion getRegionForPos(World world, BlockPos pos); @@ -37,7 +36,4 @@ public interface IClimateManager { @Nonnull Map> getRegions(); - @Nonnull - Map> getSources(); - } diff --git a/src/main/java/forestry/api/core/climate/IClimatePosition.java b/src/main/java/forestry/api/climate/IClimatePosition.java similarity index 95% rename from src/main/java/forestry/api/core/climate/IClimatePosition.java rename to src/main/java/forestry/api/climate/IClimatePosition.java index 9fa331f92..e604cd3ef 100644 --- a/src/main/java/forestry/api/core/climate/IClimatePosition.java +++ b/src/main/java/forestry/api/climate/IClimatePosition.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.core.climate; +package forestry.api.climate; import javax.annotation.Nonnull; diff --git a/src/main/java/forestry/api/climate/IClimateProvider.java b/src/main/java/forestry/api/climate/IClimateProvider.java new file mode 100644 index 000000000..061e3de65 --- /dev/null +++ b/src/main/java/forestry/api/climate/IClimateProvider.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.climate; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import net.minecraft.world.biome.Biome; + +public interface IClimateProvider { + Biome getBiome(); + + EnumTemperature getTemperature(); + + EnumHumidity getHumidity(); +} diff --git a/src/main/java/forestry/api/core/climate/IClimateRegion.java b/src/main/java/forestry/api/climate/IClimateRegion.java similarity index 66% rename from src/main/java/forestry/api/core/climate/IClimateRegion.java rename to src/main/java/forestry/api/climate/IClimateRegion.java index d9a7f0283..a5fe4dd27 100644 --- a/src/main/java/forestry/api/core/climate/IClimateRegion.java +++ b/src/main/java/forestry/api/climate/IClimateRegion.java @@ -3,9 +3,9 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.core.climate; +package forestry.api.climate; -import java.util.List; +import java.util.Collection; import java.util.Map; import javax.annotation.Nonnull; @@ -21,15 +21,25 @@ public interface IClimateRegion extends INbtReadable, INbtWritable { World getWorld(); /** - * Update the climate in a region, all 20 world ticks. + * Update the climate in a region. */ - void updateClimate(); + void updateClimate(int ticks); + + int getTicksPerUpdate(); @Nonnull Map getPositions(); - int getTicksPerUpdate(); + void addSource(IClimateSource source); - List getOtherPositions(); + void removeSource(IClimateSource source); + + Collection getSources(); + + Collection getOtherPositions(); + + float getTemperature(); + + float getHumidity(); } diff --git a/src/main/java/forestry/api/core/climate/IClimateSource.java b/src/main/java/forestry/api/climate/IClimateSource.java similarity index 82% rename from src/main/java/forestry/api/core/climate/IClimateSource.java rename to src/main/java/forestry/api/climate/IClimateSource.java index 73047b065..7ee863ac7 100644 --- a/src/main/java/forestry/api/core/climate/IClimateSource.java +++ b/src/main/java/forestry/api/climate/IClimateSource.java @@ -3,10 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -package forestry.api.core.climate; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +package forestry.api.climate; /** * A climate source is used to change the climate in a region. @@ -24,8 +21,6 @@ public interface IClimateSource { */ int getTicksForChange(IClimateRegion region); - World getWorld(); - - BlockPos getPos(); + IClimateSourceProvider getProvider(); } diff --git a/src/main/java/forestry/api/climate/IClimateSourceProvider.java b/src/main/java/forestry/api/climate/IClimateSourceProvider.java new file mode 100644 index 000000000..799abe02a --- /dev/null +++ b/src/main/java/forestry/api/climate/IClimateSourceProvider.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.climate; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface IClimateSourceProvider { + + IClimateSource getClimateSource(); + + World getWorld(); + + BlockPos getCoordinates(); + +} diff --git a/src/main/java/forestry/api/climate/IClimatiserDefinition.java b/src/main/java/forestry/api/climate/IClimatiserDefinition.java new file mode 100644 index 000000000..4d0a76733 --- /dev/null +++ b/src/main/java/forestry/api/climate/IClimatiserDefinition.java @@ -0,0 +1,18 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +package forestry.api.climate; + +public interface IClimatiserDefinition { + + float getChange(); + + double getRange(); + + EnumClimatiserModes getMode(); + + EnumClimatiserTypes getType(); + +} diff --git a/src/main/java/forestry/api/climate/package-info.java b/src/main/java/forestry/api/climate/package-info.java new file mode 100644 index 000000000..71b75c935 --- /dev/null +++ b/src/main/java/forestry/api/climate/package-info.java @@ -0,0 +1,9 @@ +/******************************************************************************* + * Copyright 2011-2014 SirSengir + * + * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. + ******************************************************************************/ +@API(apiVersion = "2.1.0", owner = "Forestry", provides = "ForestryAPI|climate") +package forestry.api.climate; + +import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/core/ForestryAPI.java b/src/main/java/forestry/api/core/ForestryAPI.java index 9c253efb4..2ba4f1f2a 100644 --- a/src/main/java/forestry/api/core/ForestryAPI.java +++ b/src/main/java/forestry/api/core/ForestryAPI.java @@ -7,7 +7,7 @@ package forestry.api.core; import java.util.Set; -import forestry.api.core.climate.IClimateManager; +import forestry.api.climate.IClimateManager; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/main/java/forestry/api/core/ICamouflageAccess.java b/src/main/java/forestry/api/core/ICamouflageAccess.java index ab2824dbd..ffdf05b3e 100644 --- a/src/main/java/forestry/api/core/ICamouflageAccess.java +++ b/src/main/java/forestry/api/core/ICamouflageAccess.java @@ -30,4 +30,6 @@ public interface ICamouflageAccess { boolean isItemBlackListed(@Nonnull String type, @Nonnull ItemStack camouflageBlock); + ICamouflageItemHandler getHandlerFromItem(ItemStack stack); + } diff --git a/src/main/java/forestry/api/core/ICamouflageItemHandler.java b/src/main/java/forestry/api/core/ICamouflageItemHandler.java index 996dde44e..159322f16 100644 --- a/src/main/java/forestry/api/core/ICamouflageItemHandler.java +++ b/src/main/java/forestry/api/core/ICamouflageItemHandler.java @@ -15,7 +15,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public interface ICamouflageItemHandler { - boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler); + boolean canHandle(ItemStack stack); String getType(); diff --git a/src/main/java/forestry/api/core/IClimateProvider.java b/src/main/java/forestry/api/core/IClimateProvider.java deleted file mode 100644 index d593cee1c..000000000 --- a/src/main/java/forestry/api/core/IClimateProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package forestry.api.core; - -import net.minecraft.world.biome.Biome; - -public interface IClimateProvider { - Biome getBiome(); - - EnumTemperature getTemperature(); - - EnumHumidity getHumidity(); -} diff --git a/src/main/java/forestry/api/genetics/IMutationCondition.java b/src/main/java/forestry/api/genetics/IMutationCondition.java index ceda0e776..22aa093b9 100644 --- a/src/main/java/forestry/api/genetics/IMutationCondition.java +++ b/src/main/java/forestry/api/genetics/IMutationCondition.java @@ -5,7 +5,7 @@ ******************************************************************************/ package forestry.api.genetics; -import forestry.api.core.IClimateProvider; +import forestry.api.climate.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; diff --git a/src/main/java/forestry/api/greenhouse/package-info.java b/src/main/java/forestry/api/greenhouse/package-info.java index 5129d01c5..5a7854a19 100644 --- a/src/main/java/forestry/api/greenhouse/package-info.java +++ b/src/main/java/forestry/api/greenhouse/package-info.java @@ -3,7 +3,7 @@ * * This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details. ******************************************************************************/ -@API(apiVersion = "5.0.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse") +@API(apiVersion = "5.2.0", owner = "ForestryAPI|core", provides = "ForestryAPI|greenhouse") package forestry.api.greenhouse; import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java index fead01af1..eb956030e 100644 --- a/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java +++ b/src/main/java/forestry/api/lepidopterology/IButterflyNursery.java @@ -5,7 +5,7 @@ ******************************************************************************/ package forestry.api.lepidopterology; -import forestry.api.core.IClimateProvider; +import forestry.api.climate.IClimateProvider; import forestry.api.genetics.IHousing; import forestry.api.genetics.IIndividual; diff --git a/src/main/java/forestry/api/multiblock/IAlvearyComponent.java b/src/main/java/forestry/api/multiblock/IAlvearyComponent.java index 225972d68..8d09f9216 100644 --- a/src/main/java/forestry/api/multiblock/IAlvearyComponent.java +++ b/src/main/java/forestry/api/multiblock/IAlvearyComponent.java @@ -7,7 +7,7 @@ package forestry.api.multiblock; import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; -import forestry.api.core.climate.IClimateControlled; +import forestry.api.climate.IClimateControlled; /** * Needs to be implemented by TileEntities that want to be part of an alveary. diff --git a/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java b/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java index d7472e67c..ae61c7997 100644 --- a/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java +++ b/src/main/java/forestry/api/multiblock/IGreenhouseComponent.java @@ -5,7 +5,10 @@ ******************************************************************************/ package forestry.api.multiblock; -import forestry.api.core.climate.IClimateSource; +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimateControlProvider; +import forestry.api.climate.IClimateSourceProvider; +import forestry.api.climate.IClimatiserDefinition; import forestry.api.greenhouse.IGreenhouseListener; import forestry.api.lepidopterology.IButterflyCocoon; import net.minecraft.item.ItemStack; @@ -18,10 +21,17 @@ public interface IGreenhouseComponent exte IGreenhouseListener getGreenhouseListener(); } + interface ClimateControl extends IGreenhouseComponent, IClimateControlProvider { + + @Override + IClimateControl getClimateControl(); + } + interface Door extends IGreenhouseComponent { } - interface Climatiser extends IGreenhouseComponent, IClimateSource { + interface Climatiser extends IGreenhouseComponent, IClimateSourceProvider { + IClimatiserDefinition getDefinition(); } interface ButterflyHatch extends IGreenhouseComponent { diff --git a/src/main/java/forestry/api/multiblock/IGreenhouseController.java b/src/main/java/forestry/api/multiblock/IGreenhouseController.java index 81c4ba4c1..1a9bba142 100644 --- a/src/main/java/forestry/api/multiblock/IGreenhouseController.java +++ b/src/main/java/forestry/api/multiblock/IGreenhouseController.java @@ -7,15 +7,18 @@ package forestry.api.multiblock; import java.util.List; +import javax.annotation.Nonnull; import javax.annotation.Nullable; +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimateControlProvider; +import forestry.api.climate.IClimateRegion; import forestry.api.core.ICamouflageHandler; -import forestry.api.core.climate.IClimateRegion; import forestry.api.greenhouse.EnumGreenhouseEventType; import forestry.api.greenhouse.IGreenhouseHousing; import forestry.api.greenhouse.IGreenhouseLogic; -public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler { +public interface IGreenhouseController extends IMultiblockController, IGreenhouseHousing, ICamouflageHandler, IClimateControlProvider { /** * Handle change events. @@ -29,5 +32,9 @@ public interface IGreenhouseController extends IMultiblockController, IGreenhous @Nullable IClimateRegion getRegion(); + + @Override + @Nonnull + IClimateControl getClimateControl(); } diff --git a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java index 82cc2a3d6..60c7aac02 100644 --- a/src/main/java/forestry/apiculture/multiblock/AlvearyController.java +++ b/src/main/java/forestry/apiculture/multiblock/AlvearyController.java @@ -21,11 +21,11 @@ import forestry.api.apiculture.IBeeHousingInventory; import forestry.api.apiculture.IBeeListener; import forestry.api.apiculture.IBeeModifier; import forestry.api.apiculture.IBeekeepingLogic; +import forestry.api.climate.IClimateControlled; import forestry.api.core.BiomeHelper; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; -import forestry.api.core.climate.IClimateControlled; import forestry.api.multiblock.IAlvearyComponent; import forestry.api.multiblock.IMultiblockComponent; import forestry.apiculture.AlvearyBeeModifier; diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java index 2aa69cc87..b928bef9e 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearyClimatiser.java @@ -15,7 +15,7 @@ import javax.annotation.Nullable; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; -import forestry.api.core.climate.IClimateControlled; +import forestry.api.climate.IClimateControlled; import forestry.api.multiblock.IAlvearyComponent; import forestry.apiculture.network.packets.PacketActiveUpdate; import forestry.core.proxy.Proxies; diff --git a/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java b/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java index 7762863d7..8bd597a86 100644 --- a/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java +++ b/src/main/java/forestry/apiculture/multiblock/TileAlvearyHygroregulator.java @@ -22,7 +22,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.CapabilityFluidHandler; -import forestry.api.core.climate.IClimateControlled; +import forestry.api.climate.IClimateControlled; import forestry.api.multiblock.IAlvearyComponent; import forestry.apiculture.blocks.BlockAlvearyType; import forestry.apiculture.gui.ContainerAlvearyHygroregulator; diff --git a/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java b/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java index cdb149d71..b3324de22 100644 --- a/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java +++ b/src/main/java/forestry/arboriculture/CamouflageHandlerArbDoor.java @@ -30,8 +30,8 @@ import org.apache.commons.lang3.tuple.Pair; public class CamouflageHandlerArbDoor implements ICamouflageItemHandler { @Override - public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) { - if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0){ + public boolean canHandle(ItemStack stack) { + if(stack == null || stack.getItem() == null || stack.stackSize <= 0){ return false; } if(stack.getItem() instanceof ItemBlockWoodDoor){ diff --git a/src/main/java/forestry/arboriculture/PluginArboriculture.java b/src/main/java/forestry/arboriculture/PluginArboriculture.java index 40161b619..02acc79df 100644 --- a/src/main/java/forestry/arboriculture/PluginArboriculture.java +++ b/src/main/java/forestry/arboriculture/PluginArboriculture.java @@ -419,7 +419,7 @@ public class PluginArboriculture extends BlankForestryPlugin { } //Dirt Pile Block - RecipeUtil.addShapelessRecipe(new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.DIRT)), OreDictUtil.DUST_ASH, Items.CLAY_BALL, OreDictUtil.DUST_ASH, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.TREE_LEAVES, Items.CLAY_BALL, OreDictUtil.TREE_LEAVES); + RecipeUtil.addShapelessRecipe(new ItemStack(PluginArboriculture.blocks.piles.get(EnumPileType.DIRT)), PluginCore.items.fertilizerBio, Items.CLAY_BALL, PluginCore.items.fertilizerBio, OreDictUtil.DIRT, OreDictUtil.DIRT, OreDictUtil.DIRT, PluginCore.items.fertilizerBio, Items.CLAY_BALL, PluginCore.items.fertilizerBio); } diff --git a/src/main/java/forestry/arboriculture/models/WoodTextures.java b/src/main/java/forestry/arboriculture/models/WoodTextures.java index 315bf59ad..870d18516 100644 --- a/src/main/java/forestry/arboriculture/models/WoodTextures.java +++ b/src/main/java/forestry/arboriculture/models/WoodTextures.java @@ -20,9 +20,7 @@ import com.google.gson.stream.JsonReader; import forestry.api.arboriculture.IWoodType; import forestry.api.arboriculture.WoodBlockKind; -import forestry.core.render.FontColour; import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourcePack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; diff --git a/src/main/java/forestry/core/CamouflageAccess.java b/src/main/java/forestry/core/CamouflageAccess.java index fb5ed0f2e..f67efedab 100644 --- a/src/main/java/forestry/core/CamouflageAccess.java +++ b/src/main/java/forestry/core/CamouflageAccess.java @@ -20,7 +20,6 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.Loader; import forestry.api.core.ICamouflageAccess; -import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflageItemHandler; import forestry.core.utils.Log; @@ -48,6 +47,13 @@ public class CamouflageAccess implements ICamouflageAccess { @Override public List getCamouflageItemHandler(String type) { + if(type == null){ + List handlers = new ArrayList<>(); + for(List handler : camouflageItemHandlers.values()){ + handlers.addAll(handler); + } + return handlers; + } if(!camouflageItemHandlers.containsKey(type)){ return null; } @@ -76,21 +82,31 @@ public class CamouflageAccess implements ICamouflageAccess { @Override public boolean isItemBlackListed(String type, ItemStack camouflageBlock) { - if (camouflageBlock == null || camouflageBlock.getItem() == null || Block.getBlockFromItem(camouflageBlock.getItem()) == null || !camouflageItemBlacklist.containsKey(type)) { + if (camouflageBlock == null || camouflageBlock.getItem() == null || Block.getBlockFromItem(camouflageBlock.getItem()) == null || type != null && !camouflageItemBlacklist.containsKey(type)) { return false; } - for (ItemStack camouflageBlacklisted : camouflageItemBlacklist.get(type)) { + List camouflageItemBlacklisted; + if(type == null){ + camouflageItemBlacklisted = new ArrayList<>(); + for(List stacks : camouflageItemBlacklist.values()){ + camouflageItemBlacklisted.addAll(stacks); + } + }else{ + camouflageItemBlacklisted = camouflageItemBlacklist.get(type); + } + for (ItemStack camouflageBlacklisted : camouflageItemBlacklisted) { if (camouflageBlacklisted.getItem() == camouflageBlock.getItem() && camouflageBlacklisted.getItemDamage() == camouflageBlock.getItemDamage() && ItemStack.areItemStackTagsEqual(camouflageBlock, camouflageBlacklisted)) { return true; } } return false; } - - public static ICamouflageItemHandler getHandlerFromItem(@Nonnull ItemStack camouflageItem, ICamouflageHandler camouflageHandler){ + + @Override + public ICamouflageItemHandler getHandlerFromItem(ItemStack stack) { for(List handlers : camouflageItemHandlers.values()){ for(ICamouflageItemHandler handler : handlers){ - if(handler.canHandle(camouflageItem, camouflageHandler)){ + if(handler.canHandle(stack)){ return handler; } } diff --git a/src/main/java/forestry/core/CamouflageHandlerDefault.java b/src/main/java/forestry/core/CamouflageHandlerDefault.java index 5e59ee172..296e3fb69 100644 --- a/src/main/java/forestry/core/CamouflageHandlerDefault.java +++ b/src/main/java/forestry/core/CamouflageHandlerDefault.java @@ -28,14 +28,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class CamouflageHandlerDefault implements ICamouflageItemHandler { @Override - public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) { - if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){ + public boolean canHandle(ItemStack stack) { + if(stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){ return false; } Block block = Block.getBlockFromItem(stack.getItem()); IBlockState stateFromMeta = block.getStateFromMeta(stack.getItemDamage()); - return stateFromMeta.isOpaqueCube() && !block.hasTileEntity(stateFromMeta) && block.isNormalCube(stateFromMeta, camouflageHandler.getWorld(), camouflageHandler.getCoordinates()); + return stateFromMeta.isOpaqueCube() && !block.hasTileEntity(stateFromMeta) && block.isNormalCube(stateFromMeta) && block.isFullCube(stateFromMeta) && block.isBlockNormalCube(stateFromMeta); } @Override diff --git a/src/main/java/forestry/core/CamouflageHandlerDoor.java b/src/main/java/forestry/core/CamouflageHandlerDoor.java index 7363cda40..310964641 100644 --- a/src/main/java/forestry/core/CamouflageHandlerDoor.java +++ b/src/main/java/forestry/core/CamouflageHandlerDoor.java @@ -33,8 +33,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class CamouflageHandlerDoor implements ICamouflageItemHandler { @Override - public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) { - if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0){ + public boolean canHandle(ItemStack stack) { + if(stack == null || stack.getItem() == null || stack.stackSize <= 0){ return false; } if(stack.getItem() instanceof ItemDoor){ diff --git a/src/main/java/forestry/core/CamouflageHandlerGlass.java b/src/main/java/forestry/core/CamouflageHandlerGlass.java index 2deb89a6d..62c1bdab1 100644 --- a/src/main/java/forestry/core/CamouflageHandlerGlass.java +++ b/src/main/java/forestry/core/CamouflageHandlerGlass.java @@ -28,14 +28,14 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class CamouflageHandlerGlass implements ICamouflageItemHandler { @Override - public boolean canHandle(ItemStack stack, ICamouflageHandler camouflageHandler) { - if(camouflageHandler == null || stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){ + public boolean canHandle(ItemStack stack) { + if(stack == null || stack.getItem() == null || stack.stackSize <= 0 || Block.getBlockFromItem(stack.getItem()) == null){ return false; } Block block = Block.getBlockFromItem(stack.getItem()); IBlockState stateFromMeta = block.getStateFromMeta(stack.getItemDamage()); - return !stateFromMeta.isOpaqueCube() && !block.hasTileEntity(stateFromMeta); + return !stateFromMeta.isOpaqueCube() && !block.hasTileEntity(stateFromMeta) && !block.isBlockNormalCube(stateFromMeta); } @Override diff --git a/src/main/java/forestry/core/DefaultClimateProvider.java b/src/main/java/forestry/core/DefaultClimateProvider.java index 4f40c5ef1..904f74d93 100644 --- a/src/main/java/forestry/core/DefaultClimateProvider.java +++ b/src/main/java/forestry/core/DefaultClimateProvider.java @@ -1,9 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ package forestry.core; +import forestry.api.climate.IClimateProvider; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; diff --git a/src/main/java/forestry/core/PluginCore.java b/src/main/java/forestry/core/PluginCore.java index 1b1179e2c..462c79e1b 100644 --- a/src/main/java/forestry/core/PluginCore.java +++ b/src/main/java/forestry/core/PluginCore.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Set; import forestry.core.owner.GameProfileDataSerializer; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.command.ICommand; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -60,6 +61,8 @@ import forestry.core.genetics.alleles.AlleleRegistry; import forestry.core.items.EnumContainerType; import forestry.core.items.ItemRegistryCore; import forestry.core.loot.functions.SetSpeciesNBT; +import forestry.core.models.ModelCamouflageSprayCan; +import forestry.core.models.ModelEntry; import forestry.core.models.ModelManager; import forestry.core.multiblock.MultiblockLogicFactory; import forestry.core.network.IPacketRegistry; @@ -449,6 +452,9 @@ public class PluginCore extends BlankForestryPlugin { @SubscribeEvent @SideOnly(Side.CLIENT) public void onBakeModel(ModelBakeEvent event) { + ModelResourceLocation modelLocation = new ModelResourceLocation("forestry:camouflageSprayCan", "inventory"); + ModelEntry blockModelIndex = new ModelEntry(modelLocation, new ModelCamouflageSprayCan()); + Proxies.render.registerModel(blockModelIndex); ModelManager.getInstance().registerCustomModels(event); } diff --git a/src/main/java/forestry/core/blocks/BlockBase.java b/src/main/java/forestry/core/blocks/BlockBase.java index 096f807bd..9adc09912 100644 --- a/src/main/java/forestry/core/blocks/BlockBase.java +++ b/src/main/java/forestry/core/blocks/BlockBase.java @@ -59,7 +59,7 @@ import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileUtil; import forestry.core.utils.InventoryUtil; -public class BlockBase

& IBlockType & IStringSerializable> extends BlockForestry implements IItemModelRegister, ISpriteRegister, IStateMapperRegister { +public class BlockBase

& IBlockType & IStringSerializable> extends BlockForestry implements IItemModelRegister, ISpriteRegister, IStateMapperRegister, IBlockRotatable { /** use this instead of {@link BlockHorizontal#FACING} so the blocks rotate in a circle instead of NSWE order. */ public static final PropertyEnum FACING = PropertyEnum.create("facing", EnumFacing.class, EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.DOWN, EnumFacing.UP); @@ -170,6 +170,7 @@ public class BlockBase

& IBlockType & IStringSerializable> ext return false; } + @Override public void rotateAfterPlacement(EntityPlayer player, World world, BlockPos pos, EnumFacing side) { IBlockState state = world.getBlockState(pos); diff --git a/src/main/java/forestry/core/blocks/BlockStructure.java b/src/main/java/forestry/core/blocks/BlockStructure.java index cac84d6ac..d3ae8c686 100644 --- a/src/main/java/forestry/core/blocks/BlockStructure.java +++ b/src/main/java/forestry/core/blocks/BlockStructure.java @@ -45,7 +45,7 @@ public abstract class BlockStructure extends BlockForestry { return false; } - private long previousMessageTick = 0; + protected long previousMessageTick = 0; @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { diff --git a/src/main/java/forestry/core/blocks/IBlockRotatable.java b/src/main/java/forestry/core/blocks/IBlockRotatable.java new file mode 100644 index 000000000..47b185c61 --- /dev/null +++ b/src/main/java/forestry/core/blocks/IBlockRotatable.java @@ -0,0 +1,12 @@ +package forestry.core.blocks; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface IBlockRotatable { + + void rotateAfterPlacement(EntityPlayer player, World world, BlockPos pos, EnumFacing side); + +} diff --git a/src/main/java/forestry/core/climate/BiomeClimateControl.java b/src/main/java/forestry/core/climate/BiomeClimateControl.java new file mode 100644 index 000000000..e3bb7d21d --- /dev/null +++ b/src/main/java/forestry/core/climate/BiomeClimateControl.java @@ -0,0 +1,36 @@ +package forestry.core.climate; + +import java.util.HashMap; +import java.util.Map; + +import forestry.greenhouse.multiblock.DefaultClimateControl; +import net.minecraft.world.biome.Biome; + +public class BiomeClimateControl extends DefaultClimateControl { + + private static final Map climateControls = new HashMap<>(); + + public static BiomeClimateControl getControl(Biome biome){ + if(!climateControls.containsKey(biome)){ + climateControls.put(biome, new BiomeClimateControl(biome)); + } + return climateControls.get(biome); + } + + private final Biome biome; + + private BiomeClimateControl(Biome biome) { + this.biome = biome; + } + + @Override + public float getControlTemperature() { + return biome.getTemperature(); + } + + @Override + public float getControlHumidity() { + return biome.getRainfall(); + } + +} diff --git a/src/main/java/forestry/core/climate/ClimateControl.java b/src/main/java/forestry/core/climate/ClimateControl.java new file mode 100644 index 000000000..73d08edb9 --- /dev/null +++ b/src/main/java/forestry/core/climate/ClimateControl.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.climate; + +import forestry.api.core.INbtReadable; +import forestry.api.core.INbtWritable; +import forestry.core.network.DataInputStreamForestry; +import forestry.core.network.DataOutputStreamForestry; +import forestry.core.network.IStreamable; +import net.minecraft.nbt.NBTTagCompound; + +import java.io.IOException; + +import forestry.api.climate.IClimateControl; + +public class ClimateControl implements IClimateControl, INbtWritable, INbtReadable, IStreamable { + + private float temperature; + private float humidity; + + public ClimateControl() { + temperature = 2.0F; + humidity = 2.0F; + } + + @Override + public float getControlTemperature() { + return temperature; + } + + @Override + public float getControlHumidity() { + return humidity; + } + + @Override + public void setControlTemperature(float temperature) { + if(temperature > 2.0F){ + temperature = 2.0F; + }else{ + this.temperature = temperature; + } + } + + @Override + public void setControlHumidity(float humidity) { + if(humidity > 2.0F){ + humidity = 2.0F; + }else{ + this.humidity = humidity; + } + } + + @Override + public void writeData(DataOutputStreamForestry data) throws IOException { + data.writeFloat(temperature); + data.writeFloat(humidity); + } + + @Override + public void readData(DataInputStreamForestry data) throws IOException { + temperature = data.readFloat(); + humidity = data.readFloat(); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + temperature = nbt.getFloat("Temperature"); + humidity = nbt.getFloat("Humidity"); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + nbt.setFloat("Temperature", temperature); + nbt.setFloat("Humidity", humidity); + return nbt; + } + +} diff --git a/src/main/java/forestry/core/climate/ClimateEventHandler.java b/src/main/java/forestry/core/climate/ClimateEventHandler.java index 2666d6dca..9baca466e 100644 --- a/src/main/java/forestry/core/climate/ClimateEventHandler.java +++ b/src/main/java/forestry/core/climate/ClimateEventHandler.java @@ -1,16 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ package forestry.core.climate; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import forestry.api.climate.IClimateRegion; import forestry.api.core.ForestryAPI; -import forestry.api.core.climate.IClimateManager; -import forestry.api.core.climate.IClimateRegion; -import forestry.api.core.climate.IClimateSource; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -33,20 +38,7 @@ public class ClimateEventHandler { Map> regions = ForestryAPI.climateManager.getRegions(); if(regions != null && regions.containsKey(dim)){ for(IClimateRegion region : regions.get(dim)){ - if(ticks % region.getTicksPerUpdate() == 0){ - region.updateClimate(); - } - } - } - Map> sources = ForestryAPI.climateManager.getSources(); - if(sources != null && sources.containsKey(dim)){ - for(IClimateSource source : sources.get(dim).values()){ - IClimateRegion region = ForestryAPI.climateManager.getRegionForPos(event.world, source.getPos()); - if(region != null){ - if(ticks % source.getTicksForChange(region) == 0){ - source.changeClimate(ticks, region); - } - } + region.updateClimate(ticks); } } serverTicks.put(dim, ticks+1); diff --git a/src/main/java/forestry/core/climate/ClimateManager.java b/src/main/java/forestry/core/climate/ClimateManager.java index 117f10e49..47faf3b1a 100644 --- a/src/main/java/forestry/core/climate/ClimateManager.java +++ b/src/main/java/forestry/core/climate/ClimateManager.java @@ -19,23 +19,21 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import forestry.api.core.IClimateProvider; -import forestry.api.core.climate.IClimateManager; -import forestry.api.core.climate.IClimatePosition; -import forestry.api.core.climate.IClimateRegion; -import forestry.api.core.climate.IClimateSource; +import forestry.api.climate.IClimateManager; +import forestry.api.climate.IClimatePosition; +import forestry.api.climate.IClimateProvider; +import forestry.api.climate.IClimateRegion; +import forestry.api.climate.IClimateSourceProvider; import forestry.core.DefaultClimateProvider; public class ClimateManager implements IClimateManager{ protected Map> regions; - protected Map> sources; private final Object regionsMutex; public ClimateManager() { regions = new HashMap<>(); - sources = new HashMap<>(); regionsMutex = new Object(); } @@ -79,24 +77,40 @@ public class ClimateManager implements IClimateManager{ } @Override - public void removeSource(IClimateSource source) { - Integer dimensionID = Integer.valueOf(source.getWorld().provider.getDimension()); - if(!sources.containsKey(dimensionID)){ - sources.put(dimensionID, new HashMap<>()); + public void removeSource(IClimateSourceProvider source) { + if(source == null){ + return; } - if(sources.get(dimensionID).keySet().contains(source.getPos())){ - sources.get(dimensionID).remove(source.getPos(), source); + synchronized (regionsMutex) { + Integer dimensionID = Integer.valueOf(source.getWorld().provider.getDimension()); + if(!regions.containsKey(dimensionID)){ + regions.put(dimensionID, new ArrayList<>()); + } + IClimateRegion region = getRegionForPos(source.getWorld(), source.getCoordinates()); + if(region != null){ + if(!region.getSources().contains(source.getClimateSource())){ + region.removeSource(source.getClimateSource()); + } + } } } @Override - public void addSource(IClimateSource source) { - Integer dimensionID = Integer.valueOf(source.getWorld().provider.getDimension()); - if(!sources.containsKey(dimensionID)){ - sources.put(dimensionID, new HashMap<>()); + public void addSource(IClimateSourceProvider source) { + if(source == null){ + return; } - if(sources.get(dimensionID).get(source.getPos()) == null){ - sources.get(dimensionID).put(source.getPos(), source); + synchronized (regionsMutex) { + Integer dimensionID = Integer.valueOf(source.getWorld().provider.getDimension()); + if(!regions.containsKey(dimensionID)){ + regions.put(dimensionID, new ArrayList<>()); + } + IClimateRegion region = getRegionForPos(source.getWorld(), source.getCoordinates()); + if(region != null){ + if(!region.getSources().contains(source.getClimateSource())){ + region.addSource(source.getClimateSource()); + } + } } } @@ -150,11 +164,6 @@ public class ClimateManager implements IClimateManager{ return null; } - @Override - public Map> getSources() { - return sources; - } - @Override public IClimateProvider getDefaultClimate(World world, BlockPos pos) { return new DefaultClimateProvider(world, pos); diff --git a/src/main/java/forestry/core/climate/ClimatePosition.java b/src/main/java/forestry/core/climate/ClimatePosition.java index f164e9878..638a7ae6f 100644 --- a/src/main/java/forestry/core/climate/ClimatePosition.java +++ b/src/main/java/forestry/core/climate/ClimatePosition.java @@ -12,8 +12,8 @@ package forestry.core.climate; import javax.annotation.Nonnull; -import forestry.api.core.climate.IClimateRegion; -import forestry.api.core.climate.IClimatePosition; +import forestry.api.climate.IClimatePosition; +import forestry.api.climate.IClimateRegion; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.world.biome.Biome; @@ -27,6 +27,12 @@ public class ClimatePosition implements IClimatePosition { protected float temperature; protected float humidity; + public ClimatePosition(IClimateRegion climateRegion, BlockPos pos, NBTTagCompound nbtTag) { + this.climateRegion = climateRegion; + this.pos = pos; + readFromNBT(nbtTag); + } + public ClimatePosition(IClimateRegion climateRegion, BlockPos pos) { Biome biome = climateRegion.getWorld().getBiome(pos); this.climateRegion = climateRegion; diff --git a/src/main/java/forestry/core/climate/ClimateRoom.java b/src/main/java/forestry/core/climate/ClimateRoom.java index f10474690..82b4e713d 100644 --- a/src/main/java/forestry/core/climate/ClimateRoom.java +++ b/src/main/java/forestry/core/climate/ClimateRoom.java @@ -1,87 +1,148 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ package forestry.core.climate; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import forestry.api.core.climate.IClimatePosition; -import forestry.api.core.climate.IClimateRegion; -import forestry.api.multiblock.IGreenhouseController; +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimatePosition; +import forestry.api.climate.IClimateRegion; +import forestry.api.climate.IClimateSource; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamable; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import net.minecraft.world.biome.Biome; public class ClimateRoom implements IClimateRegion, IStreamable { - protected World world; - protected IGreenhouseController controller; - protected Map positions; - protected List wallPositions; + protected final World world; + protected final IGreenhouseControllerInternal controller; + protected final Map positions; + protected final List wallPositions; + protected final List sources; + protected float temperature; + protected float humidity; - public ClimateRoom(ClimateRoom oldRoom, Map innerPositions, List wallPositions) { + public ClimateRoom(ClimateRoom oldRoom, Map newPositions, List newWallPositions) { this.world = oldRoom.getWorld(); this.controller = oldRoom.controller; - Map newPositions = new HashMap<>(); - for(Entry positionEntry : innerPositions.entrySet()){ - IClimatePosition position = oldRoom.getPositions().get(positionEntry.getKey()); - if(position == null){ - newPositions.put(positionEntry.getKey(), positionEntry.getValue()); - }else{ - newPositions.put(positionEntry.getKey(), position); + this.positions = new HashMap<>(); + this.wallPositions = newWallPositions; + this.sources = new ArrayList<>(); + for(Entry positionEntry : newPositions.entrySet()){ + BlockPos pos = positionEntry.getKey(); + IClimatePosition position = positionEntry.getValue(); + IClimatePosition oldPosition = oldRoom.getPositions().get(pos); + float temperature = position.getTemperature(); + float humidity = position.getHumidity(); + if(oldPosition != null){ + temperature = oldPosition.getTemperature(); + humidity = oldPosition.getHumidity(); } + addPosition(pos, temperature, humidity); } - this.positions = newPositions; - this.wallPositions = wallPositions; + this.temperature = getExactTemperature(); + this.humidity = getExactHumidity(); } - public ClimateRoom(IGreenhouseController controller, Map innerPositions, List wallPositions) { + public ClimateRoom(IGreenhouseControllerInternal controller, Map innerPositions, List wallPositions) { this.world = controller.getWorldObj(); this.controller = controller; this.positions = innerPositions; this.wallPositions = wallPositions; + this.sources = new ArrayList<>(); + this.temperature = getExactTemperature(); + this.humidity = getExactHumidity(); } - public ClimateRoom(IGreenhouseController controller, NBTTagCompound nbtTag) { + public ClimateRoom(IGreenhouseControllerInternal controller, List wallPositions, NBTTagCompound nbtTag) { this.world = controller.getWorldObj(); this.controller = controller; this.positions = new HashMap<>(); + this.wallPositions = new ArrayList<>(); + this.sources = new ArrayList<>(); readFromNBT(nbtTag); + this.temperature = getExactTemperature(); + this.humidity = getExactHumidity(); + } + + private float getExactTemperature() { + float temperature = 0.0F; + int positions = 0; + + for(IClimatePosition position : this.positions.values()){ + if(position != null){ + positions++; + temperature+=position.getTemperature(); + } + } + return temperature / positions; + } + + private float getExactHumidity() { + float humidity = 0.0F; + int positions = 0; + + for(IClimatePosition position : this.positions.values()){ + if(position != null){ + positions++; + humidity+=position.getHumidity(); + } + } + return humidity / positions; } @Override - public void updateClimate() { - for(Entry position : positions.entrySet()){ - BlockPos pos = position.getKey(); - if(world.isBlockLoaded(pos)){ - updateSides(pos); - if(!controller.isAssembled()){ - Biome biome = world.getBiome(pos); + public void updateClimate(int ticks) { + for(IClimateSource source : sources){ + if(source != null){ + if(ticks % source.getTicksForChange(this) == 0){ + source.changeClimate(ticks, this); + } + } + } + if(ticks % getTicksPerUpdate() == 0){ + for(Entry position : positions.entrySet()){ + BlockPos pos = position.getKey(); + if(world.isBlockLoaded(pos)){ + updateSides(pos); - float biomeTemperature = biome.getTemperature(); - float biomeHumidity = biome.getRainfall(); - IClimatePosition climatedInfo = positions.get(pos); - - if(climatedInfo.getTemperature() != biomeTemperature){ - if(climatedInfo.getTemperature() > biomeTemperature){ - climatedInfo.addTemperature(-0.01F); - }else{ - climatedInfo.addTemperature(0.01F); + if(!controller.isAssembled()){ + IClimateControl climateControl = getControl(pos); + IClimatePosition climatedInfo = positions.get(pos); + + if(climatedInfo.getTemperature() != climateControl.getControlTemperature()){ + if(climatedInfo.getTemperature() > climateControl.getControlTemperature()){ + climatedInfo.addTemperature(-Math.min(0.01F, climatedInfo.getTemperature() - climateControl.getControlTemperature())); + }else{ + climatedInfo.addTemperature(Math.min(0.01F, climateControl.getControlTemperature() - climatedInfo.getTemperature())); + } } - } - - if(climatedInfo.getHumidity() != biomeHumidity){ - if(climatedInfo.getHumidity() > biomeHumidity){ - climatedInfo.addHumidity(-0.01F); - }else{ - climatedInfo.addHumidity(0.01F); + if(climatedInfo.getHumidity() != climateControl.getControlHumidity()){ + if(climatedInfo.getHumidity() > climateControl.getControlHumidity()){ + climatedInfo.addHumidity(-Math.min(0.01F, climatedInfo.getHumidity() - climateControl.getControlHumidity())); + }else{ + climatedInfo.addHumidity(Math.min(0.01F, climateControl.getControlHumidity() - climatedInfo.getHumidity())); + } } } } @@ -89,44 +150,51 @@ public class ClimateRoom implements IClimateRegion, IStreamable { } } - private void updateSides(BlockPos pos){ + protected void updateSides(BlockPos pos){ IClimatePosition climatedInfo = positions.get(pos); - for(EnumFacing facing : EnumFacing.VALUES){ - BlockPos facePos = pos.offset(facing); - IClimatePosition climatedInfoFace = positions.get(facePos); - if(climatedInfoFace != null){ - if(climatedInfoFace.getTemperature() >= 2.0F){ - if(climatedInfoFace.getTemperature() > 2.0F){ - climatedInfoFace.setTemperature(2.0F); + IClimateControl climateControl = getControl(pos); + boolean hasChange = false; + if(climateControl.getControlTemperature() != temperature || climateControl.getControlHumidity() != humidity) { + boolean updateTemp = climatedInfo.getTemperature() >= climateControl.getControlTemperature(); + boolean updateHum = climatedInfo.getHumidity() >= climateControl.getControlHumidity(); + if(updateTemp || updateHum){ + for(EnumFacing facing : EnumFacing.VALUES){ + IClimatePosition climatedInfoFace = positions.get(pos.offset(facing)); + if(climatedInfoFace != null){ + if(climatedInfo.getTemperature() > climatedInfoFace.getTemperature() + 0.01F){ + float change = Math.min(0.01F, climatedInfo.getTemperature() - climatedInfoFace.getTemperature()); + climatedInfo.addTemperature(-change); + climatedInfoFace.addTemperature(change); + updateTemp = climatedInfo.getTemperature() >= climateControl.getControlTemperature(); + hasChange = true; + } + if(climatedInfo.getHumidity() > climatedInfoFace.getHumidity() + 0.01F){ + float change = Math.min(0.01F, climatedInfo.getHumidity() - climatedInfoFace.getHumidity()); + climatedInfo.addHumidity(-change); + climatedInfoFace.addHumidity(change); + updateHum = climatedInfo.getTemperature() >= climateControl.getControlTemperature(); + hasChange = true; + } + if(!updateTemp && !updateHum){ + break; + } } - continue; - }else if(climatedInfoFace.getTemperature() <= 0.0F){ - if(climatedInfoFace.getTemperature() < 0.0F){ - climatedInfoFace.setTemperature(0.0F); - } - continue; - } - if(climatedInfoFace.getHumidity() >= 2.0F){ - if(climatedInfoFace.getHumidity() > 2.0F){ - climatedInfoFace.setHumidity(2.0F); - } - continue; - }else if(climatedInfoFace.getHumidity() <= 0.0F){ - if(climatedInfoFace.getHumidity() < 0.0F){ - climatedInfoFace.setHumidity(0.0F); - } - continue; - } - if(climatedInfo.getTemperature() > climatedInfoFace.getTemperature() + 0.01F){ - climatedInfo.addTemperature(-0.01F); - climatedInfoFace.addTemperature(0.01F); - } - if(climatedInfo.getHumidity() > climatedInfoFace.getHumidity() + 0.01F){ - climatedInfo.addHumidity(-0.01F); - climatedInfoFace.addHumidity(0.01F); } } } + if(hasChange){ + temperature = getExactTemperature(); + humidity = getExactHumidity(); + } + } + + protected IClimateControl getControl(BlockPos pos){ + if(world.isBlockLoaded(pos)){ + if(!controller.isAssembled()){ + return BiomeClimateControl.getControl(world.getBiome(pos)); + } + } + return controller.getClimateControl(); } @Override @@ -135,9 +203,9 @@ public class ClimateRoom implements IClimateRegion, IStreamable { for(Entry entry : positions.entrySet()){ BlockPos pos = entry.getKey(); NBTTagCompound tag = new NBTTagCompound(); - tag.setInteger("XPos", pos.getX()); - tag.setInteger("YPos", pos.getY()); - tag.setInteger("ZPos", pos.getZ()); + tag.setInteger("X", pos.getX()); + tag.setInteger("Y", pos.getY()); + tag.setInteger("Z", pos.getZ()); positionList.appendTag(entry.getValue().writeToNBT(tag)); } nbt.setTag("Positions", positionList); @@ -149,13 +217,16 @@ public class ClimateRoom implements IClimateRegion, IStreamable { NBTTagList positionList = nbt.getTagList("Positions", 10); for(int i = 0;i < positionList.tagCount();i++){ NBTTagCompound positionTag = positionList.getCompoundTagAt(i); - int xPos = positionTag.getInteger("XPos"); - int yPos = positionTag.getInteger("YPos"); - int zPos = positionTag.getInteger("ZPos"); + int xPos = positionTag.getInteger("X"); + int yPos = positionTag.getInteger("Y"); + int zPos = positionTag.getInteger("Z"); BlockPos pos = new BlockPos(xPos, yPos, zPos); - ClimatePosition position = new ClimatePosition(this, pos); - position.readFromNBT(positionTag); - positions.put(pos, position); + IClimatePosition position = positions.get(pos); + if(position != null){ + position.readFromNBT(positionTag); + }else{ + positions.put(pos, new ClimatePosition(this, pos, positionTag)); + } } } @@ -174,6 +245,35 @@ public class ClimateRoom implements IClimateRegion, IStreamable { return positions; } + protected void addPosition(BlockPos pos, float temperature, float humidity){ + IClimatePosition otherPosition = positions.get(pos); + if(otherPosition != null){ + otherPosition.setHumidity(humidity); + otherPosition.setTemperature(temperature); + }else{ + positions.put(pos, new ClimatePosition(this, pos, temperature, humidity)); + } + } + + @Override + public void addSource(IClimateSource source) { + if(!sources.contains(source)){ + sources.add(source); + } + } + + @Override + public void removeSource(IClimateSource source) { + if(sources.contains(source)){ + sources.remove(source); + } + } + + @Override + public Collection getSources() { + return sources; + } + @Override public List getOtherPositions() { return wallPositions; @@ -190,6 +290,8 @@ public class ClimateRoom implements IClimateRegion, IStreamable { data.writeFloat(pos.getTemperature()); data.writeFloat(pos.getHumidity()); } + data.writeFloat(temperature); + data.writeFloat(humidity); }else{ data.writeInt(0); } @@ -199,18 +301,23 @@ public class ClimateRoom implements IClimateRegion, IStreamable { public void readData(DataInputStreamForestry data) throws IOException { int size = data.readInt(); if(size != 0){ - positions = new HashMap<>(); + positions.clear();; for(int index = 0;index < size;index++){ - int xPos = data.readInt(); - int yPos = data.readInt(); - int zPos = data.readInt(); - float temperature = data.readFloat(); - float humidity = data.readFloat(); - - BlockPos pos = new BlockPos(xPos, yPos, zPos); - positions.put(pos, new ClimatePosition(this, pos, temperature, humidity)); + addPosition(new BlockPos(data.readInt(), data.readInt(), data.readInt()), data.readFloat(), data.readFloat()); } + temperature = data.readFloat(); + humidity = data.readFloat(); } } + + @Override + public float getTemperature() { + return temperature; + } + + @Override + public float getHumidity() { + return humidity; + } } diff --git a/src/main/java/forestry/core/climate/ClimateSource.java b/src/main/java/forestry/core/climate/ClimateSource.java new file mode 100644 index 000000000..0a96dbfca --- /dev/null +++ b/src/main/java/forestry/core/climate/ClimateSource.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.climate; + +import forestry.api.climate.IClimateRegion; +import forestry.api.climate.IClimateSource; +import forestry.api.climate.IClimateSourceProvider; + +public abstract class ClimateSource

implements IClimateSource { + + protected P provider; + protected final int ticksForChange; + + public ClimateSource(int ticksForChange) { + this.ticksForChange = ticksForChange; + } + + public void setProvider(P provider) { + this.provider = provider; + } + + @Override + public void changeClimate(int tickCount, IClimateRegion region) { + } + + @Override + public int getTicksForChange(IClimateRegion region) { + return ticksForChange; + } + + @Override + public IClimateSourceProvider getProvider() { + return provider; + } + +} diff --git a/src/main/java/forestry/core/climate/ClimatiserDefinition.java b/src/main/java/forestry/core/climate/ClimatiserDefinition.java new file mode 100644 index 000000000..63f2d559f --- /dev/null +++ b/src/main/java/forestry/core/climate/ClimatiserDefinition.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.climate; + +import forestry.api.climate.EnumClimatiserModes; +import forestry.api.climate.EnumClimatiserTypes; +import forestry.api.climate.IClimatiserDefinition; + +public class ClimatiserDefinition implements IClimatiserDefinition { + + protected final float change; + protected final EnumClimatiserModes mode; + protected final double range; + protected final EnumClimatiserTypes type; + + public ClimatiserDefinition(float change, EnumClimatiserModes mode, double range, EnumClimatiserTypes type) { + this.change = change; + this.mode = mode; + this.range = range; + this.type = type; + } + + @Override + public float getChange() { + return change; + } + + @Override + public double getRange() { + return range; + } + + @Override + public EnumClimatiserTypes getType() { + return type; + } + + @Override + public EnumClimatiserModes getMode() { + return mode; + } + +} diff --git a/src/main/java/forestry/core/genetics/mutations/Mutation.java b/src/main/java/forestry/core/genetics/mutations/Mutation.java index 95f86e24e..4a83b042a 100644 --- a/src/main/java/forestry/core/genetics/mutations/Mutation.java +++ b/src/main/java/forestry/core/genetics/mutations/Mutation.java @@ -19,9 +19,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.BiomeDictionary; +import forestry.api.climate.IClimateProvider; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; -import forestry.api.core.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IAlleleSpecies; import forestry.api.genetics.IGenome; diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionBiome.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionBiome.java index 53bdb8c1d..002a8f99c 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionBiome.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionBiome.java @@ -14,13 +14,12 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; import net.minecraftforge.common.BiomeDictionary; - +import forestry.api.climate.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionDaytime.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionDaytime.java index 36ce2105e..6b9fd3ffa 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionDaytime.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionDaytime.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.core.genetics.mutations; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - +import forestry.api.climate.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java index 81484b46b..6837e5e05 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionHumidity.java @@ -10,10 +10,9 @@ ******************************************************************************/ package forestry.core.genetics.mutations; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - +import forestry.api.climate.IClimateProvider; import forestry.api.core.EnumHumidity; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java index 237e078a1..b08214b42 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionRequiresResource.java @@ -15,7 +15,7 @@ import java.util.HashSet; import java.util.Set; import forestry.api.apiculture.IBeeHousing; -import forestry.api.core.IClimateProvider; +import forestry.api.climate.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java index ab40c2df1..3a890c373 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionTemperature.java @@ -10,11 +10,10 @@ ******************************************************************************/ package forestry.core.genetics.mutations; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; - +import forestry.api.climate.IClimateProvider; import forestry.api.core.EnumTemperature; import forestry.api.genetics.AlleleManager; import forestry.api.genetics.IAllele; diff --git a/src/main/java/forestry/core/genetics/mutations/MutationConditionTimeLimited.java b/src/main/java/forestry/core/genetics/mutations/MutationConditionTimeLimited.java index 8da289c86..0fbad9cb7 100644 --- a/src/main/java/forestry/core/genetics/mutations/MutationConditionTimeLimited.java +++ b/src/main/java/forestry/core/genetics/mutations/MutationConditionTimeLimited.java @@ -12,10 +12,9 @@ package forestry.core.genetics.mutations; import java.util.Calendar; -import forestry.api.core.IClimateProvider; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; - +import forestry.api.climate.IClimateProvider; import forestry.api.genetics.IAllele; import forestry.api.genetics.IGenome; import forestry.api.genetics.IMutationCondition; diff --git a/src/main/java/forestry/core/gui/ContainerCamouflageSprayCan.java b/src/main/java/forestry/core/gui/ContainerCamouflageSprayCan.java new file mode 100644 index 000000000..ff9cbbcf1 --- /dev/null +++ b/src/main/java/forestry/core/gui/ContainerCamouflageSprayCan.java @@ -0,0 +1,12 @@ +package forestry.core.gui; + +import forestry.core.inventory.ItemInventoryCamouflageSprayCan; +import net.minecraft.entity.player.InventoryPlayer; + +public class ContainerCamouflageSprayCan extends ContainerItemInventory { + + public ContainerCamouflageSprayCan(ItemInventoryCamouflageSprayCan inventory, InventoryPlayer playerInventory) { + super(inventory, playerInventory, 8, 84); + } + +} diff --git a/src/main/java/forestry/core/gui/ContainerItemInventory.java b/src/main/java/forestry/core/gui/ContainerItemInventory.java index fd3c030c4..297e2c67d 100755 --- a/src/main/java/forestry/core/gui/ContainerItemInventory.java +++ b/src/main/java/forestry/core/gui/ContainerItemInventory.java @@ -58,5 +58,9 @@ public abstract class ContainerItemInventory extends Co } return result; } + + public I getItemInventory() { + return inventory; + } } diff --git a/src/main/java/forestry/core/gui/GuiCamouflageSprayCan.java b/src/main/java/forestry/core/gui/GuiCamouflageSprayCan.java new file mode 100644 index 000000000..244ef75de --- /dev/null +++ b/src/main/java/forestry/core/gui/GuiCamouflageSprayCan.java @@ -0,0 +1,27 @@ +package forestry.core.gui; + +import forestry.core.config.Constants; +import forestry.core.gui.widgets.WidgetCamouflageSlot; +import forestry.core.inventory.ItemInventoryCamouflageSprayCan; +import forestry.core.utils.Translator; +import net.minecraft.entity.player.EntityPlayer; + +public class GuiCamouflageSprayCan extends GuiForestry { + + public GuiCamouflageSprayCan(EntityPlayer player, ItemInventoryCamouflageSprayCan inventory) { + super(Constants.TEXTURE_PATH_GUI + "/camouflageSprayCan.png", new ContainerCamouflageSprayCan(inventory, player.inventory), inventory); + + widgetManager.add(new WidgetCamouflageSlot(widgetManager, 80, 39, inventory, null)); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + + String name = Translator.translateToLocal("for.gui.camouflage.spray.can"); + textLayout.line = 6; + textLayout.drawCenteredLine(name, 0, fontColor.get("gui.title")); + bindTexture(textureFile); + } + +} diff --git a/src/main/java/forestry/core/gui/GuiIdRegistry.java b/src/main/java/forestry/core/gui/GuiIdRegistry.java index 6ab306853..bfe0277b1 100644 --- a/src/main/java/forestry/core/gui/GuiIdRegistry.java +++ b/src/main/java/forestry/core/gui/GuiIdRegistry.java @@ -25,6 +25,7 @@ import forestry.apiculture.multiblock.TileAlvearySieve; import forestry.apiculture.tiles.TileApiary; import forestry.apiculture.tiles.TileBeeHouse; import forestry.core.items.ItemAlyzer; +import forestry.core.items.ItemCamouflageSprayCan; import forestry.core.items.ItemSolderingIron; import forestry.core.tiles.TileAnalyzer; import forestry.core.tiles.TileEscritoire; @@ -105,7 +106,8 @@ public class GuiIdRegistry { ItemImprinter.class, ItemInfuser.class, ItemLetter.class, - ItemSolderingIron.class + ItemSolderingIron.class, + ItemCamouflageSprayCan.class )); registerGuiHandlers(GuiType.Entity, Arrays.asList( diff --git a/src/main/java/forestry/greenhouse/gui/widgets/WidgetCamouflageSlot.java b/src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java similarity index 93% rename from src/main/java/forestry/greenhouse/gui/widgets/WidgetCamouflageSlot.java rename to src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java index 67e1617c0..dae353598 100644 --- a/src/main/java/forestry/greenhouse/gui/widgets/WidgetCamouflageSlot.java +++ b/src/main/java/forestry/core/gui/widgets/WidgetCamouflageSlot.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.greenhouse.gui.widgets; +package forestry.core.gui.widgets; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -25,8 +25,6 @@ import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflageItemHandler; import forestry.api.multiblock.IMultiblockController; import forestry.core.gui.tooltips.ToolTip; -import forestry.core.gui.widgets.Widget; -import forestry.core.gui.widgets.WidgetManager; import forestry.core.proxy.Proxies; import forestry.core.utils.Translator; @@ -65,8 +63,8 @@ public class WidgetCamouflageSlot extends Widget { if (stack != null) { if (!CamouflageManager.camouflageAccess.isItemBlackListed(type, stack)) { for(ICamouflageItemHandler handler : CamouflageManager.camouflageAccess.getCamouflageItemHandler(type)){ - if(handler != null && handler.canHandle(stack, camouflageHandler)){ - camouflageHandler.setCamouflageBlock(type, stack.copy()); + if(handler != null && handler.canHandle(stack)){ + camouflageHandler.setCamouflageBlock(handler.getType(), stack.copy()); } } } diff --git a/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java b/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java new file mode 100644 index 000000000..171b33f6b --- /dev/null +++ b/src/main/java/forestry/core/inventory/ItemInventoryCamouflageSprayCan.java @@ -0,0 +1,56 @@ +package forestry.core.inventory; + +import forestry.api.core.ICamouflageHandler; +import forestry.core.network.packets.CamouflageSelectionType; +import forestry.core.network.packets.PacketCamouflageSelectServer; +import forestry.core.proxy.Proxies; +import forestry.core.utils.ItemStackUtil; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class ItemInventoryCamouflageSprayCan extends ItemInventory implements ICamouflageHandler { + + public ItemInventoryCamouflageSprayCan(EntityPlayer player, ItemStack parent) { + super(player, 1, parent); + } + + @Override + public ItemStack getCamouflageBlock(String type) { + return getStackInSlot(0); + } + + @Override + public ItemStack getDefaultCamouflageBlock(String type) { + return null; + } + + @Override + public boolean canHandleType(String type) { + return true; + } + + @Override + public void setCamouflageBlock(String type, ItemStack camouflageBlock) { + if(!ItemStackUtil.isIdenticalItem(camouflageBlock, getStackInSlot(0))){ + setInventorySlotContents(0, camouflageBlock); + + World world = player.worldObj; + if (world != null && world.isRemote) { + Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.ITEM)); + } + } + } + + @Override + public BlockPos getCoordinates() { + return new BlockPos(player); + } + + @Override + public World getWorld() { + return null; + } + +} diff --git a/src/main/java/forestry/core/items/ItemBlockForestry.java b/src/main/java/forestry/core/items/ItemBlockForestry.java index c1c691fa4..1572b7263 100644 --- a/src/main/java/forestry/core/items/ItemBlockForestry.java +++ b/src/main/java/forestry/core/items/ItemBlockForestry.java @@ -12,7 +12,7 @@ package forestry.core.items; import java.util.List; -import forestry.core.blocks.BlockBase; +import forestry.core.blocks.IBlockRotatable; import forestry.core.blocks.IBlockWithMeta; import forestry.core.tiles.TileForestry; import forestry.core.tiles.TileUtil; @@ -77,8 +77,8 @@ public class ItemBlockForestry extends ItemBlock { } } - if (block instanceof BlockBase) { - ((BlockBase) block).rotateAfterPlacement(player, world, pos, side); + if (block instanceof IBlockRotatable) { + ((IBlockRotatable) block).rotateAfterPlacement(player, world, pos, side); } } diff --git a/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java b/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java new file mode 100644 index 000000000..8c16e3f13 --- /dev/null +++ b/src/main/java/forestry/core/items/ItemCamouflageSprayCan.java @@ -0,0 +1,69 @@ +package forestry.core.items; + +import forestry.api.core.CamouflageManager; +import forestry.api.core.ICamouflageHandler; +import forestry.api.core.IModelManager; +import forestry.core.gui.ContainerCamouflageSprayCan; +import forestry.core.gui.GuiCamouflageSprayCan; +import forestry.core.inventory.ItemInventoryCamouflageSprayCan; +import net.minecraft.client.renderer.block.model.ModelBakery; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class ItemCamouflageSprayCan extends ItemWithGui { + + @Override + public Object getGui(EntityPlayer player, ItemStack heldItem, int data) { + return new GuiCamouflageSprayCan(player, new ItemInventoryCamouflageSprayCan(player, heldItem)); + } + + @Override + public Object getContainer(EntityPlayer player, ItemStack heldItem, int data) { + return new ContainerCamouflageSprayCan(new ItemInventoryCamouflageSprayCan(player, heldItem), player.inventory); + } + + @Override + public void registerModel(Item item, IModelManager manager) { + super.registerModel(item, manager); + ModelBakery.registerItemVariants(item, new ResourceLocation("forestry:camouflageSprayCanFilled")); + } + + @Override + public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) { + ItemInventoryCamouflageSprayCan inventory = new ItemInventoryCamouflageSprayCan(player, stack); + ItemStack camouflage = inventory.getStackInSlot(0); + if(camouflage != null){ + TileEntity tile = world.getTileEntity(pos); + if(tile instanceof ICamouflageHandler){ + ICamouflageHandler handler = (ICamouflageHandler) tile; + String type = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflage).getType(); + if(type != null && handler.canHandleType(type)){ + if(world.isRemote){ + handler.setCamouflageBlock(type, camouflage); + } + return EnumActionResult.SUCCESS; + } + } + } + return EnumActionResult.PASS; + } + + @Override + public ActionResult onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { + if (!worldIn.isRemote && playerIn.isSneaking()) { + openGui(playerIn); + } + + return ActionResult.newResult(EnumActionResult.SUCCESS, itemStackIn); + } + +} diff --git a/src/main/java/forestry/core/items/ItemRegistryCore.java b/src/main/java/forestry/core/items/ItemRegistryCore.java index e8e5ff8f0..303f893d5 100644 --- a/src/main/java/forestry/core/items/ItemRegistryCore.java +++ b/src/main/java/forestry/core/items/ItemRegistryCore.java @@ -89,6 +89,9 @@ public class ItemRegistryCore extends ItemRegistry { public final ItemForestry refractoryWax; public final ItemFruit fruits; + /* Camouflage */ + public final ItemCamouflageSprayCan camouflageSprayCan; + public ItemRegistryCore() { fertilizerBio = registerItem(new ItemForestry(), "fertilizerBio"); fertilizerCompound = registerItem(new ItemFertilizer(), "fertilizerCompound"); @@ -186,6 +189,9 @@ public class ItemRegistryCore extends ItemRegistry { ItemStack fruit = new ItemStack(fruits, 1, def.ordinal()); OreDictionary.registerOre(def.getOreDict(), fruit); } + + // CAMOUFLAGE + camouflageSprayCan = registerItem(new ItemCamouflageSprayCan(), "camouflageSprayCan"); } } diff --git a/src/main/java/forestry/core/models/ModelCamouflageSprayCan.java b/src/main/java/forestry/core/models/ModelCamouflageSprayCan.java new file mode 100644 index 000000000..863040f31 --- /dev/null +++ b/src/main/java/forestry/core/models/ModelCamouflageSprayCan.java @@ -0,0 +1,104 @@ +package forestry.core.models; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.vecmath.Matrix4f; + +import org.apache.commons.lang3.tuple.Pair; + +import forestry.core.inventory.ItemInventoryCamouflageSprayCan; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.block.model.BakedQuad; +import net.minecraft.client.renderer.block.model.IBakedModel; +import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; +import net.minecraft.client.renderer.block.model.ItemOverrideList; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.client.model.IModel; +import net.minecraftforge.client.model.IPerspectiveAwareModel; +import net.minecraftforge.client.model.ModelLoaderRegistry; +import net.minecraftforge.common.model.IModelState; +import net.minecraftforge.fml.relauncher.Side; + +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public class ModelCamouflageSprayCan extends BlankModel { + + @Override + protected ItemOverrideList createOverrides() { + return new SprayCanOverrideList(); + } + + private class SprayCanOverrideList extends ItemOverrideList{ + + public SprayCanOverrideList() { + super(Collections.emptyList()); + } + + @Override + public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) { + IModel basicModel = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("forestry:item/camouflageSprayCan")); + IBakedModel model = basicModel.bake(basicModel.getDefaultState(), DefaultVertexFormats.ITEM, new DefaultTextureGetter()); + IBakedModel filledModel = basicModel.bake(basicModel.getDefaultState(), DefaultVertexFormats.ITEM, new DefaultTextureGetter()); + IBakedModel camouflageModel = null; + + if(stack.hasTagCompound() && entity instanceof EntityPlayer){ + ItemInventoryCamouflageSprayCan inventory = new ItemInventoryCamouflageSprayCan((EntityPlayer) entity, stack); + ItemStack camouflage = inventory.getStackInSlot(0); + if(camouflage != null){ + IModel filledBasicModel = ModelLoaderRegistry.getModelOrMissing(new ResourceLocation("forestry:item/camouflageSprayCanFilled")); + filledModel = filledBasicModel.bake(filledBasicModel.getDefaultState(), DefaultVertexFormats.ITEM, new DefaultTextureGetter()); + + camouflageModel = new TRSRBakedModel(Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(camouflage), -0.0625F * 3, 0.0625F * 3, 0.0625F, 0.5F); + } + + } + return new SprayCanModel(model, filledModel, camouflageModel, ModelManager.getInstance().DEFAULT_ITEM); + } + + } + + private class SprayCanModel extends BlankModel implements IPerspectiveAwareModel{ + + private final IBakedModel originalModel; + private final IBakedModel camouflageModel; + private final IModelState state; + private final IBakedModel filledModel; + + public SprayCanModel(IBakedModel originalModel, IBakedModel filledModel, IBakedModel camouflageModel, IModelState state) { + this.originalModel = originalModel; + this.filledModel = filledModel; + this.camouflageModel = camouflageModel; + this.state = state; + } + + @Override + public List getQuads(IBlockState state, EnumFacing side, long rand) { + List quads = new ArrayList<>(); + quads.addAll(filledModel.getQuads(state, side, rand)); + if(camouflageModel != null){ + quads.addAll(camouflageModel.getQuads(state, side, rand)); + } + return quads; + } + + @Override + public Pair handlePerspective(TransformType cameraTransformType) { + if(cameraTransformType == TransformType.GUI){ + return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType); + } + return IPerspectiveAwareModel.MapWrapper.handlePerspective(originalModel, state, cameraTransformType); + } + + } + +} diff --git a/src/main/java/forestry/core/network/PacketIdClient.java b/src/main/java/forestry/core/network/PacketIdClient.java index 8a62fc3e2..d1397f09a 100644 --- a/src/main/java/forestry/core/network/PacketIdClient.java +++ b/src/main/java/forestry/core/network/PacketIdClient.java @@ -26,6 +26,7 @@ public enum PacketIdClient implements IPacketId { GUI_LAYOUT_SELECT, GUI_ENERGY, SOCKET_UPDATE, + CAMOUFLAGE_SELECTION, // Core Tile Entities TILE_FORESTRY_UPDATE, diff --git a/src/main/java/forestry/core/network/PacketIdServer.java b/src/main/java/forestry/core/network/PacketIdServer.java index b9dcfd1ad..b62eb1ce9 100644 --- a/src/main/java/forestry/core/network/PacketIdServer.java +++ b/src/main/java/forestry/core/network/PacketIdServer.java @@ -23,15 +23,14 @@ public enum PacketIdServer implements IPacketId { PIPETTE_CLICK, CHIPSET_CLICK, SOLDERING_IRON_CLICK, + CAMOUFLAGE_SELECTION, + CLIMATE_CONTROL_UPDATE, // JEI WORKTABLE_RECIPE_REQUEST, // Apiculture BEE_LOGIC_ACTIVE_ENTITY_REQUEST, - - //Greenhouse - TILE_FORESTRY_CAMOUFLAGE, // Mail LETTER_INFO_REQUEST, diff --git a/src/main/java/forestry/core/network/PacketRegistryCore.java b/src/main/java/forestry/core/network/PacketRegistryCore.java index 2c53b67fe..8e1784d52 100644 --- a/src/main/java/forestry/core/network/PacketRegistryCore.java +++ b/src/main/java/forestry/core/network/PacketRegistryCore.java @@ -10,6 +10,8 @@ ******************************************************************************/ package forestry.core.network; +import forestry.core.network.packets.PacketCamouflageSelectClient; +import forestry.core.network.packets.PacketCamouflageSelectServer; import forestry.core.network.packets.PacketChipsetClick; import forestry.core.network.packets.PacketErrorUpdate; import forestry.core.network.packets.PacketErrorUpdateEntity; @@ -26,6 +28,7 @@ import forestry.core.network.packets.PacketSocketUpdate; import forestry.core.network.packets.PacketSolderingIronClick; import forestry.core.network.packets.PacketTankLevelUpdate; import forestry.core.network.packets.PacketTileStream; +import forestry.core.network.packets.PacketUpdateClimateControl; public class PacketRegistryCore extends PacketRegistry { @Override @@ -42,10 +45,13 @@ public class PacketRegistryCore extends PacketRegistry { registerClientPacket(new PacketFXSignal()); registerClientPacket(new PacketTankLevelUpdate()); registerClientPacket(new PacketGenomeTrackerSync()); + registerClientPacket(new PacketCamouflageSelectClient()); registerServerPacket(new PacketGuiSelectRequest()); registerServerPacket(new PacketPipetteClick()); registerServerPacket(new PacketChipsetClick()); registerServerPacket(new PacketSolderingIronClick()); + registerServerPacket(new PacketCamouflageSelectServer()); + registerServerPacket(new PacketUpdateClimateControl()); } } diff --git a/src/main/java/forestry/core/network/packets/CamouflageSelectionType.java b/src/main/java/forestry/core/network/packets/CamouflageSelectionType.java new file mode 100644 index 000000000..41caf7f82 --- /dev/null +++ b/src/main/java/forestry/core/network/packets/CamouflageSelectionType.java @@ -0,0 +1,8 @@ +package forestry.core.network.packets; + +public enum CamouflageSelectionType { + TILE, MULTIBLOCK, ITEM; + + public static final CamouflageSelectionType[] VALUES = values(); + +} diff --git a/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java new file mode 100644 index 000000000..2129defee --- /dev/null +++ b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectClient.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.network.packets; + +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import forestry.api.core.ICamouflageHandler; +import forestry.api.core.ICamouflagedTile; +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockController; +import forestry.core.network.DataInputStreamForestry; +import forestry.core.network.DataOutputStreamForestry; +import forestry.core.network.IForestryPacketClient; +import forestry.core.network.PacketIdClient; + +public class PacketCamouflageSelectClient extends PacketCoordinates implements IForestryPacketClient{ + + private ItemStack camouflageStack; + private String camouflageType; + private CamouflageSelectionType selectionType; + + public PacketCamouflageSelectClient() { + } + + public PacketCamouflageSelectClient(ICamouflageHandler handler, String camouflageType, CamouflageSelectionType selectionType) { + super(handler.getCoordinates()); + this.camouflageStack = handler.getCamouflageBlock(camouflageType); + this.selectionType = selectionType; + this.camouflageType = camouflageType; + } + + @Override + public PacketIdClient getPacketId() { + return PacketIdClient.CAMOUFLAGE_SELECTION; + } + + @Override + protected void writeData(DataOutputStreamForestry data) throws IOException { + super.writeData(data); + data.writeShort(selectionType.ordinal()); + data.writeBoolean(camouflageType != null); + if(camouflageType != null){ + data.writeUTF(camouflageType); + } + data.writeItemStack(camouflageStack); + } + + @Override + public void readData(DataInputStreamForestry data) throws IOException { + super.readData(data); + selectionType = CamouflageSelectionType.values()[data.readShort()]; + if(data.readBoolean()){ + camouflageType = data.readUTF(); + } + camouflageStack = data.readItemStack(); + } + + @Override + public void onPacketData(DataInputStreamForestry data, EntityPlayer player) { + TileEntity tile = getTarget(player.worldObj); + ICamouflageHandler handler = null; + if(selectionType == CamouflageSelectionType.MULTIBLOCK){ + if (tile instanceof IMultiblockComponent) { + IMultiblockController controller = ((IMultiblockComponent) tile).getMultiblockLogic().getController(); + + if (controller instanceof ICamouflageHandler) { + handler = (ICamouflageHandler) controller; + handler.setCamouflageBlock(camouflageType, camouflageStack); + for (IMultiblockComponent comp : controller.getComponents()) { + if (comp instanceof ICamouflagedTile) { + ICamouflagedTile camBlock = (ICamouflagedTile) comp; + if (camouflageType != null && camBlock.getCamouflageType() != null && camBlock.getCamouflageType().equals(camouflageType)) { + player.worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates()); + } + } + } + } + } + }else if(selectionType == CamouflageSelectionType.TILE){ + if (tile instanceof ICamouflageHandler) { + handler = (ICamouflageHandler) tile; + handler.setCamouflageBlock(camouflageType, camouflageStack); + player.worldObj.markBlockRangeForRenderUpdate(getPos(), getPos()); + } + } + + if (handler != null) { + handler.setCamouflageBlock(camouflageType, camouflageStack); + } + } +} diff --git a/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java new file mode 100644 index 000000000..5cb2798bd --- /dev/null +++ b/src/main/java/forestry/core/network/packets/PacketCamouflageSelectServer.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2011-2014 SirSengir. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the GNU Lesser Public License v3 + * which accompanies this distribution, and is available at + * http://www.gnu.org/licenses/lgpl-3.0.txt + * + * Various Contributors including, but not limited to: + * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges + ******************************************************************************/ +package forestry.core.network.packets; + +import java.io.IOException; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import forestry.api.core.ICamouflageHandler; +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockController; +import forestry.core.gui.ContainerCamouflageSprayCan; +import forestry.core.inventory.ItemInventoryCamouflageSprayCan; +import forestry.core.network.DataInputStreamForestry; +import forestry.core.network.DataOutputStreamForestry; +import forestry.core.network.IForestryPacketServer; +import forestry.core.network.PacketIdServer; +import forestry.core.proxy.Proxies; + +public class PacketCamouflageSelectServer extends PacketCoordinates implements IForestryPacketServer{ + + private ItemStack camouflageStack; + private String camouflageType; + private CamouflageSelectionType selectionType; + + public PacketCamouflageSelectServer() { + } + + public PacketCamouflageSelectServer(ICamouflageHandler handler, String camouflageType, CamouflageSelectionType selectionType) { + super(handler.getCoordinates()); + this.camouflageStack = handler.getCamouflageBlock(camouflageType); + this.selectionType = selectionType; + this.camouflageType = camouflageType; + } + + @Override + public PacketIdServer getPacketId() { + return PacketIdServer.CAMOUFLAGE_SELECTION; + } + + @Override + protected void writeData(DataOutputStreamForestry data) throws IOException { + super.writeData(data); + data.writeShort(selectionType.ordinal()); + data.writeBoolean(camouflageType != null); + if(camouflageType != null){ + data.writeUTF(camouflageType); + } + data.writeItemStack(camouflageStack); + } + + @Override + public void readData(DataInputStreamForestry data) throws IOException { + super.readData(data); + selectionType = CamouflageSelectionType.values()[data.readShort()]; + if(data.readBoolean()){ + camouflageType = data.readUTF(); + } + camouflageStack = data.readItemStack(); + } + + @Override + public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) { + TileEntity tile = getTarget(player.worldObj); + ICamouflageHandler handler = null; + if(selectionType == CamouflageSelectionType.MULTIBLOCK){ + if (tile instanceof IMultiblockComponent) { + IMultiblockController controller = ((IMultiblockComponent) tile).getMultiblockLogic().getController(); + + if (controller instanceof ICamouflageHandler) { + handler = (ICamouflageHandler) controller; + } + + } + }else if(selectionType == CamouflageSelectionType.TILE){ + if (tile instanceof ICamouflageHandler) { + handler = (ICamouflageHandler) tile; + } + }else{ + if(player.openContainer instanceof ContainerCamouflageSprayCan){ + ContainerCamouflageSprayCan container = (ContainerCamouflageSprayCan) player.openContainer; + ItemInventoryCamouflageSprayCan itemInventoryCamouflageSprayCan = container.getItemInventory(); + if(itemInventoryCamouflageSprayCan != null){ + handler = itemInventoryCamouflageSprayCan; + } + } + } + + if (handler != null) { + handler.setCamouflageBlock(camouflageType, camouflageStack); + if(selectionType != CamouflageSelectionType.ITEM){ + Proxies.net.sendNetworkPacket(new PacketCamouflageSelectClient(handler, camouflageType, selectionType), player.worldObj); + } + } + } +} diff --git a/src/main/java/forestry/core/network/packets/PacketUpdateClimateControl.java b/src/main/java/forestry/core/network/packets/PacketUpdateClimateControl.java new file mode 100644 index 000000000..c0a120e90 --- /dev/null +++ b/src/main/java/forestry/core/network/packets/PacketUpdateClimateControl.java @@ -0,0 +1,72 @@ +package forestry.core.network.packets; + +import java.io.IOException; + +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimateControlProvider; +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockLogic; +import forestry.core.network.DataInputStreamForestry; +import forestry.core.network.DataOutputStreamForestry; +import forestry.core.network.IForestryPacketServer; +import forestry.core.network.PacketIdServer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.tileentity.TileEntity; + +public class PacketUpdateClimateControl extends PacketCoordinates implements IForestryPacketServer { + + private float controlTemperature; + private float controlHumidity; + + public PacketUpdateClimateControl() { + } + + public PacketUpdateClimateControl(IClimateControlProvider provider) { + super(provider.getCoordinates()); + + IClimateControl control = provider.getClimateControl(); + controlTemperature = control.getControlTemperature(); + controlHumidity = control.getControlHumidity(); + } + + @Override + protected void writeData(DataOutputStreamForestry data) throws IOException { + super.writeData(data); + + data.writeFloat(controlTemperature); + data.writeFloat(controlHumidity); + } + + @Override + public void readData(DataInputStreamForestry data) throws IOException { + super.readData(data); + + controlTemperature = data.readFloat(); + controlHumidity = data.readFloat(); + } + + @Override + public PacketIdServer getPacketId() { + return PacketIdServer.CLIMATE_CONTROL_UPDATE; + } + + @Override + public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) throws IOException { + TileEntity tile = getTarget(player.worldObj); + IClimateControl control = null; + if(tile instanceof IMultiblockComponent){ + IMultiblockComponent component = (IMultiblockComponent) tile; + IMultiblockLogic logic = component.getMultiblockLogic(); + if(logic.isConnected() && logic.getController() instanceof IClimateControlProvider){ + control = ((IClimateControlProvider) logic.getController()).getClimateControl(); + } + }else if(tile instanceof IClimateControlProvider){ + control = ((IClimateControlProvider) tile).getClimateControl(); + } + if(control != null){ + control.setControlTemperature(controlTemperature); + control.setControlHumidity(controlHumidity); + } + } + +} diff --git a/src/main/java/forestry/core/utils/CamouflageUtil.java b/src/main/java/forestry/core/utils/CamouflageUtil.java index d8bcf871b..0fb459193 100644 --- a/src/main/java/forestry/core/utils/CamouflageUtil.java +++ b/src/main/java/forestry/core/utils/CamouflageUtil.java @@ -15,6 +15,7 @@ import java.io.IOException; import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflagedTile; import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IMultiblockController; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import net.minecraft.item.ItemStack; @@ -58,23 +59,22 @@ public class CamouflageUtil { } public static ICamouflageHandler getCamouflageHandler(IBlockAccess world, BlockPos pos){ - if(pos == null){ + if(pos == null || world == null){ return null; } TileEntity tile = world.getTileEntity(pos); if(tile instanceof ICamouflagedTile){ ICamouflagedTile block = (ICamouflagedTile) tile; String type = block.getCamouflageType(); - ItemStack camouflageStack = null; ICamouflageHandler handler = null; if(tile instanceof ICamouflageHandler){ handler = (ICamouflageHandler) tile; - camouflageStack = handler.getCamouflageBlock(type); } - if(camouflageStack == null && tile instanceof IMultiblockComponent){ + if((handler == null || handler.getCamouflageBlock(type) == null) && tile instanceof IMultiblockComponent){ IMultiblockComponent component = (IMultiblockComponent) tile; - if(component.getMultiblockLogic().getController() instanceof ICamouflageHandler){ - handler = (ICamouflageHandler) component.getMultiblockLogic().getController(); + IMultiblockController controller = component.getMultiblockLogic().getController(); + if(controller instanceof ICamouflageHandler){ + handler = (ICamouflageHandler) controller; } } return handler; @@ -83,7 +83,7 @@ public class CamouflageUtil { } public static ItemStack getCamouflageBlock(IBlockAccess world, BlockPos pos){ - if(pos == null){ + if(pos == null || world == null){ return null; } TileEntity tile = world.getTileEntity(pos); @@ -91,18 +91,26 @@ public class CamouflageUtil { ICamouflagedTile block = (ICamouflagedTile) tile; String type = block.getCamouflageType(); ItemStack camouflageStack = null; + ICamouflageHandler tileHandler = null; + ICamouflageHandler multiblockHandler = null; if(tile instanceof ICamouflageHandler){ - ICamouflageHandler handler = (ICamouflageHandler) tile; - camouflageStack = handler.getCamouflageBlock(type); + tileHandler = (ICamouflageHandler) tile; + camouflageStack = tileHandler.getCamouflageBlock(type); } if(camouflageStack == null && tile instanceof IMultiblockComponent){ IMultiblockComponent component = (IMultiblockComponent) tile; - if(component.getMultiblockLogic().getController() instanceof ICamouflageHandler){ - ICamouflageHandler handler = (ICamouflageHandler) component.getMultiblockLogic().getController(); - camouflageStack = handler.getCamouflageBlock(type); - if(camouflageStack == null){ - camouflageStack = handler.getDefaultCamouflageBlock(type); - } + IMultiblockController controller = component.getMultiblockLogic().getController(); + if(controller.isAssembled() && controller instanceof ICamouflageHandler){ + multiblockHandler = (ICamouflageHandler) controller; + camouflageStack = multiblockHandler.getCamouflageBlock(type); + } + } + if(camouflageStack == null){ + if(tileHandler != null){ + camouflageStack = tileHandler.getDefaultCamouflageBlock(type); + } + if(multiblockHandler != null && camouflageStack == null){ + camouflageStack = multiblockHandler.getDefaultCamouflageBlock(type); } } return camouflageStack; diff --git a/src/main/java/forestry/greenhouse/GreenhouseClimateSource.java b/src/main/java/forestry/greenhouse/GreenhouseClimateSource.java new file mode 100644 index 000000000..8bc39b154 --- /dev/null +++ b/src/main/java/forestry/greenhouse/GreenhouseClimateSource.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * 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.EnumClimatiserModes; +import forestry.api.climate.EnumClimatiserTypes; +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimatePosition; +import forestry.api.climate.IClimateRegion; +import forestry.api.climate.IClimatiserDefinition; +import forestry.api.multiblock.IMultiblockController; +import forestry.api.multiblock.IMultiblockLogic; +import forestry.core.climate.ClimateSource; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; +import forestry.greenhouse.tiles.TileGreenhouseClimatiser; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class GreenhouseClimateSource

extends ClimateSource

{ + + public GreenhouseClimateSource(int ticksForChange) { + super(ticksForChange); + } + + @Override + public void changeClimate(int tickCount, IClimateRegion region) { + World world = region.getWorld(); + IClimatiserDefinition definition = provider.getDefinition(); + IMultiblockLogic logic = provider.getMultiblockLogic(); + IMultiblockController controller = logic.getController(); + Iterable positionsInRange = provider.getPositionsInRange(); + + boolean isActive = false; + if(logic.isConnected() && controller.isAssembled() && controller instanceof IGreenhouseControllerInternal && positionsInRange != null && positionsInRange.iterator().hasNext() && region != null){ + IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller; + IClimateControl climateControl = getClimateControl(greenhouseInternal); + float controlTemp = climateControl.getControlTemperature(); + float controlHum = climateControl.getControlHumidity(); + isActive = greenhouseInternal.canWork() && provider.canWork(); + EnumClimatiserTypes type = definition.getType(); + EnumClimatiserModes mode = definition.getMode(); + float maxChange = definition.getChange(); + if(isActive){ + if(canChange(type, EnumClimatiserTypes.TEMPERATURE)){ + if(region.getTemperature() < controlTemp) { + if(!canChange(mode, EnumClimatiserModes.POSITIVE)){ + isActive = false; + } + }else if(region.getTemperature() > controlTemp){ + if(!canChange(mode, EnumClimatiserModes.NEGATIVE)){ + isActive = false; + } + } + } + if (canChange(type, EnumClimatiserTypes.HUMIDITY)) { + if(region.getTemperature() < controlHum) { + if(!canChange(mode, EnumClimatiserModes.POSITIVE)){ + isActive = false; + } + }else if(region.getTemperature() > controlHum){ + if(!canChange(mode, EnumClimatiserModes.NEGATIVE)){ + isActive = false; + } + } + } + } + + if (isActive) { + for(BlockPos pos : positionsInRange){ + IClimatePosition position = region.getPositions().get(pos); + if(position != null){ + double distance = pos.distanceSq(provider.getCoordinates()); + double range = definition.getRange(); + if(distance <= range){ + float change = maxChange; + if(distance > 0){ + change = (float) (maxChange / distance); + } + if (canChange(type, EnumClimatiserTypes.TEMPERATURE)) { + if(position.getTemperature() < controlTemp) { + if(canChange(mode, EnumClimatiserModes.POSITIVE)){ + position.addTemperature(Math.min(change, controlTemp - position.getTemperature())); + } + }else if(position.getTemperature() > controlTemp){ + if(canChange(mode, EnumClimatiserModes.NEGATIVE)){ + position.addTemperature(-Math.min(position.getTemperature() - controlTemp, change)); + } + } + } + if (canChange(type, EnumClimatiserTypes.HUMIDITY)) { + if(position.getHumidity() < controlHum) { + if(canChange(mode, EnumClimatiserModes.POSITIVE)){ + position.addHumidity(Math.min(change, controlHum - position.getHumidity())); + } + }else if(position.getHumidity() > controlHum){ + if(canChange(mode, EnumClimatiserModes.NEGATIVE)){ + position.addHumidity(-Math.min(position.getHumidity() - controlHum, change)); + } + } + } + } + } + } + } + } + if(provider.isActive() != isActive){ + provider.setActive(isActive); + } + } + + protected boolean canChange(EnumClimatiserTypes climatiserType, EnumClimatiserTypes type){ + if(type == climatiserType || climatiserType == EnumClimatiserTypes.NONE){ + return true; + } + return false; + } + + protected boolean canChange(EnumClimatiserModes climatiserMode, EnumClimatiserModes mode){ + if(mode == climatiserMode || climatiserMode == EnumClimatiserModes.NONE){ + return true; + } + return false; + } + + protected IClimateControl getClimateControl(IGreenhouseControllerInternal greenhouseInternal){ + return greenhouseInternal.getClimateControl(); + } + +} diff --git a/src/main/java/forestry/greenhouse/GreenhouseClimateWindow.java b/src/main/java/forestry/greenhouse/GreenhouseClimateWindow.java new file mode 100644 index 000000000..6cee694f0 --- /dev/null +++ b/src/main/java/forestry/greenhouse/GreenhouseClimateWindow.java @@ -0,0 +1,105 @@ +package forestry.greenhouse; + +import forestry.api.climate.EnumClimatiserModes; +import forestry.api.climate.EnumClimatiserTypes; +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimatePosition; +import forestry.api.climate.IClimateRegion; +import forestry.api.climate.IClimatiserDefinition; +import forestry.api.multiblock.IMultiblockController; +import forestry.api.multiblock.IMultiblockLogic; +import forestry.core.climate.BiomeClimateControl; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; +import forestry.greenhouse.tiles.TileGreenhouseWindow; +import forestry.greenhouse.tiles.TileGreenhouseWindow.WindowMode; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; + +public class GreenhouseClimateWindow extends GreenhouseClimateSource{ + + private Biome biome; + + public GreenhouseClimateWindow(int ticksForChange) { + super(ticksForChange); + } + + @Override + public void changeClimate(int tickCount, IClimateRegion region) { + World world = region.getWorld(); + IClimatiserDefinition definition = provider.getDefinition(); + IMultiblockLogic logic = provider.getMultiblockLogic(); + IMultiblockController controller = logic.getController(); + Iterable positionsInRange = provider.getPositionsInRange(); + + WindowMode windowMode = provider.getMode(); + if(logic.isConnected() && controller.isAssembled() && controller instanceof IGreenhouseControllerInternal && positionsInRange != null && positionsInRange.iterator().hasNext() && region != null){ + IGreenhouseControllerInternal greenhouseInternal = (IGreenhouseControllerInternal) controller; + IClimateControl climateControl = getClimateControl(greenhouseInternal); + float controlTemp = climateControl.getControlTemperature(); + float controlHum = climateControl.getControlHumidity(); + if(!greenhouseInternal.canWork()){ + if(windowMode == WindowMode.OPEN){ + provider.setMode(windowMode = WindowMode.CONTROL); + } + }else{ + if(windowMode == WindowMode.CONTROL){ + provider.setMode(windowMode = WindowMode.OPEN); + } + } + if(windowMode == WindowMode.OPEN){ + int dimensionID = world.provider.getDimension(); + EnumClimatiserTypes type = definition.getType(); + EnumClimatiserModes mode = definition.getMode(); + float maxChange = definition.getChange(); + + for(BlockPos pos : positionsInRange){ + IClimatePosition position = region.getPositions().get(pos); + if(position != null){ + double distance = pos.distanceSq(provider.getCoordinates()); + double range = definition.getRange(); + if(distance <= range){ + float change = maxChange; + if(distance > 0){ + change = (float) (maxChange / distance); + } + if (canChange(type, EnumClimatiserTypes.TEMPERATURE)) { + if(position.getTemperature() < controlTemp) { + if(canChange(mode, EnumClimatiserModes.POSITIVE)){ + position.addTemperature(Math.min(change, controlTemp - position.getTemperature())); + } + }else if(position.getTemperature() > controlTemp){ + if(canChange(mode, EnumClimatiserModes.NEGATIVE)){ + position.addTemperature(-Math.min(position.getTemperature() - controlTemp, change)); + } + } + } + if (canChange(type, EnumClimatiserTypes.HUMIDITY)) { + if(position.getHumidity() < controlHum) { + if(canChange(mode, EnumClimatiserModes.POSITIVE)){ + position.addHumidity(Math.min(change, controlHum - position.getHumidity())); + } + }else if(position.getHumidity() > controlHum){ + if(canChange(mode, EnumClimatiserModes.NEGATIVE)){ + position.addHumidity(-Math.min(position.getHumidity() - controlHum, change)); + } + } + } + } + } + } + } + } + } + + @Override + protected IClimateControl getClimateControl(IGreenhouseControllerInternal greenhouseInternal) { + if(biome == null){ + BlockPos pos = provider.getCoordinates(); + World world = provider.getWorld(); + biome = world.getBiome(pos); + } + return BiomeClimateControl.getControl(biome); + } + +} diff --git a/src/main/java/forestry/greenhouse/PluginGreenhouse.java b/src/main/java/forestry/greenhouse/PluginGreenhouse.java index 5965a4900..91a6a14c4 100644 --- a/src/main/java/forestry/greenhouse/PluginGreenhouse.java +++ b/src/main/java/forestry/greenhouse/PluginGreenhouse.java @@ -12,6 +12,7 @@ package forestry.greenhouse; import net.minecraft.block.Block; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.registry.GameRegistry; @@ -23,16 +24,15 @@ import forestry.core.PluginCore; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; import forestry.core.items.EnumElectronTube; -import forestry.core.network.IPacketRegistry; import forestry.core.recipes.RecipeUtil; import forestry.core.utils.OreDictUtil; import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.blocks.BlockRegistryGreenhouse; import forestry.greenhouse.logics.GreenhouseLogicGreenhouseDoor; import forestry.greenhouse.logics.GreenhouseLogicGreenhouseEffect; -import forestry.greenhouse.network.PacketRegistryGreenhouse; import forestry.greenhouse.proxy.ProxyGreenhouse; import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch; +import forestry.greenhouse.tiles.TileGreenhouseClimateControl; import forestry.greenhouse.tiles.TileGreenhouseControl; import forestry.greenhouse.tiles.TileGreenhouseDoor; import forestry.greenhouse.tiles.TileGreenhouseDryer; @@ -43,6 +43,7 @@ import forestry.greenhouse.tiles.TileGreenhouseHeater; import forestry.greenhouse.tiles.TileGreenhousePlain; import forestry.greenhouse.tiles.TileGreenhouseSprinkler; import forestry.greenhouse.tiles.TileGreenhouseValve; +import forestry.greenhouse.tiles.TileGreenhouseWindow; import forestry.plugins.BlankForestryPlugin; import forestry.plugins.ForestryPlugin; import forestry.plugins.ForestryPluginUids; @@ -107,7 +108,7 @@ public class PluginGreenhouse extends BlankForestryPlugin { " X ", "#T#", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), - '#', "dustRedstone", + '#', OreDictUtil.DUST_REDSTONE, 'T', PluginCore.items.tubes.get(EnumElectronTube.GOLD, 1)); Block greenhouseGearBoxBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.GEARBOX); @@ -115,15 +116,15 @@ public class PluginGreenhouse extends BlankForestryPlugin { " X ", "###", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), - '#', "gearTin"); + '#', OreDictUtil.GEAR_TIN); Block greenhouseValveBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.VALVE); RecipeUtil.addRecipe(greenhouseValveBlock, " X ", "#G#", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), - '#', "blockGlass", - 'G', "gearTin"); + '#', OreDictUtil.BLOCK_GLASS, + 'G', OreDictUtil.GEAR_TIN); Block greenhouseHeaterBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.HEATER); RecipeUtil.addRecipe(greenhouseHeaterBlock, @@ -131,7 +132,7 @@ public class PluginGreenhouse extends BlankForestryPlugin { "#X#", "T#T", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), - '#', "ingotGold", + '#', OreDictUtil.INGOT_TIN, 'T', PluginCore.items.tubes.get(EnumElectronTube.GOLD, 1)); Block greenhouseFanlock = blocks.getGreenhouseBlock(BlockGreenhouseType.FAN); @@ -140,7 +141,7 @@ public class PluginGreenhouse extends BlankForestryPlugin { "#X#", "T#T", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), - '#', "ingotTin", + '#', OreDictUtil.INGOT_IRON, 'T', PluginCore.items.tubes.get(EnumElectronTube.TIN, 1)); Block greenhouseDryerBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.DRYER); @@ -149,16 +150,17 @@ public class PluginGreenhouse extends BlankForestryPlugin { "#X#", "T#T", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), - '#', "ingotBronze", + '#', OreDictUtil.INGOT_TIN, 'T', PluginCore.items.tubes.get(EnumElectronTube.BLAZE, 1)); Block greenhouseSprinklerBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.SPRINKLER); RecipeUtil.addRecipe(greenhouseSprinklerBlock, "TXT", + "GIG", " I ", - "III", 'X', blocks.getGreenhouseBlock(BlockGreenhouseType.GLASS), - 'I', "ingotIron", + 'I', OreDictUtil.INGOT_IRON, + 'G', OreDictUtil.GEAR_TIN, 'T', PluginCore.items.tubes.get(EnumElectronTube.LAPIS, 1)); Block greenhouseDoorBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.DOOR); @@ -168,14 +170,60 @@ public class PluginGreenhouse extends BlankForestryPlugin { "GG ", "GG ", 'G', blocks.getGreenhouseBlock(BlockGreenhouseType.GLASS)); + + Block greenhouseWindowBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.WINDOW); + RecipeUtil.addRecipe(greenhouseWindowBlock, + true, + "GGS", + "GGG", + "GGS", + 'G', blocks.getGreenhouseBlock(BlockGreenhouseType.GLASS), + 'S', OreDictUtil.STICK_WOOD); + + Block greenhouseWindowRoofBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.WINDOW_UP); + RecipeUtil.addRecipe(greenhouseWindowRoofBlock, + true, + "SGS", + "GGG", + "GGG", + 'G', blocks.getGreenhouseBlock(BlockGreenhouseType.GLASS), + 'S', OreDictUtil.STICK_WOOD); + + Block greenhouseClimateControlBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.CLIMATE_CONTROL); + RecipeUtil.addRecipe(greenhouseClimateControlBlock, + true, + "IRG", + "EBT", + "GRI", + 'B', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), + 'I', OreDictUtil.INGOT_BRONZE, + 'G', OreDictUtil.GEAR_TIN, + 'R', OreDictUtil.DUST_REDSTONE, + 'T', PluginCore.items.tubes.get(EnumElectronTube.LAPIS, 1), + 'E', PluginCore.items.tubes.get(EnumElectronTube.BLAZE, 1)); + + if(ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)){ + Block greenhouseButterflyHatchBlock = blocks.getGreenhouseBlock(BlockGreenhouseType.BUTTERFLY_HATCH); + RecipeUtil.addRecipe(greenhouseButterflyHatchBlock, + true, + "IRG", + "SBS", + "GRI", + 'R', OreDictUtil.DUST_REDSTONE, + 'I', OreDictUtil.INGOT_IRON, + 'G', OreDictUtil.GEAR_COPPER, + 'B', blocks.getGreenhouseBlock(BlockGreenhouseType.PLAIN), + 'S', PluginCore.items.craftingMaterial.getSilkWisp()); + } + if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.FACTORY)) { RecipeManagers.carpenterManager.addRecipe(50, Fluids.BIOMASS.getFluid(500), null, PluginCore.items.craftingMaterial.getCamouflagedPaneling(4), " A ", "###", "RPR", - '#', "plankWood", - 'A', "dustAsh", - 'R', "dustRedstone", - 'P', "pulpWood"); + '#', OreDictUtil.PLANK_WOOD, + 'A', OreDictUtil.DUST_ASH, + 'R', OreDictUtil.DUST_REDSTONE, + 'P', OreDictUtil.PULP_WOOD); } } @@ -193,6 +241,8 @@ public class PluginGreenhouse extends BlankForestryPlugin { GameRegistry.registerTileEntity(TileGreenhousePlain.class, "forestry.GreenhousePlain"); GameRegistry.registerTileEntity(TileGreenhouseDoor.class, "forestry.GreenhouseDoor"); GameRegistry.registerTileEntity(TileGreenhouseHatch.class, "forestry.GreenhouseHatch"); + GameRegistry.registerTileEntity(TileGreenhouseClimateControl.class, "forestry.GreenhouseClimateControl"); + GameRegistry.registerTileEntity(TileGreenhouseWindow.class, "forestry.GreenhouseWindow"); if (ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)) { GameRegistry.registerTileEntity(TileGreenhouseButterflyHatch.class, "forestry.GreenhouseButterflyHatch"); } @@ -208,9 +258,4 @@ public class PluginGreenhouse extends BlankForestryPlugin { GreenhouseManager.greenhouseHelper.addGreenhouseLogic(GreenhouseLogicGreenhouseDoor.class); } - @Override - public IPacketRegistry getPacketRegistry() { - return new PacketRegistryGreenhouse(); - } - } diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java index 236d11b66..a9e3aad56 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouse.java @@ -20,20 +20,29 @@ import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumFacing.Plane; +import net.minecraft.util.EnumHand; import net.minecraft.util.IStringSerializable; +import net.minecraft.util.Rotation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -52,12 +61,18 @@ import forestry.api.core.ISpriteRegister; import forestry.api.core.ITextureManager; import forestry.api.core.Tabs; import forestry.api.multiblock.IGreenhouseComponent; +import forestry.api.multiblock.IMultiblockController; import forestry.core.CreativeTabForestry; import forestry.core.blocks.BlockStructure; +import forestry.core.blocks.IBlockRotatable; import forestry.core.blocks.IColoredBlock; import forestry.core.blocks.propertys.UnlistedBlockAccess; import forestry.core.blocks.propertys.UnlistedBlockPos; +import forestry.core.multiblock.MultiblockTileEntityForestry; +import forestry.core.tiles.IActivatable; import forestry.core.utils.CamouflageUtil; +import forestry.core.utils.Log; +import forestry.greenhouse.tiles.TileGreenhouseClimateControl; import forestry.greenhouse.tiles.TileGreenhouseControl; import forestry.greenhouse.tiles.TileGreenhouseDoor; import forestry.greenhouse.tiles.TileGreenhouseDryer; @@ -68,11 +83,15 @@ import forestry.greenhouse.tiles.TileGreenhouseHeater; import forestry.greenhouse.tiles.TileGreenhousePlain; import forestry.greenhouse.tiles.TileGreenhouseSprinkler; import forestry.greenhouse.tiles.TileGreenhouseValve; +import forestry.greenhouse.tiles.TileGreenhouseWindow; +import forestry.greenhouse.tiles.TileGreenhouseWindow.WindowMode; import forestry.plugins.ForestryPluginUids; -public abstract class BlockGreenhouse extends BlockStructure implements ISpriteRegister, IColoredBlock { +public abstract class BlockGreenhouse extends BlockStructure implements ISpriteRegister, IColoredBlock, IBlockRotatable { private static final AxisAlignedBB SPRINKLER_BOUNDS = new AxisAlignedBB(0.3125F, 0.25F, 0.3125F, 0.6875F, 1F, 0.6875F); public static final PropertyEnum STATE = PropertyEnum.create("state", State.class); + public static final PropertyBool BLOCKED = PropertyBool.create("blocked"); + public static final PropertyDirection FACING = PropertyDirection.create("facing", Plane.HORIZONTAL); public enum State implements IStringSerializable { ON, OFF; @@ -106,7 +125,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR @Nonnull @Override public SoundType getSoundType() { - if(type == BlockGreenhouseType.SPRINKLER || type == BlockGreenhouseType.GLASS){ + if(type == BlockGreenhouseType.SPRINKLER || type == BlockGreenhouseType.GLASS || type == BlockGreenhouseType.WINDOW || type == BlockGreenhouseType.WINDOW_UP){ return SoundType.GLASS; } return super.getSoundType(); @@ -125,6 +144,9 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR if (greenhouseType.activatable && greenhouseType != BlockGreenhouseType.SPRINKLER) { defaultState = defaultState.withProperty(STATE, State.OFF); } + if(greenhouseType == BlockGreenhouseType.WINDOW || greenhouseType == BlockGreenhouseType.WINDOW_UP){ + defaultState = defaultState.withProperty(FACING, EnumFacing.NORTH); + } setDefaultState(defaultState); setHardness(1.0f); @@ -135,6 +157,78 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR setCreativeTab(CreativeTabForestry.tabForestry); } } + + @Override + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + if (player.isSneaking()) { + return false; + } + + TileEntity tile = worldIn.getTileEntity(pos); + if (!(tile instanceof MultiblockTileEntityForestry)) { + return false; + } + + MultiblockTileEntityForestry part = (MultiblockTileEntityForestry) tile; + IMultiblockController controller = part.getMultiblockLogic().getController(); + if(player.getHeldItemMainhand() == null){ + if(tile instanceof TileGreenhouseWindow){ + TileGreenhouseWindow window = (TileGreenhouseWindow) tile; + if(window.getMode() != WindowMode.CONTROL){ + if (!worldIn.isRemote) { + if(window.isBlocked() == WindowMode.OPEN){ + if(window.getMode() == WindowMode.OPEN){ + window.setMode(WindowMode.PLAYER); + }else{ + window.setMode(WindowMode.OPEN); + } + } + } + worldIn.playEvent(player, getPlaySound(!window.isActive()), pos, 0); + return true; + } + } + + if (player.getHeldItemOffhand() == null) { + // If the player's hands are empty and they right-click on a multiblock, they get a + // multiblock-debugging message if the machine is not assembled. + if (controller != null) { + if (!controller.isAssembled()) { + String validationError = controller.getLastValidationError(); + if (validationError != null) { + long tick = worldIn.getTotalWorldTime(); + if (tick > previousMessageTick + 20) { + player.addChatMessage(new TextComponentString(validationError)); + previousMessageTick = tick; + } + return true; + } + } + } else { + player.addChatMessage(new TextComponentTranslation("for.multiblock.error.notConnected")); + return true; + } + } + } + + // Don't open the GUI if the multiblock isn't assembled + if (controller == null || !controller.isAssembled()) { + return false; + } + + if (!worldIn.isRemote) { + part.openGui(player); + } + return true; + } + + protected int getPlaySound(boolean open){ + if (open){ + return 1007; + }else{ + return 1013; + } + } @Override @SideOnly(Side.CLIENT) @@ -153,14 +247,9 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR return super.getCollisionBoundingBox(blockState, worldIn, pos); } - @Override - public int getMetaFromState(IBlockState state) { - return 0; - } - @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - if (getGreenhouseType() != BlockGreenhouseType.SPRINKLER) { + if (getGreenhouseType() != BlockGreenhouseType.SPRINKLER && getGreenhouseType() != BlockGreenhouseType.WINDOW && getGreenhouseType() != BlockGreenhouseType.WINDOW_UP) { return ((IExtendedBlockState) super.getExtendedState(state, world, pos)).withProperty(UnlistedBlockPos.POS, pos) .withProperty(UnlistedBlockAccess.BLOCKACCESS, world); } @@ -171,7 +260,9 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR protected BlockStateContainer createBlockState() { if (getGreenhouseType() == BlockGreenhouseType.SPRINKLER) { return new ExtendedBlockState(this, new IProperty[]{Properties.StaticProperty}, new IUnlistedProperty[]{Properties.AnimationProperty}); - } else if (getGreenhouseType().activatable) { + }else if (getGreenhouseType() == BlockGreenhouseType.WINDOW || getGreenhouseType() == BlockGreenhouseType.WINDOW_UP) { + return new BlockStateContainer(this, STATE, FACING); + } else if (getGreenhouseType().activatable) { return new ExtendedBlockState(this, new IProperty[]{STATE}, new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS}); } else { return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{UnlistedBlockPos.POS, UnlistedBlockAccess.BLOCKACCESS}); @@ -183,10 +274,61 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR if (getGreenhouseType() == BlockGreenhouseType.SPRINKLER) { return state.withProperty(Properties.StaticProperty, true); } else { + TileEntity tile = worldIn.getTileEntity(pos); + if(tile instanceof IActivatable){ + state = state.withProperty(STATE, ((IActivatable) tile).isActive() ? State.ON : State.OFF); + } + if(tile instanceof TileGreenhouseWindow){ + TileGreenhouseWindow window = (TileGreenhouseWindow) tile; + } return super.getActualState(state, worldIn, pos); } } + @Override + public IBlockState withRotation(IBlockState state, Rotation rot) { + EnumFacing facing = state.getValue(FACING); + return state.withProperty(FACING, rot.rotate(facing)); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + if(getGreenhouseType() == BlockGreenhouseType.WINDOW || getGreenhouseType() == BlockGreenhouseType.WINDOW_UP){ + return getDefaultState().withProperty(FACING, EnumFacing.VALUES[meta + 2]); + } + return super.getStateFromMeta(meta); + } + + @Override + public int getMetaFromState(IBlockState state) { + if(getGreenhouseType() == BlockGreenhouseType.WINDOW || getGreenhouseType() == BlockGreenhouseType.WINDOW_UP){ + return state.getValue(FACING).ordinal() - 2; + } + return 0; + } + + @Override + public void rotateAfterPlacement(EntityPlayer player, World world, BlockPos pos, EnumFacing side) { + IBlockState state = world.getBlockState(pos); + + if(state.getProperties().containsKey(FACING)){ + world.setBlockState(pos, state.withProperty(FACING, player.getHorizontalFacing().getOpposite())); + } + } + + @Override + public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) { + try { + TileEntity tile = worldIn.getTileEntity(pos); + if (tile instanceof TileGreenhouseWindow) { + ((TileGreenhouseWindow) tile).onNeighborBlockChange(); + } + } catch (StackOverflowError error) { + Log.error("Stack Overflow Error in BlockMachine.onNeighborBlockChange()", error); + throw error; + } + } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item item, CreativeTabs tab, List list) { @@ -213,6 +355,11 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR return new TileGreenhouseDoor(); case CONTROL: return new TileGreenhouseControl(); + case CLIMATE_CONTROL: + return new TileGreenhouseClimateControl(); + case WINDOW_UP: + case WINDOW: + return new TileGreenhouseWindow(); case HATCH_INPUT: case HATCH_OUTPUT: return new TileGreenhouseHatch(); @@ -252,7 +399,7 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR @Override @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { - if (getGreenhouseType() == BlockGreenhouseType.GLASS || getGreenhouseType() == BlockGreenhouseType.SPRINKLER) { + if (getGreenhouseType() == BlockGreenhouseType.GLASS || getGreenhouseType() == BlockGreenhouseType.WINDOW || getGreenhouseType() == BlockGreenhouseType.WINDOW_UP || getGreenhouseType() == BlockGreenhouseType.SPRINKLER) { return BlockRenderLayer.TRANSLUCENT; } return BlockRenderLayer.CUTOUT; @@ -260,12 +407,12 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR @Override public boolean isFullCube(IBlockState state) { - return getGreenhouseType() != BlockGreenhouseType.GLASS && getGreenhouseType() != BlockGreenhouseType.SPRINKLER; + return getGreenhouseType() != BlockGreenhouseType.GLASS && getGreenhouseType() != BlockGreenhouseType.SPRINKLER && getGreenhouseType() != BlockGreenhouseType.WINDOW && getGreenhouseType() != BlockGreenhouseType.WINDOW_UP; } @Override public boolean isOpaqueCube(IBlockState state) { - return getGreenhouseType() != BlockGreenhouseType.GLASS && getGreenhouseType() != BlockGreenhouseType.SPRINKLER; + return getGreenhouseType() != BlockGreenhouseType.GLASS && getGreenhouseType() != BlockGreenhouseType.SPRINKLER && getGreenhouseType() != BlockGreenhouseType.WINDOW && getGreenhouseType() != BlockGreenhouseType.WINDOW_UP; } @Override @@ -280,6 +427,18 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR } return super.canPlaceBlockAt(worldIn, pos); } + + @Override + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + super.onBlockPlacedBy(world, pos, state, placer, stack); + TileEntity tile = world.getTileEntity(pos); + if(tile instanceof TileGreenhouseWindow){ + TileGreenhouseWindow window = (TileGreenhouseWindow) tile; + if(!window.getWorld().isRemote){ + window.setMode(window.isBlocked()); + } + } + } @Override @SideOnly(Side.CLIENT) @@ -308,7 +467,11 @@ public abstract class BlockGreenhouse extends BlockStructure implements ISpriteR public void registerModel(Item item, IModelManager manager) { if (getGreenhouseType() == BlockGreenhouseType.SPRINKLER) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forestry:greenhouse.sprinkler", "inventory")); - } else { + } else if (getGreenhouseType() == BlockGreenhouseType.WINDOW) { + ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forestry:greenhouse.window", "inventory")); + } else if (getGreenhouseType() == BlockGreenhouseType.WINDOW_UP) { + ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forestry:greenhouse.window_up", "inventory")); + } else { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation("forestry:greenhouse", "inventory")); } } diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java index 5a99d4f42..fb0d010b8 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseDoor.java @@ -46,7 +46,6 @@ import forestry.api.core.IStateMapperRegister; import forestry.core.blocks.propertys.UnlistedBlockAccess; import forestry.core.blocks.propertys.UnlistedBlockPos; import forestry.core.proxy.Proxies; -import forestry.core.tiles.TileUtil; import forestry.core.utils.CamouflageUtil; import forestry.core.utils.Translator; import forestry.greenhouse.models.GreenhouseDoorStateMapper; @@ -247,13 +246,7 @@ public class BlockGreenhouseDoor extends BlockGreenhouse implements IStateMapper state = state.withProperty(FACING, iblockstate1.getValue(FACING)).withProperty(OPEN, iblockstate1.getValue(OPEN)); } } - TileGreenhouse tile = TileUtil.getTile(worldIn, pos, TileGreenhouse.class); - boolean isCamouflaged = false; - if(tile != null){ - ItemStack camouflage = CamouflageUtil.getCamouflageBlock(worldIn, pos); - isCamouflaged = camouflage != null; - } - state = state.withProperty(CAMOUFLAGED, isCamouflaged); + state = state.withProperty(CAMOUFLAGED, CamouflageUtil.getCamouflageBlock(worldIn, pos) != null); return state; } diff --git a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseType.java b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseType.java index 68384f3ea..5b29d9c81 100644 --- a/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseType.java +++ b/src/main/java/forestry/greenhouse/blocks/BlockGreenhouseType.java @@ -35,6 +35,9 @@ public enum BlockGreenhouseType { CONTROL(true), SPRINKLER(false, true), DOOR, + CLIMATE_CONTROL(true), + WINDOW(true), + WINDOW_UP(true), BUTTERFLY_HATCH(true); public static final BlockGreenhouseType[] VALUES = values(); @@ -61,7 +64,7 @@ public enum BlockGreenhouseType { private static EnumMap sprites; private enum BlockGreenhouseSprites { - PLAIN, GLASS, GEARS("gears"), VALVE("valve"), FAN_OFF("fan.off"), FAN_ON("fan.on"), HEATER_OFF("heater.off"), HEATER_ON("heater.on"), DRYER("dryer"), CONTROL("control"), HATCH_DEFAULT("hatch"), HATCH_INPUT("hatch_input"), HATCH_OUTPUT("hatch_output"), BUTTERFLY_HATCH("butterfly_hatch"); + GEARS("gears"), VALVE("valve"), FAN_OFF("fan.off"), FAN_ON("fan.on"), HEATER_OFF("heater.off"), HEATER_ON("heater.on"), DRYER("dryer"), CONTROL("control"), HATCH_DEFAULT("hatch"), HATCH_INPUT("hatch_input"), HATCH_OUTPUT("hatch_output"), CLIMATE_CONTROL("climate_control"), BUTTERFLY_HATCH("butterfly_hatch"); public static final BlockGreenhouseSprites[] VALUES = values(); @@ -70,10 +73,6 @@ public enum BlockGreenhouseType { BlockGreenhouseSprites(String spriteName) { this.spriteName = spriteName; } - - BlockGreenhouseSprites() { - this.spriteName = null; - } } @SideOnly(Side.CLIENT) @@ -82,11 +81,9 @@ public enum BlockGreenhouseType { TextureMap map = Proxies.common.getClientInstance().getTextureMapBlocks(); for (BlockGreenhouseSprites sprite : BlockGreenhouseSprites.VALUES) { - if (sprite != BlockGreenhouseSprites.PLAIN && sprite != BlockGreenhouseSprites.GLASS) { - ResourceLocation location = new ResourceLocation(Constants.MOD_ID, "blocks/greenhouse/" + sprite.spriteName); - TextureAtlasSprite textureAtlasSprite = map.registerSprite(location); - sprites.put(sprite, textureAtlasSprite); - } + ResourceLocation location = new ResourceLocation(Constants.MOD_ID, "blocks/greenhouse/" + sprite.spriteName); + TextureAtlasSprite textureAtlasSprite = map.registerSprite(location); + sprites.put(sprite, textureAtlasSprite); } } @@ -140,6 +137,11 @@ public enum BlockGreenhouseType { return sprites.get(BlockGreenhouseSprites.HATCH_INPUT); } return null; + case CLIMATE_CONTROL: + if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) { + return null; + } + return sprites.get(BlockGreenhouseSprites.CLIMATE_CONTROL); case BUTTERFLY_HATCH: if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) { return null; diff --git a/src/main/java/forestry/greenhouse/entities/SprinklerWater.java b/src/main/java/forestry/greenhouse/entities/SprinklerWater.java new file mode 100644 index 000000000..1e80d54fc --- /dev/null +++ b/src/main/java/forestry/greenhouse/entities/SprinklerWater.java @@ -0,0 +1,57 @@ +package forestry.greenhouse.entities; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.renderer.VertexBuffer; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +@SideOnly(Side.CLIENT) +public abstract class SprinklerWater extends Particle { + + public SprinklerWater(World world, double x, double y, double z, Vec3d vector, ResourceLocation texture) { + super(world, x, y, z, 0, 0, 0); + this.particleScale = 0.3F; + this.motionX = vector.xCoord; + this.motionY = vector.yCoord; + this.motionZ = vector.zCoord; + this.particleMaxAge = 15; + this.setSize(0.2f, 0.2f); + } + + @Override + public int getFXLayer() { + return 1; + } + + @Override + public void renderParticle(VertexBuffer worldRenderer, Entity entity, float partialTicks, float f0, float f1, float f2, float f3, float f4) { + float f6 = 0; + float f7 = 1; + float f8 = 0; + float f9 = 1; + float f10 = 0.1F * this.particleScale; + float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * f0 - interpPosX); + float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * f0 - interpPosY); + float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * f0 - interpPosZ); + Minecraft.getMinecraft().renderEngine.bindTexture(FluidRegistry.WATER.getStill()); + int i = this.getBrightnessForRender(partialTicks); + int j = i >> 16 & 65535; + int k = i & 65535; + worldRenderer.pos((f11 - f1 * f10 - f4 * f10), (f12 - f2 * f10), (f13 - f3 * f10 - f6 * f10)).color(1F, 1F, 1F, 0.5F).tex(f7, f9).lightmap(j, k).endVertex(); + worldRenderer.pos((f11 - f1 * f10 + f4 * f10), (f12 + f2 * f10), (f13 - f3 * f10 + f6 * f10)).color(1F, 1F, 1F, 0.5F).tex(f7, f8).lightmap(j, k).endVertex(); + worldRenderer.pos((f11 + f1 * f10 + f4 * f10), (f12 + f2 * f10), (f13 + f3 * f10 + f6 * f10)).color(1F, 1F, 1F, 0.5F).tex(f6, f8).lightmap(j, k).endVertex(); + worldRenderer.pos((f11 + f1 * f10 - f4 * f10), (f12 - f2 * f10), (f13 + f3 * f10 - f6 * f10)).color(1F, 1F, 1F, 0.5F).tex(f6, f9).lightmap(j, k).endVertex(); + } + + // avoid calculating lighting for water, it is too much processing + @Override + public int getBrightnessForRender(float p_189214_1_) { + return 15728880; + } +} \ No newline at end of file diff --git a/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java b/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java index 85015a09e..72079d1b5 100644 --- a/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java +++ b/src/main/java/forestry/greenhouse/gui/GuiGreenhouse.java @@ -10,21 +10,55 @@ ******************************************************************************/ package forestry.greenhouse.gui; +import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; +import java.io.IOException; + +import javax.annotation.Nullable; + +import com.google.common.base.Predicate; +import com.google.common.primitives.Floats; + +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimateControlProvider; import forestry.api.core.CamouflageManager; +import forestry.api.multiblock.IGreenhouseController; import forestry.core.config.Constants; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.ledgers.ClimateLedger; import forestry.core.gui.ledgers.Ledger; import forestry.core.gui.widgets.TankWidget; +import forestry.core.gui.widgets.WidgetCamouflageSlot; +import forestry.core.network.packets.PacketUpdateClimateControl; +import forestry.core.proxy.Proxies; import forestry.core.render.TextureManager; import forestry.core.utils.Translator; -import forestry.greenhouse.gui.widgets.WidgetCamouflageSlot; +import forestry.greenhouse.multiblock.DefaultClimateControl; import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.greenhouse.tiles.TileGreenhouse; public class GuiGreenhouse extends GuiForestryTitled { + private static final Predicate numberFilter = new Predicate(){ + @Override + public boolean apply(@Nullable String text){ + if(!text.isEmpty() && text.length() > 1){ + if(!text.contains(".")){ + return false; + } + } + if(text.length() > 7){ + return false; + } + Float f = Floats.tryParse(text); + return text.isEmpty() || f != null && Floats.isFinite(f.floatValue()) && f.floatValue() >= 0.0F; + } + }; + + private GuiTextField humidityField; + private GuiTextField temperatureField; + private boolean fieldsEnabeled; + public GuiGreenhouse(EntityPlayer player, TileGreenhouse tile) { super(Constants.TEXTURE_PATH_GUI + "/greenhouse.png", new ContainerGreenhouse(player.inventory, tile), tile); @@ -38,7 +72,101 @@ public class GuiGreenhouse extends GuiForestryTitled= 2){ + f = 2.0F; + } + return f; + }catch (NumberFormatException var5){ + return 2.0F; + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY); + + if(temperatureField.getVisible()){ + textLayout.line = 20; + textLayout.drawCenteredLine(Translator.translateToLocal("for.gui.temperature"), 0, fontColor.get("gui.greenhouse.temperature.text")); + temperatureField.drawTextBox(); + } + if(humidityField.getVisible()){ + textLayout.line = 50; + textLayout.drawCenteredLine(Translator.translateToLocal("for.gui.humidity"), 0, fontColor.get("gui.greenhouse.humidity.text")); + + humidityField.drawTextBox(); + } + bindTexture(textureFile); + } @Override protected void addLedgers() { diff --git a/src/main/java/forestry/greenhouse/gui/GuiGreenhouseButterflyHatch.java b/src/main/java/forestry/greenhouse/gui/GuiGreenhouseButterflyHatch.java index 133dd9c9f..4b90716fa 100644 --- a/src/main/java/forestry/greenhouse/gui/GuiGreenhouseButterflyHatch.java +++ b/src/main/java/forestry/greenhouse/gui/GuiGreenhouseButterflyHatch.java @@ -15,7 +15,7 @@ import net.minecraft.entity.player.EntityPlayer; import forestry.core.config.Constants; import forestry.core.gui.GuiForestryTitled; import forestry.core.gui.ledgers.ClimateLedger; -import forestry.greenhouse.gui.widgets.WidgetCamouflageSlot; +import forestry.core.gui.widgets.WidgetCamouflageSlot; import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.greenhouse.tiles.TileGreenhouseButterflyHatch; diff --git a/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java b/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java index 72bd724eb..8416ac39a 100644 --- a/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java +++ b/src/main/java/forestry/greenhouse/logics/GreenhouseLogicGreenhouseEffect.java @@ -21,7 +21,6 @@ import forestry.api.greenhouse.EnumGreenhouseEventType; import forestry.api.greenhouse.IGreenhouseClimaLogic; import forestry.api.multiblock.IGreenhouseController; import forestry.api.multiblock.IMultiblockComponent; -import forestry.core.CamouflageAccess; import forestry.core.utils.CamouflageUtil; public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic implements IGreenhouseClimaLogic { @@ -76,7 +75,7 @@ public class GreenhouseLogicGreenhouseEffect extends DefaultGreenhouseLogic impl if (block.getCamouflageType() == CamouflageManager.GLASS) { if (world.canBlockSeeSky(component.getCoordinates())) { ItemStack camouflageStack = CamouflageUtil.getCamouflageBlock(world, component.getCoordinates()); - ICamouflageItemHandler handler = CamouflageAccess.getHandlerFromItem(camouflageStack, controller); + ICamouflageItemHandler handler = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflageStack); float camouflageLightTransmittance = handler.getLightTransmittance(camouflageStack, controller); if (camouflageLightTransmittance < 1 && camouflageLightTransmittance > 0) { diff --git a/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java b/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java index ad4b2e095..9c6dc5757 100644 --- a/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java +++ b/src/main/java/forestry/greenhouse/models/ModelGreenhouse.java @@ -25,11 +25,11 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.property.IExtendedBlockState; +import forestry.api.core.CamouflageManager; import forestry.api.core.ICamouflageHandler; import forestry.api.core.ICamouflageItemHandler; import forestry.api.core.ICamouflagedTile; import forestry.api.core.IModelBaker; -import forestry.core.CamouflageAccess; import forestry.core.models.ModelBlockDefault; import forestry.core.utils.CamouflageUtil; import forestry.greenhouse.blocks.BlockGreenhouse; @@ -57,7 +57,7 @@ public class ModelGreenhouse extends ModelBlockDefault { if (camouflageStack != null) { ICamouflageHandler camouflageHandler = CamouflageUtil.getCamouflageHandler(world, pos); ICamouflagedTile camouflageTile = (ICamouflagedTile) world.getTileEntity(pos); - ICamouflageItemHandler itemHandler = CamouflageAccess.getHandlerFromItem(camouflageStack, camouflageHandler); + ICamouflageItemHandler itemHandler = CamouflageManager.camouflageAccess.getHandlerFromItem(camouflageStack); if(itemHandler != null){ Pair model = itemHandler.getModel(camouflageStack, camouflageHandler, camouflageTile); diff --git a/src/main/java/forestry/greenhouse/multiblock/DefaultClimateControl.java b/src/main/java/forestry/greenhouse/multiblock/DefaultClimateControl.java new file mode 100644 index 000000000..a68066fc3 --- /dev/null +++ b/src/main/java/forestry/greenhouse/multiblock/DefaultClimateControl.java @@ -0,0 +1,30 @@ +package forestry.greenhouse.multiblock; + +import forestry.api.climate.IClimateControl; + +public class DefaultClimateControl implements IClimateControl { + + public static final DefaultClimateControl instance = new DefaultClimateControl(); + + public DefaultClimateControl() { + } + + @Override + public float getControlTemperature() { + return 2.0F; + } + + @Override + public float getControlHumidity() { + return 2.0F; + } + + @Override + public void setControlTemperature(float temperature) { + } + + @Override + public void setControlHumidity(float humidity) { + } + +} diff --git a/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java index b7c8f9d34..6f9589ac2 100644 --- a/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/FakeGreenhouseController.java @@ -18,10 +18,12 @@ import java.util.Set; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.core.climate.IClimateRegion; +import forestry.api.climate.IClimateControl; +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; import forestry.core.fluids.FakeTankManager; import forestry.core.fluids.ITankManager; @@ -115,4 +117,19 @@ public class FakeGreenhouseController extends FakeMultiblockController implement public World getWorld() { return null; } + + @Override + public boolean canWork() { + return false; + } + + @Override + public IClimateControl getClimateControl() { + return DefaultClimateControl.instance; + } + + @Override + public ButterflyHatch getButterflyHatch() { + return null; + } } diff --git a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java index e9ab98c11..d0398d38a 100644 --- a/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java +++ b/src/main/java/forestry/greenhouse/multiblock/GreenhouseController.java @@ -31,14 +31,15 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.FluidRegistry; +import forestry.api.climate.IClimateControl; +import forestry.api.climate.IClimatePosition; +import forestry.api.climate.IClimateRegion; +import forestry.api.climate.IClimateSourceProvider; import forestry.api.core.CamouflageManager; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.ForestryAPI; import forestry.api.core.ICamouflagedTile; -import forestry.api.core.climate.IClimatePosition; -import forestry.api.core.climate.IClimateRegion; -import forestry.api.core.climate.IClimateSource; import forestry.api.greenhouse.EnumGreenhouseEventType; import forestry.api.greenhouse.GreenhouseEvents.CamouflageChangeEvent; import forestry.api.greenhouse.GreenhouseEvents.CheckInternalBlockFaceEvent; @@ -49,6 +50,8 @@ 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.ClimateRoom; @@ -64,6 +67,8 @@ import forestry.core.multiblock.MultiblockValidationException; import forestry.core.multiblock.RectangularMultiblockControllerBase; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; +import forestry.core.network.packets.CamouflageSelectionType; +import forestry.core.network.packets.PacketCamouflageSelectServer; import forestry.core.proxy.Proxies; import forestry.core.tiles.ILiquidTankTile; import forestry.core.utils.CamouflageUtil; @@ -74,7 +79,6 @@ import forestry.energy.EnergyManager; import forestry.greenhouse.blocks.BlockGreenhouse; import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.inventory.InventoryGreenhouse; -import forestry.greenhouse.network.packets.PacketCamouflageUpdate; import forestry.greenhouse.tiles.TileGreenhouseSprinkler; public class GreenhouseController extends RectangularMultiblockControllerBase implements IGreenhouseControllerInternal, ILiquidTankTile { @@ -82,7 +86,10 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im private final Set internalBlocks = new HashSet<>(); private final Set listenerComponents = new HashSet<>(); private final Set activeComponents = new HashSet<>(); + private final Set climatiserComponents = new HashSet<>(); private final List logics = new ArrayList<>(); + protected ClimateControl climateControl; + protected ButterflyHatch butterflyHatch; private final TankManager tankManager; private final StandardTank resourceTank; @@ -123,34 +130,18 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im @Override public float getExactTemperature() { - int dimensionID = worldObj.provider.getDimension(); - float temperature = 0.0F; - int positions = 0; - - for(IInternalBlock internalBlock : internalBlocks){ - IClimatePosition position = region.getPositions().get(internalBlock.getPos()); - if(position != null){ - positions++; - temperature+=position.getTemperature(); - } + if(region == null){ + return 0; } - return temperature / positions; + return region.getTemperature(); } @Override public float getExactHumidity() { - int dimensionID = worldObj.provider.getDimension(); - float humidity = 0.0F; - int positions = 0; - - for(IInternalBlock internalBlock : internalBlocks){ - IClimatePosition position = region.getPositions().get(internalBlock.getPos()); - if(position != null){ - positions++; - humidity+=position.getHumidity(); - } + if(region == null){ + return 0; } - return humidity / positions; + return region.getHumidity(); } @Override @@ -212,7 +203,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im if(data.hasKey("Region")){ NBTTagCompound nbtTag = data.getCompoundTag("Region"); - region = new ClimateRoom(this, nbtTag); + if(region != null){ + region.readFromNBT(nbtTag); + }else{ + region = new ClimateRoom(this, getWallPositions(), nbtTag); + } } } @@ -299,18 +294,8 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im return; } - if (worldObj != null) { - if (worldObj.isRemote) { - Proxies.net.sendToServer(new PacketCamouflageUpdate(this, type, true)); - for (IMultiblockComponent comp : connectedParts) { - if (comp instanceof ICamouflagedTile) { - ICamouflagedTile camBlock = (ICamouflagedTile) comp; - if (camBlock.getCamouflageType() == type) { - worldObj.markBlockRangeForRenderUpdate(camBlock.getCoordinates(), camBlock.getCoordinates()); - } - } - } - } + if (worldObj != null && worldObj.isRemote) { + Proxies.net.sendToServer(new PacketCamouflageSelectServer(this, type, CamouflageSelectionType.MULTIBLOCK)); } MinecraftForge.EVENT_BUS.post(new CamouflageChangeEvent(this, null, this, type)); @@ -421,17 +406,11 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im } } ForestryAPI.climateManager.removeRegion(region); - region = new ClimateRoom(region, internalPositions, wallPositions); + region = new ClimateRoom(region, internalPositions, getWallPositions()); ForestryAPI.climateManager.addRegion(region); }else{ Map internalPositions = new HashMap<>(); - List wallPositions = new ArrayList<>(); - for(IMultiblockComponent comp : connectedParts){ - if(comp != null){ - wallPositions.add(comp.getCoordinates()); - } - } - region = new ClimateRoom(this, internalPositions, wallPositions); + region = new ClimateRoom(this, internalPositions, getWallPositions()); for(IInternalBlock block : internalBlocks){ if(block != null){ internalPositions.put(block.getPos(), new ClimatePosition(region, block.getPos())); @@ -439,6 +418,16 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im } ForestryAPI.climateManager.addRegion(region); } + + for(IClimateSourceProvider source : climatiserComponents){ + ForestryAPI.climateManager.addSource(source); + } + + for (IMultiblockComponent comp : connectedParts) { + if (comp instanceof ICamouflagedTile) { + worldObj.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates()); + } + } } @Override @@ -447,6 +436,16 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im internalBlocks.clear(); logics.clear(); + + for(IClimateSourceProvider source : climatiserComponents){ + ForestryAPI.climateManager.removeSource(source); + } + + for (IMultiblockComponent comp : connectedParts) { + if (comp instanceof ICamouflagedTile) { + worldObj.markBlockRangeForRenderUpdate(comp.getCoordinates(), comp.getCoordinates()); + } + } } @Override @@ -454,7 +453,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im if (newPart instanceof IGreenhouseComponent.Listener) { listenerComponents.add((IGreenhouseComponent.Listener) newPart); } else if (newPart instanceof IGreenhouseComponent.Climatiser) { - ForestryAPI.climateManager.addSource((IClimateSource) newPart); + climatiserComponents.add((Climatiser) newPart); } else if (newPart instanceof IGreenhouseComponent.Active) { activeComponents.add((IGreenhouseComponent.Active) newPart); } @@ -465,7 +464,8 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im if (oldPart instanceof IGreenhouseComponent.Listener) { listenerComponents.remove(oldPart); } else if (oldPart instanceof IGreenhouseComponent.Climatiser) { - ForestryAPI.climateManager.removeSource((IClimateSource) oldPart); + climatiserComponents.remove(oldPart); + ForestryAPI.climateManager.removeSource((IClimateSourceProvider) oldPart); } else if (oldPart instanceof IGreenhouseComponent.Active) { activeComponents.remove(oldPart); } @@ -477,13 +477,7 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im IGreenhouseControllerInternal internal = (IGreenhouseControllerInternal) assimilated; if(region != null){ ForestryAPI.climateManager.removeRegion(region); - List wallPositions = new ArrayList<>(); - for(IMultiblockComponent comp : connectedParts){ - if(comp != null){ - wallPositions.add(comp.getCoordinates()); - } - } - region = new ClimateRoom(region,internal.getRegion().getPositions(), wallPositions); + region = new ClimateRoom(region, internal.getRegion().getPositions(), getWallPositions()); ForestryAPI.climateManager.addRegion(region); } } @@ -640,34 +634,55 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im internalBlocks.clear(); if (isNextRoof) { - Stack blocksToCheck = new Stack<>(); - IInternalBlock internalBlock = createInternalBlock(new InternalBlock(getMinimumCoord().add(1, 1, 1))); - blocksToCheck.add(internalBlock); - while (!blocksToCheck.isEmpty()) { - IInternalBlock blockToCheck = blocksToCheck.pop(); - List newBlocksToCheck = checkInternalBlock(blockToCheck); - blocksToCheck.addAll(newBlocksToCheck); - } + checkInternalBlocks(); } if (internalBlocks.isEmpty()) { throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.space.closed")); } - int hatches = 0; + Set hatches = new HashSet<>(); + Set controls = new HashSet<>(); for (IMultiblockComponent comp : connectedParts) { - if (comp instanceof IGreenhouseComponent.ButterflyHatch) { - hatches++; + if (comp instanceof ButterflyHatch) { + hatches.add((ButterflyHatch) comp); + }else if(comp instanceof ClimateControl){ + controls.add((ClimateControl) comp); } } - if (hatches > 1) { + if (hatches.size() > 1) { throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.butterflyhatch.toomany")); } + if (controls.size() > 1) { + throw new MultiblockValidationException(Translator.translateToLocal("for.multiblock.greenhouse.error.climatecontrol.toomany")); + } + if(hatches.iterator().hasNext()){ + butterflyHatch = hatches.iterator().next(); + } + if(controls.iterator().hasNext()){ + climateControl = controls.iterator().next(); + } } @Override protected void updateClient(int tickCount) { } + + /** + * Check all internal blocks. + * @throws MultiblockValidationException + */ + private void checkInternalBlocks() throws MultiblockValidationException{ + Stack blocksToCheck = new Stack<>(); + IInternalBlock internalBlock = createInternalBlock(new InternalBlock(getMinimumCoord().add(1, 1, 1))); + blocksToCheck.add(internalBlock); + while (!blocksToCheck.isEmpty()) { + IInternalBlock blockToCheck = blocksToCheck.pop(); + List newBlocksToCheck = checkInternalBlock(blockToCheck); + blocksToCheck.addAll(newBlocksToCheck); + } + } + /** * Returns a list of more internal blocks to check. @@ -732,17 +747,17 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im return internalBlocks; } - public static ButterflyHatch getGreenhouseButterflyHatch(World world, BlockPos pos) { - if (GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos) == null) { - return null; + @Override + public IClimateControl getClimateControl() { + if(climateControl == null){ + return DefaultClimateControl.instance; } - IGreenhouseController controller = GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos); - for (IMultiblockComponent greenhouse : controller.getComponents()) { - if (greenhouse instanceof ButterflyHatch) { - return (ButterflyHatch) greenhouse; - } - } - return null; + return climateControl.getClimateControl(); + } + + @Override + public ButterflyHatch getButterflyHatch() { + return butterflyHatch; } @Override @@ -778,5 +793,26 @@ public class GreenhouseController extends RectangularMultiblockControllerBase im public Set getListenerComponents() { return listenerComponents; } + + @Override + public boolean canWork() { + boolean canWork = true; + for (IGreenhouseComponent.Listener listenerComponent : listenerComponents) { + if(canWork){ + canWork = listenerComponent.getGreenhouseListener().canWork(this, canWork); + } + } + return canWork; + } + + protected List getWallPositions(){ + List wallPositions = new ArrayList<>(); + for(IMultiblockComponent comp : connectedParts){ + if(comp != null){ + wallPositions.add(comp.getCoordinates()); + } + } + return wallPositions; + } } diff --git a/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java b/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java index 4d321d841..28fd6fe66 100644 --- a/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java +++ b/src/main/java/forestry/greenhouse/multiblock/IGreenhouseControllerInternal.java @@ -55,5 +55,9 @@ public interface IGreenhouseControllerInternal extends IGreenhouseController, IM */ void clearRegion(); + boolean canWork(); + Set getListenerComponents(); + + IGreenhouseComponent.ButterflyHatch getButterflyHatch(); } diff --git a/src/main/java/forestry/greenhouse/network/PacketRegistryGreenhouse.java b/src/main/java/forestry/greenhouse/network/PacketRegistryGreenhouse.java deleted file mode 100644 index facddea69..000000000 --- a/src/main/java/forestry/greenhouse/network/PacketRegistryGreenhouse.java +++ /dev/null @@ -1,21 +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.network; - -import forestry.core.network.PacketRegistry; -import forestry.greenhouse.network.packets.PacketCamouflageUpdate; - -public class PacketRegistryGreenhouse extends PacketRegistry { - @Override - public void registerPackets() { - registerServerPacket(new PacketCamouflageUpdate()); - } -} diff --git a/src/main/java/forestry/greenhouse/network/packets/PacketCamouflageUpdate.java b/src/main/java/forestry/greenhouse/network/packets/PacketCamouflageUpdate.java deleted file mode 100644 index fea95fe6d..000000000 --- a/src/main/java/forestry/greenhouse/network/packets/PacketCamouflageUpdate.java +++ /dev/null @@ -1,91 +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.network.packets; - -import java.io.IOException; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import forestry.api.core.ICamouflageHandler; -import forestry.api.multiblock.IMultiblockComponent; -import forestry.api.multiblock.IMultiblockController; -import forestry.core.network.DataInputStreamForestry; -import forestry.core.network.DataOutputStreamForestry; -import forestry.core.network.IForestryPacketServer; -import forestry.core.network.PacketIdServer; -import forestry.core.network.packets.PacketCoordinates; - -public class PacketCamouflageUpdate extends PacketCoordinates implements IForestryPacketServer{ - - private ItemStack camouflageStack; - private String type; - private boolean isMultiblock; - - public PacketCamouflageUpdate() { - } - - public PacketCamouflageUpdate(ICamouflageHandler tile, String type, boolean isMultiblock) { - super(tile.getCoordinates()); - this.camouflageStack = tile.getCamouflageBlock(type); - this.isMultiblock = isMultiblock; - this.type = type; - } - - public PacketCamouflageUpdate(ICamouflageHandler tile, String type) { - super(tile.getCoordinates()); - this.camouflageStack = tile.getCamouflageBlock(type); - this.isMultiblock = false; - this.type = type; - } - - @Override - public PacketIdServer getPacketId() { - return PacketIdServer.TILE_FORESTRY_CAMOUFLAGE; - } - - @Override - protected void writeData(DataOutputStreamForestry data) throws IOException { - super.writeData(data); - data.writeBoolean(isMultiblock); - data.writeUTF(type); - data.writeItemStack(camouflageStack); - } - - @Override - public void readData(DataInputStreamForestry data) throws IOException { - super.readData(data); - isMultiblock = data.readBoolean(); - type = data.readUTF(); - camouflageStack = data.readItemStack(); - } - - @Override - public void onPacketData(DataInputStreamForestry data, EntityPlayerMP player) { - TileEntity tile = getTarget(player.worldObj); - ICamouflageHandler handler = null; - - if (isMultiblock && tile instanceof IMultiblockComponent) { - IMultiblockController controller = ((IMultiblockComponent) tile).getMultiblockLogic().getController(); - - if (controller instanceof ICamouflageHandler) { - handler = (ICamouflageHandler) controller; - } - - } else if (tile instanceof ICamouflageHandler) { - handler = (ICamouflageHandler) tile; - } - - if (handler != null) { - handler.setCamouflageBlock(type, camouflageStack); - } - } -} diff --git a/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java b/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java index a0673c808..b0c8d9506 100644 --- a/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java +++ b/src/main/java/forestry/greenhouse/proxy/ProxyGreenhouseClient.java @@ -40,6 +40,8 @@ public class ProxyGreenhouseClient extends ProxyGreenhouse { if(!ForestryAPI.enabledPlugins.contains(ForestryPluginUids.LEPIDOPTEROLOGY)){ continue; } + }else if(greenhouseType == BlockGreenhouseType.WINDOW || greenhouseType == BlockGreenhouseType.WINDOW_UP){ + continue; } Block greenhouseBlock = PluginGreenhouse.blocks.getGreenhouseBlock(greenhouseType); diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java index a80036e06..24093add6 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouse.java @@ -39,6 +39,8 @@ import forestry.core.multiblock.MultiblockTileEntityForestry; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamableGui; +import forestry.core.network.packets.CamouflageSelectionType; +import forestry.core.network.packets.PacketCamouflageSelectServer; import forestry.core.proxy.Proxies; import forestry.core.tiles.ITitled; import forestry.core.utils.ItemStackUtil; @@ -48,7 +50,6 @@ import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.gui.ContainerGreenhouse; import forestry.greenhouse.gui.GuiGreenhouse; import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse; -import forestry.greenhouse.network.packets.PacketCamouflageUpdate; public abstract class TileGreenhouse extends MultiblockTileEntityForestry implements IGreenhouseComponent, IHintSource, IStreamableGui, IErrorLogicSource, IOwnedTile, ITitled, ICamouflageHandler, ICamouflagedTile { @@ -106,11 +107,8 @@ public abstract class TileGreenhouse extends MultiblockTileEntityForestry= 2.0F){ - if(position.getTemperature() > 2.0F){ - position.setTemperature(2.0F); - } - continue; - } - }else{ - if(position.getTemperature() <= 0.0F){ - if(position.getTemperature() < 0.0F){ - position.setTemperature(0.0F); - } - continue; - } - } - }else{ - if(definition.isPositiv()){ - if(position.getHumidity() >= 2.0F){ - if(position.getHumidity() > 2.0F){ - position.setHumidity(2.0F); - } - continue; - } - }else{ - if(position.getHumidity() <= 0.0F){ - if(position.getHumidity() < 0.0F){ - position.setHumidity(0.0F); - } - continue; - } - } - } - - double distance = pos.distanceSq(this.pos); - int maxDistance = definition.getClimitiseRange(); - if(distance <= maxDistance){ - if (definition.getType() == ClimitiserType.TEMPERATURE) { - position.addTemperature((definition.isPositiv() ? +1 : -1) * ((distance == 0) ? definition.getChange() : (float) (definition.getChange() / distance))); - }else{ - position.addHumidity((definition.isPositiv() ? +1 : -1) * ((distance == 0) ? definition.getChange() : (float) (definition.getChange() / distance))); - } - } - } - } - - // TODO: Add config entry for a time modifier and a energy modifier. - // one tick of work for every 10 RF - workingTime += ENERGY_PER_OPERATION / 25; - } - - if (workingTime > 0) { - workingTime--; - } - - setActive(workingTime > 0); - }else if(isActive()){ - setActive(false); - } - } - - /* LOADING & SAVING */ - @Override - public void readFromNBT(NBTTagCompound nbttagcompound) { - super.readFromNBT(nbttagcompound); - workingTime = nbttagcompound.getInteger("Heating"); - setActive(workingTime > 0); - } - - @Nonnull - @Override - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound = super.writeToNBT(nbttagcompound); - nbttagcompound.setInteger("Heating", workingTime); - return nbttagcompound; + public BlockPos getMaxPos() { + return maxPos; } /* Network */ @@ -204,29 +109,29 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat leftwards = null; int facesMatching = 0; - if (maxCoord.getX() == getPos().getX() || minCoord.getX() == getPos().getX()) { + if (maxCoord.getX() == getCoordinates().getX() || minCoord.getX() == getCoordinates().getX()) { facesMatching++; } - if (maxCoord.getY() == getPos().getY() || minCoord.getY() == getPos().getY()) { + if (maxCoord.getY() == getCoordinates().getY() || minCoord.getY() == getCoordinates().getY()) { facesMatching++; } - if (maxCoord.getZ() == getPos().getZ() || minCoord.getZ() == getPos().getZ()) { + if (maxCoord.getZ() == getCoordinates().getZ() || minCoord.getZ() == getCoordinates().getZ()) { facesMatching++; } if (facesMatching == 1) { - if (maxCoord.getX() == getPos().getX()) { + if (maxCoord.getX() == getCoordinates().getX()) { inwards = EnumFacing.WEST; leftwards = EnumFacing.SOUTH; - } else if (minCoord.getX() == getPos().getX()) { + } else if (minCoord.getX() == getCoordinates().getX()) { inwards = EnumFacing.EAST; leftwards = EnumFacing.NORTH; - } else if (maxCoord.getZ() == getPos().getZ()) { + } else if (maxCoord.getZ() == getCoordinates().getZ()) { inwards = EnumFacing.NORTH; leftwards = EnumFacing.WEST; - } else if (minCoord.getZ() == getPos().getZ()) { + } else if (minCoord.getZ() == getCoordinates().getZ()) { inwards = EnumFacing.SOUTH; leftwards = EnumFacing.EAST; - } else if (maxCoord.getY() == getPos().getY()) { + } else if (maxCoord.getY() == getCoordinates().getY()) { inwards = EnumFacing.DOWN; } else { inwards = EnumFacing.UP; @@ -236,9 +141,30 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat } } - public IClimitiserDefinition getDefinition() { + @Override + public IClimatiserDefinition getDefinition() { return definition; } + + @Override + public IClimateSource getClimateSource() { + return source; + } + + public boolean canWork(){ + IMultiblockLogic logic = getMultiblockLogic(); + if(logic == null || !logic.isConnected() || getMultiblockLogic().getController().getEnergyManager() == null){ + return false; + } + return getMultiblockLogic().getController().getEnergyManager().consumeEnergyToDoWork(WORK_CYCLES, ENERGY_PER_OPERATION); + } + + public Iterable getPositionsInRange(){ + if(maxPos == null || minPos == null){ + return null; + } + return BlockPos.getAllInBox(maxPos, minPos); + } @Override public void setActive(boolean active) { @@ -250,7 +176,7 @@ public class TileGreenhouseClimatiser extends TileGreenhouse implements IActivat if (worldObj != null) { if (worldObj.isRemote) { - worldObj.markBlockRangeForRenderUpdate(getPos(), getPos()); + worldObj.markBlockRangeForRenderUpdate(getCoordinates(), getCoordinates()); } else { Proxies.net.sendNetworkPacket(new PacketActiveUpdate(this), worldObj); } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseDryer.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseDryer.java index 51e6f343f..e4a4739a1 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseDryer.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseDryer.java @@ -10,35 +10,17 @@ ******************************************************************************/ package forestry.greenhouse.tiles; +import forestry.api.climate.EnumClimatiserModes; +import forestry.api.climate.EnumClimatiserTypes; +import forestry.api.climate.IClimatiserDefinition; +import forestry.core.climate.ClimatiserDefinition; + public class TileGreenhouseDryer extends TileGreenhouseClimatiser { - private static final DryerDefinition definition = new DryerDefinition(); + private static final IClimatiserDefinition DEFINITION = new ClimatiserDefinition(0.015F, EnumClimatiserModes.NEGATIVE, 5D, EnumClimatiserTypes.HUMIDITY); public TileGreenhouseDryer() { - super(definition); - } - - private static class DryerDefinition implements IClimitiserDefinition { - - @Override - public float getChange() { - return 0.015F; - } - - @Override - public boolean isPositiv() { - return false; - } - - @Override - public int getClimitiseRange() { - return 5; - } - - @Override - public ClimitiserType getType() { - return ClimitiserType.HUMIDITY; - } + super(DEFINITION); } } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseFan.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseFan.java index 0de35fbca..b442eb722 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseFan.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseFan.java @@ -10,36 +10,17 @@ ******************************************************************************/ package forestry.greenhouse.tiles; +import forestry.api.climate.EnumClimatiserModes; +import forestry.api.climate.EnumClimatiserTypes; +import forestry.api.climate.IClimatiserDefinition; +import forestry.core.climate.ClimatiserDefinition; public class TileGreenhouseFan extends TileGreenhouseClimatiser { - private static final FanDefinition definition = new FanDefinition(); + private static final IClimatiserDefinition DEFINITION = new ClimatiserDefinition(0.015F, EnumClimatiserModes.NEGATIVE, 5D, EnumClimatiserTypes.TEMPERATURE); public TileGreenhouseFan() { - super(definition); - } - - private static class FanDefinition implements IClimitiserDefinition { - - @Override - public float getChange() { - return 0.015F; - } - - @Override - public int getClimitiseRange() { - return 5; - } - - @Override - public ClimitiserType getType() { - return ClimitiserType.TEMPERATURE; - } - - @Override - public boolean isPositiv() { - return false; - } + super(DEFINITION); } } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseHatch.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseHatch.java index 223062e68..6003c2d6d 100644 --- a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseHatch.java +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseHatch.java @@ -45,6 +45,8 @@ import forestry.core.gui.IHintSource; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamableGui; +import forestry.core.network.packets.CamouflageSelectionType; +import forestry.core.network.packets.PacketCamouflageSelectServer; import forestry.core.proxy.Proxies; import forestry.core.tiles.TileUtil; import forestry.core.utils.ItemStackUtil; @@ -52,8 +54,6 @@ import forestry.core.utils.PlayerUtil; import forestry.greenhouse.blocks.BlockGreenhouse; import forestry.greenhouse.blocks.BlockGreenhouseType; import forestry.greenhouse.multiblock.MultiblockLogicGreenhouse; -import forestry.greenhouse.network.packets.PacketCamouflageUpdate; - import cofh.api.energy.IEnergyConnection; import cofh.api.energy.IEnergyHandler; import cofh.api.energy.IEnergyProvider; @@ -144,11 +144,8 @@ public class TileGreenhouseHatch extends MultiblockTileEntityBase= 2.0F){ - if(position.getHumidity() > 2.0F){ - position.setHumidity(2.0F); - } - continue; - } - - double distance = pos.distanceSq(pos); - int maxDistance = definition.getClimitiseRange(); - if(distance <= maxDistance){ - position.setHumidity((float) (position.getHumidity() + ((distance == 0) ? definition.getChange() : (definition.getChange() / distance)))); - } - } - } - - workingTime += WATER_PER_OPERATION / 10; - } - - if (workingTime > 0) { - workingTime--; - } - - setActive(workingTime > 0); - }else if(isActive()){ - setActive(false); + public boolean canWork() { + IMultiblockLogic logic = getMultiblockLogic(); + if(logic == null || !logic.isConnected() || getMultiblockLogic().getController().getTankManager() == null || getMultiblockLogic().getController().getTankManager().getTank(0) == null){ + return false; } + return consumeWaterToDoWork(WORK_CYCLES, WATER_PER_OPERATION, getMultiblockLogic().getController().getTankManager().getTank(0)); } @Override @@ -110,14 +75,14 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser { } } - public boolean consumeWaterToDoWork(int ticksPerWorkCycle, int fluidPerWorkCycle, StandardTank tank) { + public boolean consumeWaterToDoWork(int ticksPerWorkCycle, int fluidPerWorkCycle, IFluidTank tank) { int fluidPerCycle = (int) Math.ceil(fluidPerWorkCycle / (float) ticksPerWorkCycle); if (tank.getFluid() == null || tank.getFluid().amount < fluidPerCycle) { return false; } - - tank.drain(fluidPerCycle, true); - return true; + FluidStack drained = tank.drain(fluidPerCycle, true); + + return drained != null && drained.amount > 0; } @Override @@ -138,27 +103,4 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser { return super.getCapability(capability, side); } - private static class SprinklerDefinition implements IClimitiserDefinition { - - @Override - public ClimitiserType getType() { - return ClimitiserType.HUMIDITY; - } - - @Override - public float getChange() { - return 0.005F; - } - - @Override - public int getClimitiseRange() { - return 9; - } - - @Override - public boolean isPositiv() { - return true; - } - } - } diff --git a/src/main/java/forestry/greenhouse/tiles/TileGreenhouseWindow.java b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseWindow.java new file mode 100644 index 000000000..57984ef82 --- /dev/null +++ b/src/main/java/forestry/greenhouse/tiles/TileGreenhouseWindow.java @@ -0,0 +1,107 @@ +/******************************************************************************* + * 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.tiles; + +import forestry.api.climate.EnumClimatiserModes; +import forestry.api.climate.EnumClimatiserTypes; +import forestry.core.climate.ClimatiserDefinition; +import forestry.greenhouse.GreenhouseClimateWindow; +import forestry.greenhouse.PluginGreenhouse; +import forestry.greenhouse.blocks.BlockGreenhouse; +import forestry.greenhouse.blocks.BlockGreenhouseType; +import net.minecraft.block.state.IBlockState; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; + +public class TileGreenhouseWindow extends TileGreenhouseClimatiser{ + + private WindowMode mode; + + public TileGreenhouseWindow() { + super(new ClimatiserDefinition(0.001F, EnumClimatiserModes.NONE, 5D, EnumClimatiserTypes.NONE), new GreenhouseClimateWindow(20)); + } + + public void onNeighborBlockChange() { + WindowMode otherMode = isBlocked(); + if(getMode() != WindowMode.PLAYER && getMode() != WindowMode.CONTROL && otherMode != getMode()){ + setMode(otherMode); + } + } + + public WindowMode isBlocked(){ + if(worldObj == null){ + return WindowMode.BLOCK; + } + IBlockState state = worldObj.getBlockState(pos); + if(state == null){ + return WindowMode.BLOCK; + } + BlockPos blockedPos; + if(state.getBlock() == PluginGreenhouse.blocks.getGreenhouseBlock(BlockGreenhouseType.WINDOW_UP)){ + blockedPos = getCoordinates().offset(EnumFacing.UP); + }else{ + blockedPos = getCoordinates().offset(state.getValue(BlockGreenhouse.FACING)); + } + return worldObj.isAirBlock(blockedPos) ? WindowMode.OPEN : WindowMode.BLOCK; + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound data) { + if(mode != null){ + data.setShort("mode", (short) mode.ordinal()); + } + return super.writeToNBT(data); + } + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + if(data.hasKey("mode")){ + setMode(WindowMode.values()[data.getShort("mode")]); + } + } + + @Override + protected void decodeDescriptionPacket(NBTTagCompound packetData) { + super.decodeDescriptionPacket(packetData); + if(packetData.hasKey("mode")){ + setMode(WindowMode.values()[packetData.getShort("mode")]); + } + } + + @Override + protected void encodeDescriptionPacket(NBTTagCompound packetData) { + if(mode != null){ + packetData.setShort("mode", (short) mode.ordinal()); + } + super.encodeDescriptionPacket(packetData); + } + + @Override + public boolean canWork() { + return true; + } + + public void setMode(WindowMode mode){ + this.mode = mode; + setActive(mode == WindowMode.OPEN); + } + + public WindowMode getMode(){ + return mode; + } + + public static enum WindowMode{ + PLAYER, BLOCK, CONTROL, OPEN + } + +} diff --git a/src/main/java/forestry/lepidopterology/render/ModelButterflyItem.java b/src/main/java/forestry/lepidopterology/render/ModelButterflyItem.java index 5402acf05..8a068ee0c 100644 --- a/src/main/java/forestry/lepidopterology/render/ModelButterflyItem.java +++ b/src/main/java/forestry/lepidopterology/render/ModelButterflyItem.java @@ -49,7 +49,7 @@ public class ModelButterflyItem extends BlankModel { private IBakedModel bakeModel(IButterfly butterfly) { ImmutableMap.Builder textures = ImmutableMap.builder(); - textures.put("butterfly", butterfly.getGenome().getSecondary().getItemTexture()); + textures.put("butterfly", butterfly.getGenome().getPrimary().getItemTexture()); IModel retexturedModel = ModelProcessingHelper.retexture(modelButterfly, textures.build()); return new TRSRBakedModel(retexturedModel.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, textureGetter), -0.03125F, 0.5F, -0.03125F, butterfly.getSize() * 1.5F); } diff --git a/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java b/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java index f2cd6d8c4..062ff51a2 100644 --- a/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java +++ b/src/main/java/forestry/lepidopterology/tiles/TileCocoon.java @@ -28,12 +28,16 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.genetics.IAllele; +import forestry.api.greenhouse.GreenhouseManager; import forestry.api.lepidopterology.ButterflyManager; import forestry.api.lepidopterology.IButterfly; import forestry.api.lepidopterology.IButterflyCocoon; import forestry.api.lepidopterology.IButterflyGenome; import forestry.api.lepidopterology.IButterflyNursery; import forestry.api.multiblock.IGreenhouseComponent; +import forestry.api.multiblock.IGreenhouseController; +import forestry.api.multiblock.IMultiblockComponent; +import forestry.api.multiblock.IGreenhouseComponent.ButterflyHatch; import forestry.core.network.DataInputStreamForestry; import forestry.core.network.DataOutputStreamForestry; import forestry.core.network.IStreamable; @@ -42,7 +46,7 @@ import forestry.core.proxy.Proxies; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.core.utils.NBTUtilForestry; -import forestry.greenhouse.multiblock.GreenhouseController; +import forestry.greenhouse.multiblock.IGreenhouseControllerInternal; import forestry.lepidopterology.genetics.Butterfly; import forestry.lepidopterology.genetics.ButterflyDefinition; @@ -190,7 +194,7 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnedTile, I age++; maturationTime = 0; } else if (caterpillar.canTakeFlight(worldObj, getPos().getX(), getPos().getY(), getPos().getZ())) { - IGreenhouseComponent.ButterflyHatch hatch = GreenhouseController.getGreenhouseButterflyHatch(worldObj, pos); + IGreenhouseComponent.ButterflyHatch hatch = getButterflyHatch(worldObj, pos); ItemStack[] cocoonDrops; if (hatch != null) { cocoonDrops = hatch.addCocoonLoot(this); @@ -206,6 +210,22 @@ public class TileCocoon extends TileEntity implements IStreamable, IOwnedTile, I } } + public ButterflyHatch getButterflyHatch(World world, BlockPos pos) { + if (GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos) == null) { + return null; + } + IGreenhouseController controller = GreenhouseManager.greenhouseHelper.getGreenhouseController(world, pos); + if(controller instanceof IGreenhouseControllerInternal){ + return ((IGreenhouseControllerInternal) controller).getButterflyHatch(); + } + for (IMultiblockComponent greenhouse : controller.getComponents()) { + if (greenhouse instanceof ButterflyHatch) { + return (ButterflyHatch) greenhouse; + } + } + return null; + } + private static void attemptButterflySpawn(World world, IButterfly butterfly, BlockPos pos) { if (ButterflyManager.butterflyRoot.spawnButterflyInWorld(world, butterfly.copy(), pos.getX(), pos.getY() + 0.1f, pos.getZ()) != null) { Log.trace("A caterpillar '%s' hatched at %s/%s/%s.", butterfly.getDisplayName(), pos.getX(), pos.getY(), pos.getZ()); diff --git a/src/main/java/forestry/storage/compat/StorageJeiPlugin.java b/src/main/java/forestry/storage/compat/StorageJeiPlugin.java index 972a20907..7884371a5 100644 --- a/src/main/java/forestry/storage/compat/StorageJeiPlugin.java +++ b/src/main/java/forestry/storage/compat/StorageJeiPlugin.java @@ -3,9 +3,6 @@ package forestry.storage.compat; import javax.annotation.Nonnull; import forestry.core.utils.JeiUtil; -import forestry.mail.PluginMail; -import forestry.mail.blocks.BlockRegistryMail; -import forestry.mail.items.ItemRegistryMail; import forestry.storage.PluginStorage; import forestry.storage.items.ItemRegistryStorage; import mezz.jei.api.BlankModPlugin; diff --git a/src/main/resources/assets/forestry/blockstates/greenhouse.window.json b/src/main/resources/assets/forestry/blockstates/greenhouse.window.json new file mode 100644 index 000000000..186f2d176 --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/greenhouse.window.json @@ -0,0 +1,33 @@ +{ + "forge_marker": 1, + "defaults": { + "textures": { + } + }, + "variants": { + "state": { + "on": { + "model": "forestry:greenhouse.window_open" + }, + "off": { + "model": "forestry:greenhouse.window_closed" + } + }, + "facing":{ + "east": { + "y": -90 + }, + "south": { + }, + "west": { + "y": 90 + }, + "north": { + "y": 180 + }, + "up": { + "x": 90 + } + } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/greenhouse.window_up.json b/src/main/resources/assets/forestry/blockstates/greenhouse.window_up.json new file mode 100644 index 000000000..07a09ee28 --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/greenhouse.window_up.json @@ -0,0 +1,33 @@ +{ + "forge_marker": 1, + "defaults": { + "textures": { + } + }, + "variants": { + "state": { + "on": { + "model": "forestry:greenhouse.window_up_open" + }, + "off": { + "model": "forestry:greenhouse.window_up_closed" + } + }, + "facing":{ + "east": { + "y": -90 + }, + "south": { + }, + "west": { + "y": 90 + }, + "north": { + "y": 180 + }, + "up": { + "x": 90 + } + } + } +} diff --git a/src/main/resources/assets/forestry/models/block/greenhouse.window_closed.json b/src/main/resources/assets/forestry/models/block/greenhouse.window_closed.json new file mode 100644 index 000000000..f8db8265a --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/greenhouse.window_closed.json @@ -0,0 +1,109 @@ +{ +"textures": { + "texture": "blocks/glass_green" +}, +"elements": [ +{ + "from": [ 3, 0, 0 ], + "to": [ 13, 3, 15 ], + "faces": { + "down": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "up": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 3, 13, 13, 16 ], "texture": "#texture" }, + "south": { "uv": [ 3, 13, 13, 16 ], "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 3, 13, 0 ], + "to": [ 13, 16, 15 ], + "faces": { + "down": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "up": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 3, 0, 13, 3 ], "texture": "#texture" }, + "south": { "uv": [ 3, 0, 13, 3 ], "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 3, 0 ], + "to": [ 3, 13, 15 ], + "faces": { + "north": { "uv": [ 13, 3, 16, 13 ], "texture": "#texture" }, + "south": { "uv": [ 0, 3, 3, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" } + } +}, +{ + "from": [ 13, 3, 0 ], + "to": [ 16, 13, 15 ], + "faces": { + "north": { "uv": [ 0, 3, 3, 13 ], "texture": "#texture" }, + "south": { "uv": [ 13, 3, 16, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 13, 0 ], + "to": [ 3, 16, 15 ], + "faces": { + "up": { "uv": [ 0, 0, 16, 3 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 13, 0, 16, 3 ], "texture": "#texture" }, + "south": { "uv": [ 0, 0, 3, 3 ], "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 0 ], + "to": [ 3, 3, 15 ], + "faces": { + "down": { "uv": [ 16, 3, 0, 0 ], "rotation": 90, "texture": "#texture" }, + "north": { "uv": [ 13, 13, 16, 16 ], "texture": "#texture" }, + "south": { "uv": [ 0, 13, 3, 16 ], "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 13, 13, 0 ], + "to": [ 16, 16, 15 ], + "faces": { + "up": { "uv": [ 0, 13, 16, 16 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 0, 0, 3, 3 ], "texture": "#texture" }, + "south": { "uv": [ 13, 0, 16, 3 ], "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 0 ], + "to": [ 16, 3, 15 ], + "faces": { + "down": { "uv": [ 16, 16, 0, 13 ], "rotation": 90, "texture": "#texture" }, + "north": { "uv": [ 0, 13, 3, 16 ], "texture": "#texture" }, + "south": { "uv": [ 13, 13, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 15 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 16, 16, 0, 15 ], "texture": "#texture" }, + "up": { "uv": [ 0, 15, 16, 16 ], "texture": "#texture" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "west": { "uv": [ 15, 0, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 0, 1, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 3, 3, 15 ], + "to": [ 13, 13, 15.0625 ], + "faces": { + "north": { "uv": [ 3, 3, 13, 13 ], "texture": "#texture" } + } +} +] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/greenhouse.window_open.json b/src/main/resources/assets/forestry/models/block/greenhouse.window_open.json new file mode 100644 index 000000000..e045829e2 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/greenhouse.window_open.json @@ -0,0 +1,118 @@ +{ +"textures": { + "texture": "blocks/glass_green", + "log_oak": "blocks/log_oak" +}, +"elements": [ +{ + "from": [ 3, 0, 0 ], + "to": [ 13, 3, 15 ], + "faces": { + "down": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "up": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 3, 13, 13, 16 ], "texture": "#texture" }, + "south": { "uv": [ 3, 13, 13, 16 ], "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 3, 13, 0 ], + "to": [ 13, 16, 15 ], + "faces": { + "down": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "up": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 3, 0, 13, 3 ], "texture": "#texture" }, + "south": { "uv": [ 3, 0, 13, 3 ], "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 3, 0 ], + "to": [ 3, 13, 15 ], + "faces": { + "north": { "uv": [ 13, 3, 16, 13 ], "texture": "#texture" }, + "south": { "uv": [ 0, 3, 3, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" } + } +}, +{ + "from": [ 13, 3, 0 ], + "to": [ 16, 13, 15 ], + "faces": { + "north": { "uv": [ 0, 3, 3, 13 ], "texture": "#texture" }, + "south": { "uv": [ 13, 3, 16, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 13, 0 ], + "to": [ 3, 16, 15 ], + "faces": { + "up": { "uv": [ 0, 0, 16, 3 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 13, 0, 16, 3 ], "texture": "#texture" }, + "south": { "uv": [ 0, 0, 3, 3 ], "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 0 ], + "to": [ 3, 3, 15 ], + "faces": { + "down": { "uv": [ 16, 3, 0, 0 ], "rotation": 90, "texture": "#texture" }, + "north": { "uv": [ 13, 13, 16, 16 ], "texture": "#texture" }, + "south": { "uv": [ 0, 13, 3, 16 ], "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 13, 13, 0 ], + "to": [ 16, 16, 15 ], + "faces": { + "up": { "uv": [ 0, 13, 16, 16 ], "rotation": 270, "texture": "#texture" }, + "north": { "uv": [ 0, 0, 3, 3 ], "texture": "#texture" }, + "south": { "uv": [ 13, 0, 16, 3 ], "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 0 ], + "to": [ 16, 3, 15 ], + "faces": { + "down": { "uv": [ 16, 16, 0, 13 ], "rotation": 90, "texture": "#texture" }, + "north": { "uv": [ 0, 13, 3, 16 ], "texture": "#texture" }, + "south": { "uv": [ 13, 13, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 15 ], + "to": [ 16, 16, 16 ], + "rotation": { "origin": [ 0, 16, 15 ], "axis": "x", "angle": -45 }, + "faces": { + "down": { "uv": [ 16, 16, 0, 15 ], "texture": "#texture" }, + "up": { "uv": [ 0, 15, 16, 16 ], "texture": "#texture" }, + "north": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "south": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "west": { "uv": [ 15, 0, 16, 16 ], "texture": "#texture" }, + "east": { "uv": [ 0, 0, 1, 16 ], "texture": "#texture" } + } +}, +{ + "from": [ 7.5, 0, 21.5 ], + "to": [ 8.5, 9.5, 22.5 ], + "rotation": { "origin": [ 7.5, 9.5, 21.5 ], "axis": "x", "angle": 45 }, + "faces": { + "down": { "uv": [ 16, 16, 16, 15 ], "texture": "#log_oak" }, + "up": { "uv": [ 0, 15, 0, 16 ], "texture": "#log_oak" }, + "north": { "uv": [ 16, 3, 16, 16 ], "texture": "#log_oak" }, + "south": { "uv": [ 0, 3, 0, 16 ], "texture": "#log_oak" }, + "west": { "uv": [ 15, 3, 16, 16 ], "texture": "#log_oak" }, + "east": { "uv": [ 0, 3, 1, 16 ], "texture": "#log_oak" } + } +} +] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/greenhouse.window_up_closed.json b/src/main/resources/assets/forestry/models/block/greenhouse.window_up_closed.json new file mode 100644 index 000000000..f38ab1231 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/greenhouse.window_up_closed.json @@ -0,0 +1,109 @@ +{ +"textures": { + "texture": "blocks/glass_green" +}, +"elements": [ +{ + "from": [ 3, 0, 13 ], + "to": [ 13, 15, 16 ], + "faces": { + "down": { "uv": [ 3, 13, 13, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 3, 13, 13, 16 ], "texture": "#texture" }, + "north": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" }, + "south": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 3, 0, 0 ], + "to": [ 13, 15, 3 ], + "faces": { + "down": { "uv": [ 3, 0, 13, 3 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 3, 0, 13, 3 ], "texture": "#texture" }, + "north": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" }, + "south": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 3 ], + "to": [ 3, 15, 13 ], + "faces": { + "down": { "uv": [ 13, 3, 16, 13 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 3, 3, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 3 ], + "to": [ 16, 15, 13 ], + "faces": { + "down": { "uv": [ 0, 3, 3, 13 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 13, 3, 16, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 0 ], + "to": [ 3, 15, 3 ], + "faces": { + "down": { "uv": [ 13, 0, 16, 3 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 0, 3, 3 ], "texture": "#texture" }, + "north": { "uv": [ 0, 0, 16, 3 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "rotation": 270, "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 13 ], + "to": [ 3, 15, 16 ], + "faces": { + "down": { "uv": [ 13, 13, 16, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 13, 3, 16 ], "texture": "#texture" }, + "south": { "uv": [ 16, 3, 0, 0 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "rotation": 270, "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 0 ], + "to": [ 16, 15, 3 ], + "faces": { + "down": { "uv": [ 0, 0, 3, 3 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 13, 0, 16, 3 ], "texture": "#texture" }, + "north": { "uv": [ 0, 13, 16, 16 ], "rotation": 90, "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 13 ], + "to": [ 16, 15, 16 ], + "faces": { + "down": { "uv": [ 0, 13, 3, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 13, 13, 16, 16 ], "texture": "#texture" }, + "south": { "uv": [ 16, 16, 0, 13 ], "rotation": 90, "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 0, 15, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "north": { "uv": [ 0, 15, 16, 16 ], "rotation": 180, "texture": "#texture" }, + "south": { "uv": [ 16, 16, 0, 15 ], "texture": "#texture" }, + "west": { "uv": [ 15, 0, 16, 16 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 0, 1, 16 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 3, 14.9375, 3 ], + "to": [ 13, 15, 13 ], + "faces": { + "down": { "uv": [ 3, 3, 13, 13 ], "rotation": 180, "texture": "#texture" } + } +} +] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/greenhouse.window_up_open.json b/src/main/resources/assets/forestry/models/block/greenhouse.window_up_open.json new file mode 100644 index 000000000..18c33eb08 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/greenhouse.window_up_open.json @@ -0,0 +1,118 @@ +{ +"textures": { + "texture": "blocks/glass_green", + "log_oak": "blocks/log_oak" +}, +"elements": [ +{ + "from": [ 3, 0, 13 ], + "to": [ 13, 15, 16 ], + "faces": { + "down": { "uv": [ 3, 13, 13, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 3, 13, 13, 16 ], "texture": "#texture" }, + "north": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" }, + "south": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 3, 0, 0 ], + "to": [ 13, 15, 3 ], + "faces": { + "down": { "uv": [ 3, 0, 13, 3 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 3, 0, 13, 3 ], "texture": "#texture" }, + "north": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" }, + "south": { "uv": [ 16, 13, 0, 3 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 3 ], + "to": [ 3, 15, 13 ], + "faces": { + "down": { "uv": [ 13, 3, 16, 13 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 3, 3, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 3 ], + "to": [ 16, 15, 13 ], + "faces": { + "down": { "uv": [ 0, 3, 3, 13 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 13, 3, 16, 13 ], "texture": "#texture" }, + "west": { "uv": [ 0, 3, 16, 13 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 3, 16, 13 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 0 ], + "to": [ 3, 15, 3 ], + "faces": { + "down": { "uv": [ 13, 0, 16, 3 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 0, 3, 3 ], "texture": "#texture" }, + "north": { "uv": [ 0, 0, 16, 3 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 0, 16, 3 ], "rotation": 270, "texture": "#texture" } + } +}, +{ + "from": [ 0, 0, 13 ], + "to": [ 3, 15, 16 ], + "faces": { + "down": { "uv": [ 13, 13, 16, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 13, 3, 16 ], "texture": "#texture" }, + "south": { "uv": [ 16, 3, 0, 0 ], "rotation": 90, "texture": "#texture" }, + "west": { "uv": [ 0, 13, 16, 16 ], "rotation": 270, "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 0 ], + "to": [ 16, 15, 3 ], + "faces": { + "down": { "uv": [ 0, 0, 3, 3 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 13, 0, 16, 3 ], "texture": "#texture" }, + "north": { "uv": [ 0, 13, 16, 16 ], "rotation": 90, "texture": "#texture" }, + "east": { "uv": [ 0, 0, 16, 3 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 13, 0, 13 ], + "to": [ 16, 15, 16 ], + "faces": { + "down": { "uv": [ 0, 13, 3, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 13, 13, 16, 16 ], "texture": "#texture" }, + "south": { "uv": [ 16, 16, 0, 13 ], "rotation": 90, "texture": "#texture" }, + "east": { "uv": [ 0, 13, 16, 16 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 0, 14.5, -0.5 ], + "to": [ 16, 15.5, 15.5 ], + "rotation": { "origin": [ 0, 15.5, -0.5 ], "axis": "x", "angle": -45 }, + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "rotation": 180, "texture": "#texture" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "north": { "uv": [ 0, 15, 16, 16 ], "rotation": 180, "texture": "#texture" }, + "south": { "uv": [ 16, 16, 0, 15 ], "texture": "#texture" }, + "west": { "uv": [ 15, 0, 16, 16 ], "rotation": 270, "texture": "#texture" }, + "east": { "uv": [ 0, 0, 1, 16 ], "rotation": 90, "texture": "#texture" } + } +}, +{ + "from": [ 7.5, 21, 7.5 ], + "to": [ 8.5, 22, 17 ], + "rotation": { "origin": [ 7.5, 22, 7.5 ], "axis": "x", "angle": 45 }, + "faces": { + "down": { "uv": [ 16, 3, 16, 16 ], "rotation": 180, "texture": "#log_oak" }, + "up": { "uv": [ 0, 3, 0, 16 ], "texture": "#log_oak" }, + "north": { "uv": [ 0, 15, 0, 16 ], "rotation": 180, "texture": "#log_oak" }, + "south": { "uv": [ 16, 16, 16, 15 ], "texture": "#log_oak" }, + "west": { "uv": [ 15, 3, 16, 16 ], "rotation": 270, "texture": "#log_oak" }, + "east": { "uv": [ 0, 3, 1, 16 ], "rotation": 90, "texture": "#log_oak" } + } +} +] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/item/camouflageSprayCan.json b/src/main/resources/assets/forestry/models/item/camouflageSprayCan.json new file mode 100644 index 000000000..af58a5361 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/camouflageSprayCan.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "forestry:items/camouflageSprayCan" + } +} diff --git a/src/main/resources/assets/forestry/models/item/camouflageSprayCanFilled.json b/src/main/resources/assets/forestry/models/item/camouflageSprayCanFilled.json new file mode 100644 index 000000000..22901c9fb --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/camouflageSprayCanFilled.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "forestry:items/camouflageSprayCanFilled" + } +} diff --git a/src/main/resources/assets/forestry/models/item/greenhouse.window.json b/src/main/resources/assets/forestry/models/item/greenhouse.window.json new file mode 100644 index 000000000..089ee1160 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/greenhouse.window.json @@ -0,0 +1,40 @@ +{ + "parent": "forestry:block/greenhouse.window_up_open", + "display": { + "thirdperson_righthand": { + "rotation": [ 75, 135, 0 ], + "translation": [ 0, 2.5, 0 ], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "thirdperson_lefthand": { + "rotation": [ 75, 135, 0 ], + "translation": [ 0, 2.5, 0 ], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0 ], + "scale": [ 0.25, 0.25, 0.25 ] + }, + "fixed": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.5, 0.5, 0.5 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -135, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.4, 0.4, 0.4 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, -135, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.4, 0.4, 0.4 ] + }, + "gui": { + "rotation": [ 30, 45, 0 ], + "translation": [ 0, -1.5, 0 ], + "scale": [ 0.5, 0.5, 0.5 ] + } + } +} diff --git a/src/main/resources/assets/forestry/models/item/greenhouse.window_up.json b/src/main/resources/assets/forestry/models/item/greenhouse.window_up.json new file mode 100644 index 000000000..089ee1160 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/greenhouse.window_up.json @@ -0,0 +1,40 @@ +{ + "parent": "forestry:block/greenhouse.window_up_open", + "display": { + "thirdperson_righthand": { + "rotation": [ 75, 135, 0 ], + "translation": [ 0, 2.5, 0 ], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "thirdperson_lefthand": { + "rotation": [ 75, 135, 0 ], + "translation": [ 0, 2.5, 0 ], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0 ], + "scale": [ 0.25, 0.25, 0.25 ] + }, + "fixed": { + "rotation": [ -90, 0, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.5, 0.5, 0.5 ] + }, + "firstperson_righthand": { + "rotation": [ 0, -135, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.4, 0.4, 0.4 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, -135, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.4, 0.4, 0.4 ] + }, + "gui": { + "rotation": [ 30, 45, 0 ], + "translation": [ 0, -1.5, 0 ], + "scale": [ 0.5, 0.5, 0.5 ] + } + } +} diff --git a/src/main/resources/assets/forestry/models/item/smoker.json b/src/main/resources/assets/forestry/models/item/smoker.json index 04ee0a65c..4a5140f76 100644 --- a/src/main/resources/assets/forestry/models/item/smoker.json +++ b/src/main/resources/assets/forestry/models/item/smoker.json @@ -1,5 +1,5 @@ { - "parent": "builtin/generated", + "parent": "item/generated", "textures": { "layer0": "forestry:items/smoker" }, diff --git a/src/main/resources/assets/forestry/textures/blocks/greenhouse/climate_control.png b/src/main/resources/assets/forestry/textures/blocks/greenhouse/climate_control.png new file mode 100644 index 000000000..3ebaad392 Binary files /dev/null and b/src/main/resources/assets/forestry/textures/blocks/greenhouse/climate_control.png differ diff --git a/src/main/resources/assets/forestry/textures/gui/camouflageSprayCan.png b/src/main/resources/assets/forestry/textures/gui/camouflageSprayCan.png new file mode 100644 index 000000000..960954fad Binary files /dev/null and b/src/main/resources/assets/forestry/textures/gui/camouflageSprayCan.png differ diff --git a/src/main/resources/assets/forestry/textures/items/camouflageSprayCan.png b/src/main/resources/assets/forestry/textures/items/camouflageSprayCan.png new file mode 100644 index 000000000..cfadfc42a Binary files /dev/null and b/src/main/resources/assets/forestry/textures/items/camouflageSprayCan.png differ diff --git a/src/main/resources/assets/forestry/textures/items/camouflageSprayCanFilled.png b/src/main/resources/assets/forestry/textures/items/camouflageSprayCanFilled.png new file mode 100644 index 000000000..bc9b2c7bc Binary files /dev/null and b/src/main/resources/assets/forestry/textures/items/camouflageSprayCanFilled.png differ diff --git a/src/main/resources/assets/forestry/textures/items/camouflagedPaneling.png b/src/main/resources/assets/forestry/textures/items/camouflagedPaneling.png index f8a230f26..db093d8e8 100644 Binary files a/src/main/resources/assets/forestry/textures/items/camouflagedPaneling.png and b/src/main/resources/assets/forestry/textures/items/camouflagedPaneling.png differ diff --git a/src/main/resources/config/forestry/colour.properties b/src/main/resources/config/forestry/colour.properties index 8bd71abdf..23fe2e7c6 100755 --- a/src/main/resources/config/forestry/colour.properties +++ b/src/main/resources/config/forestry/colour.properties @@ -18,6 +18,9 @@ gui.beealyzer.dominant=ec3661 gui.mail.lettertext=cfa738 gui.mail.text=6689dc +gui.greenhouse.temperature.text=404040 +gui.greenhouse.humidity.text=404040 + ledger.error.background=ff3535 ledger.error.header=e1c92f ledger.error.text=000000