From cc50a05f43a2dc1f1bcaf8fd2ac7ccd5cc2dd05f Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Tue, 9 Jan 2018 18:36:20 +0100 Subject: [PATCH 01/12] Reintroduce the old-style farm --- lang | 2 +- .../api/cultivation/IPlanterHousing.java | 29 ++ .../forestry/api/farming/IFarmHousing.java | 26 +- .../forestry/api/farming/IFarmInventory.java | 2 + .../java/forestry/api/farming/IFarmLogic.java | 13 +- .../forestry/api/farming/IFarmRegistry.java | 4 +- .../java/forestry/core/blocks/BlockBase.java | 22 + .../java/forestry/core/circuits/Circuits.java | 6 +- .../java/forestry/core/gui/GuiIdRegistry.java | 3 + .../core/network/packets/PacketGuiUpdate.java | 10 +- .../java/forestry/core/utils/VectUtil.java | 3 +- .../cultivation/ModuleCultivation.java | 117 +++++ .../cultivation/blocks/BlockPlanter.java | 17 + .../blocks/BlockRegistryCultivation.java | 31 ++ .../cultivation/blocks/BlockTypePlanter.java | 40 ++ .../cultivation/blocks/package-info.java | 10 + .../cultivation/gui/ContainerPlanter.java | 50 ++ .../forestry/cultivation/gui/GuiPlanter.java | 81 +++ .../cultivation/gui/package-info.java | 10 + .../gui/widgets/GhostItemStackWidget.java | 69 +++ .../cultivation/gui/widgets/package-info.java | 10 + .../inventory/InventoryPlanter.java | 220 ++++++++ .../cultivation/inventory/package-info.java | 10 + .../cultivation/items/package-info.java | 10 + .../cultivation/network/package-info.java | 10 + .../forestry/cultivation/package-info.java | 10 + .../cultivation/tiles/TileArboretum.java | 41 ++ .../forestry/cultivation/tiles/TileBog.java | 36 ++ .../cultivation/tiles/TileFarmCrops.java | 41 ++ .../cultivation/tiles/TileFarmGourd.java | 30 ++ .../cultivation/tiles/TileFarmMushroom.java | 40 ++ .../cultivation/tiles/TileFarmNether.java | 41 ++ .../cultivation/tiles/TilePlantation.java | 26 + .../cultivation/tiles/TilePlanter.java | 488 ++++++++++++++++++ .../cultivation/tiles/package-info.java | 10 + .../java/forestry/farming/FarmHelper.java | 182 ++++++- .../java/forestry/farming/FarmTarget.java | 7 +- .../java/forestry/farming/ModuleFarming.java | 40 +- .../forestry/farming/logic/FarmLogic.java | 5 + .../farming/logic/FarmLogicArboreal.java | 6 +- .../farming/logic/FarmLogicCereal.java | 37 -- .../farming/logic/FarmLogicCocoa.java | 13 +- .../farming/logic/FarmLogicCrops.java | 28 +- .../forestry/farming/logic/FarmLogicExU.java | 16 +- .../farming/logic/FarmLogicGourd.java | 6 - .../farming/logic/FarmLogicHomogeneous.java | 42 +- .../farming/logic/FarmLogicInfernal.java | 12 +- .../farming/logic/FarmLogicOrchard.java | 8 +- .../forestry/farming/logic/FarmLogicPeat.java | 1 + .../farming/logic/FarmLogicReeds.java | 24 +- .../farming/logic/FarmLogicRubber.java | 6 +- .../forestry/farming/logic/FarmLogicSoil.java | 20 + .../farming/logic/FarmLogicSucculent.java | 11 +- .../farming/logic/FarmLogicVegetable.java | 38 -- .../farming/logic/FarmLogicWatered.java | 28 +- .../farming/logic/{ => crops}/Crop.java | 2 +- .../logic/{ => crops}/CropBasicAgriCraft.java | 5 +- .../{ => crops}/CropBasicGrowthCraft.java | 9 +- .../logic/{ => crops}/CropBasicIC2Crop.java | 8 +- .../logic/{ => crops}/CropDestroy.java | 9 +- .../logic/{ => crops}/CropDestroyDouble.java | 6 +- .../farming/logic/{ => crops}/CropFruit.java | 2 +- .../farming/logic/{ => crops}/CropPeat.java | 2 +- .../farming/logic/{ => crops}/CropRubber.java | 2 +- .../farming/logic/crops/package-info.java | 10 + .../{ => farmables}/FarmableAgingCrop.java | 13 +- .../logic/{ => farmables}/FarmableBase.java | 10 +- .../FarmableBasicAgricraft.java | 6 +- .../FarmableBasicGrowthCraft.java | 2 +- .../{ => farmables}/FarmableBasicIC2Crop.java | 4 +- .../logic/{ => farmables}/FarmableCocoa.java | 2 +- .../{ => farmables}/FarmableDoubleCrop.java | 3 +- .../logic/{ => farmables}/FarmableGE.java | 3 +- .../logic/{ => farmables}/FarmableGourd.java | 3 +- .../{ => farmables}/FarmableRusticGrape.java | 3 +- .../FarmableRusticSapling.java | 3 +- .../{ => farmables}/FarmableSapling.java | 3 +- .../{ => farmables}/FarmableStacked.java | 3 +- .../FarmableVanillaMushroom.java | 6 +- .../FarmableVanillaSapling.java | 2 +- .../farming/logic/farmables/package-info.java | 10 + .../multiblock/FakeFarmController.java | 21 +- .../farming/multiblock/FarmController.java | 197 +------ .../multiblock/FarmFertilizerManager.java | 11 +- .../multiblock/IFarmInventoryInternal.java | 10 + .../farming/multiblock/InventoryFarm.java | 4 +- .../forestry/modules/ForestryModuleUids.java | 1 + .../plugins/PluginActuallyAdditions.java | 2 +- .../plugins/PluginBetterWithMods.java | 2 +- .../plugins/PluginExtraUtilities.java | 2 +- .../forestry/plugins/PluginHarvestCraft.java | 23 +- src/main/java/forestry/plugins/PluginIC2.java | 3 +- .../plugins/PluginImmersiveEngineering.java | 2 +- .../plugins/PluginMysticalAgriculture.java | 2 +- .../java/forestry/plugins/PluginNatura.java | 6 +- .../java/forestry/plugins/PluginRoots.java | 2 +- .../java/forestry/plugins/PluginRustic.java | 6 +- .../forestry/blockstates/arboretum.json | 8 + .../forestry/blockstates/farm_crops.json | 8 + .../forestry/blockstates/farm_gourd.json | 8 + .../forestry/blockstates/farm_mushroom.json | 8 + .../forestry/blockstates/farm_nether.json | 8 + .../assets/forestry/blockstates/peat_bog.json | 8 + .../forestry/blockstates/plantation.json | 8 + .../forestry/models/block/arboretum.json | 57 ++ .../forestry/models/block/farm_crops.json | 57 ++ .../forestry/models/block/farm_gourd.json | 57 ++ .../forestry/models/block/farm_mushroom.json | 57 ++ .../forestry/models/block/farm_nether.json | 57 ++ .../forestry/models/block/peat_bog.json | 57 ++ .../forestry/models/block/plantation.json | 57 ++ .../forestry/models/item/arboretum.json | 3 + .../forestry/models/item/farm_crops.json | 3 + .../forestry/models/item/farm_gourd.json | 3 + .../forestry/models/item/farm_mushroom.json | 3 + .../forestry/models/item/farm_nether.json | 3 + .../assets/forestry/models/item/peat_bog.json | 3 + .../forestry/models/item/plantation.json | 3 + .../forestry/textures/blocks/arboretum.png | Bin 0 -> 1880 bytes .../textures/blocks/arboretum_particle.png | Bin 0 -> 472 bytes .../forestry/textures/blocks/farm_crops.png | Bin 0 -> 1704 bytes .../textures/blocks/farm_crops_particle.png | Bin 0 -> 408 bytes .../forestry/textures/blocks/farm_gourd.png | Bin 0 -> 2162 bytes .../textures/blocks/farm_gourd_particle.png | Bin 0 -> 470 bytes .../textures/blocks/farm_mushroom.png | Bin 0 -> 2014 bytes .../blocks/farm_mushroom_particle.png | Bin 0 -> 469 bytes .../forestry/textures/blocks/farm_nether.png | Bin 0 -> 1579 bytes .../textures/blocks/farm_nether_particle.png | Bin 0 -> 387 bytes .../forestry/textures/blocks/peat_bog.png | Bin 0 -> 1561 bytes .../textures/blocks/peat_bog_particle.png | Bin 0 -> 412 bytes .../forestry/textures/blocks/plantation.png | Bin 0 -> 1698 bytes .../textures/blocks/plantation_particle.png | Bin 0 -> 445 bytes .../forestry/textures/gui/arboretum.png | Bin 0 -> 3384 bytes .../assets/forestry/textures/gui/buttons.png | Bin 9796 -> 9796 bytes .../assets/forestry/textures/gui/planter.png | Bin 0 -> 727 bytes 135 files changed, 2483 insertions(+), 516 deletions(-) create mode 100644 src/main/java/forestry/api/cultivation/IPlanterHousing.java create mode 100644 src/main/java/forestry/cultivation/ModuleCultivation.java create mode 100644 src/main/java/forestry/cultivation/blocks/BlockPlanter.java create mode 100644 src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java create mode 100644 src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java create mode 100644 src/main/java/forestry/cultivation/blocks/package-info.java create mode 100644 src/main/java/forestry/cultivation/gui/ContainerPlanter.java create mode 100644 src/main/java/forestry/cultivation/gui/GuiPlanter.java create mode 100644 src/main/java/forestry/cultivation/gui/package-info.java create mode 100644 src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java create mode 100644 src/main/java/forestry/cultivation/gui/widgets/package-info.java create mode 100644 src/main/java/forestry/cultivation/inventory/InventoryPlanter.java create mode 100644 src/main/java/forestry/cultivation/inventory/package-info.java create mode 100644 src/main/java/forestry/cultivation/items/package-info.java create mode 100644 src/main/java/forestry/cultivation/network/package-info.java create mode 100644 src/main/java/forestry/cultivation/package-info.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileArboretum.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileBog.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileFarmCrops.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileFarmGourd.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileFarmNether.java create mode 100644 src/main/java/forestry/cultivation/tiles/TilePlantation.java create mode 100644 src/main/java/forestry/cultivation/tiles/TilePlanter.java create mode 100644 src/main/java/forestry/cultivation/tiles/package-info.java delete mode 100755 src/main/java/forestry/farming/logic/FarmLogicCereal.java create mode 100644 src/main/java/forestry/farming/logic/FarmLogicSoil.java delete mode 100755 src/main/java/forestry/farming/logic/FarmLogicVegetable.java rename src/main/java/forestry/farming/logic/{ => crops}/Crop.java (97%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => crops}/CropBasicAgriCraft.java (98%) rename src/main/java/forestry/farming/logic/{ => crops}/CropBasicGrowthCraft.java (98%) rename src/main/java/forestry/farming/logic/{ => crops}/CropBasicIC2Crop.java (95%) rename src/main/java/forestry/farming/logic/{ => crops}/CropDestroy.java (98%) rename src/main/java/forestry/farming/logic/{ => crops}/CropDestroyDouble.java (91%) rename src/main/java/forestry/farming/logic/{ => crops}/CropFruit.java (97%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => crops}/CropPeat.java (98%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => crops}/CropRubber.java (98%) mode change 100755 => 100644 create mode 100644 src/main/java/forestry/farming/logic/crops/package-info.java rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableAgingCrop.java (96%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableBase.java (94%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableBasicAgricraft.java (92%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableBasicGrowthCraft.java (97%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableBasicIC2Crop.java (95%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableCocoa.java (96%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableDoubleCrop.java (91%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableGE.java (95%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableGourd.java (95%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableRusticGrape.java (94%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableRusticSapling.java (95%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableSapling.java (97%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableStacked.java (95%) mode change 100755 => 100644 rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableVanillaMushroom.java (93%) rename src/main/java/forestry/farming/logic/{ => farmables}/FarmableVanillaSapling.java (95%) mode change 100755 => 100644 create mode 100644 src/main/java/forestry/farming/logic/farmables/package-info.java create mode 100644 src/main/java/forestry/farming/multiblock/IFarmInventoryInternal.java create mode 100644 src/main/resources/assets/forestry/blockstates/arboretum.json create mode 100644 src/main/resources/assets/forestry/blockstates/farm_crops.json create mode 100644 src/main/resources/assets/forestry/blockstates/farm_gourd.json create mode 100644 src/main/resources/assets/forestry/blockstates/farm_mushroom.json create mode 100644 src/main/resources/assets/forestry/blockstates/farm_nether.json create mode 100644 src/main/resources/assets/forestry/blockstates/peat_bog.json create mode 100644 src/main/resources/assets/forestry/blockstates/plantation.json create mode 100644 src/main/resources/assets/forestry/models/block/arboretum.json create mode 100644 src/main/resources/assets/forestry/models/block/farm_crops.json create mode 100644 src/main/resources/assets/forestry/models/block/farm_gourd.json create mode 100644 src/main/resources/assets/forestry/models/block/farm_mushroom.json create mode 100644 src/main/resources/assets/forestry/models/block/farm_nether.json create mode 100644 src/main/resources/assets/forestry/models/block/peat_bog.json create mode 100644 src/main/resources/assets/forestry/models/block/plantation.json create mode 100644 src/main/resources/assets/forestry/models/item/arboretum.json create mode 100644 src/main/resources/assets/forestry/models/item/farm_crops.json create mode 100644 src/main/resources/assets/forestry/models/item/farm_gourd.json create mode 100644 src/main/resources/assets/forestry/models/item/farm_mushroom.json create mode 100644 src/main/resources/assets/forestry/models/item/farm_nether.json create mode 100644 src/main/resources/assets/forestry/models/item/peat_bog.json create mode 100644 src/main/resources/assets/forestry/models/item/plantation.json create mode 100644 src/main/resources/assets/forestry/textures/blocks/arboretum.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/arboretum_particle.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_crops.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_crops_particle.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_gourd.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_gourd_particle.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_mushroom.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_mushroom_particle.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_nether.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_nether_particle.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/peat_bog.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/peat_bog_particle.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/plantation.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/plantation_particle.png create mode 100644 src/main/resources/assets/forestry/textures/gui/arboretum.png create mode 100644 src/main/resources/assets/forestry/textures/gui/planter.png diff --git a/lang b/lang index f26fbe9da..cf9f2c21f 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit f26fbe9da8874b36881c9b1fe69f0e29ec768603 +Subproject commit cf9f2c21f53e6ad4ce180bdccf258ff7e717ce94 diff --git a/src/main/java/forestry/api/cultivation/IPlanterHousing.java b/src/main/java/forestry/api/cultivation/IPlanterHousing.java new file mode 100644 index 000000000..3d1a4a1c8 --- /dev/null +++ b/src/main/java/forestry/api/cultivation/IPlanterHousing.java @@ -0,0 +1,29 @@ +package forestry.api.cultivation; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import forestry.api.farming.IFarmInventory; +import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmable; +import forestry.api.genetics.IHousing; + +public interface IPlanterHousing extends IHousing { + /** + * Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem. + * Will remove the appropriate germling from the farm's inventory. + * It's up to the logic to only call this on a valid location. + * + * @return true if planting was successful, false otherwise. + */ + boolean plantGermling(IFarmable germling, World world, BlockPos pos); + + /* INTERACTION WITH HATCHES */ + IFarmInventory getFarmInventory(); + + /* LOGIC */ + IFarmLogic getFarmLogic(); + + /* GUI */ + int getStoredFertilizerScaled(int scale); +} diff --git a/src/main/java/forestry/api/farming/IFarmHousing.java b/src/main/java/forestry/api/farming/IFarmHousing.java index ba5708d9e..cc19ebd9f 100644 --- a/src/main/java/forestry/api/farming/IFarmHousing.java +++ b/src/main/java/forestry/api/farming/IFarmHousing.java @@ -5,12 +5,14 @@ ******************************************************************************/ package forestry.api.farming; -import forestry.api.core.IErrorLogicSource; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; + import net.minecraftforge.fluids.FluidStack; +import forestry.api.core.IErrorLogicSource; + public interface IFarmHousing extends IErrorLogicSource { BlockPos getCoords(); @@ -33,10 +35,32 @@ public interface IFarmHousing extends IErrorLogicSource { * Will remove the appropriate germling from the farm's inventory. * It's up to the logic to only call this on a valid location. * + * @deprecated TODO remove this method in 1.13 + * * @return true if planting was successful, false otherwise. */ + @Deprecated boolean plantGermling(IFarmable farmable, World world, BlockPos pos); + /** + * Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem. + * Will remove the appropriate germling from the farm's inventory. + * It's up to the logic to only call this on a valid location. + * + * @return true if planting was successful, false otherwise. + */ + default boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction){ + return plantGermling(farmable, world, pos); + } + + default boolean isValidPlatform(World world, BlockPos pos){ + return false; + } + + default boolean isSquare(){ + return false; + } + /* INTERACTION WITH HATCHES */ IFarmInventory getFarmInventory(); diff --git a/src/main/java/forestry/api/farming/IFarmInventory.java b/src/main/java/forestry/api/farming/IFarmInventory.java index 7f9a793d8..0d08dbc22 100644 --- a/src/main/java/forestry/api/farming/IFarmInventory.java +++ b/src/main/java/forestry/api/farming/IFarmInventory.java @@ -27,4 +27,6 @@ public interface IFarmInventory { IInventory getResourcesInventory(); IInventory getFertilizerInventory(); + + } diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index 03fa75cd8..873fcc353 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -13,6 +13,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -35,12 +36,18 @@ public interface IFarmLogic { IFarmLogic setManual(boolean manual); void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData); - - @SideOnly(Side.CLIENT) - ResourceLocation getTextureMap(); String getName(); + /* GUI ONLY */ + + /** + * @deprecated TODO remove this method in 1.13 + */ + @Deprecated + @SideOnly(Side.CLIENT) + ResourceLocation getTextureMap(); + /** * @return the itemStack that represents this farm logic. Used as an icon for the farm logic. */ diff --git a/src/main/java/forestry/api/farming/IFarmRegistry.java b/src/main/java/forestry/api/farming/IFarmRegistry.java index 9119a990f..0b8d8bb9a 100644 --- a/src/main/java/forestry/api/farming/IFarmRegistry.java +++ b/src/main/java/forestry/api/farming/IFarmRegistry.java @@ -14,7 +14,7 @@ public interface IFarmRegistry { /** * Registers farming logic in registry under given identifier - * @param identifier Valid identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom + * @param identifier Valid identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom * @param logic corresponding instance of logic */ void registerFarmLogic(String identifier, IFarmLogic logic); @@ -22,7 +22,7 @@ public interface IFarmRegistry { /** * Can be used to add IFarmables to some of the vanilla farm logics. *

- * Identifiers: farmArboreal farmWheat farmGourd farmInfernal farmPoales farmSucculentes farmVegetables farmShroom + * Identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom */ void registerFarmables(String identifier, IFarmable... farmable); diff --git a/src/main/java/forestry/core/blocks/BlockBase.java b/src/main/java/forestry/core/blocks/BlockBase.java index 366c5fba2..1922d22ca 100755 --- a/src/main/java/forestry/core/blocks/BlockBase.java +++ b/src/main/java/forestry/core/blocks/BlockBase.java @@ -20,6 +20,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.ParticleManager; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -40,8 +41,11 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import com.mojang.authlib.GameProfile; + import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fluids.FluidUtil; + import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -51,6 +55,8 @@ import forestry.api.core.ISpriteRegister; import forestry.api.core.IStateMapperRegister; import forestry.api.core.ITextureManager; import forestry.core.circuits.ISocketable; +import forestry.core.owner.IOwnedTile; +import forestry.core.owner.IOwnerHandler; import forestry.core.render.MachineParticleCallback; import forestry.core.render.MachineStateMapper; import forestry.core.render.ParticleHelper; @@ -212,6 +218,22 @@ public class BlockBase

& IBlockType & IStringSerializable> ext super.breakBlock(world, pos, state); } + @Override + public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { + if (world.isRemote) { + return; + } + + if (placer instanceof EntityPlayer) { + TileUtil.actOnTile(world, pos, IOwnedTile.class, tile -> { + IOwnerHandler ownerHandler = tile.getOwnerHandler(); + EntityPlayer player = (EntityPlayer) placer; + GameProfile gameProfile = player.getGameProfile(); + ownerHandler.setOwner(gameProfile); + }); + } + } + public void init() { blockType.getMachineProperties().registerTileEntity(); } diff --git a/src/main/java/forestry/core/circuits/Circuits.java b/src/main/java/forestry/core/circuits/Circuits.java index cecbb5c96..b45a1b1e3 100644 --- a/src/main/java/forestry/core/circuits/Circuits.java +++ b/src/main/java/forestry/core/circuits/Circuits.java @@ -10,8 +10,7 @@ public class Circuits { public static ICircuit energyElectricBoost2; public static ICircuit farmArborealManaged; public static ICircuit farmShroomManaged; - public static ICircuit farmCerealManaged; - public static ICircuit farmVegetableManaged; + public static ICircuit farmCropsManaged; public static ICircuit farmPeatManaged; public static ICircuit farmSucculentManaged; public static ICircuit farmPoaleManaged; @@ -19,8 +18,7 @@ public class Circuits { public static ICircuit farmInfernalManaged; public static ICircuit farmGourdManaged; public static ICircuit farmShroomManual; - public static ICircuit farmCerealManual; - public static ICircuit farmVegetableManual; + public static ICircuit farmCropsManual; public static ICircuit farmPeatManual; public static ICircuit farmSucculentManual; public static ICircuit farmPoalesManual; diff --git a/src/main/java/forestry/core/gui/GuiIdRegistry.java b/src/main/java/forestry/core/gui/GuiIdRegistry.java index ff87193c6..62e1a5625 100644 --- a/src/main/java/forestry/core/gui/GuiIdRegistry.java +++ b/src/main/java/forestry/core/gui/GuiIdRegistry.java @@ -30,6 +30,7 @@ import forestry.core.items.ItemSolderingIron; import forestry.core.tiles.TileAnalyzer; import forestry.core.tiles.TileEscritoire; import forestry.core.tiles.TileNaturalistChest; +import forestry.cultivation.tiles.TilePlanter; import forestry.database.tiles.TileDatabase; import forestry.energy.tiles.TileEngineBiogas; import forestry.energy.tiles.TileEngineElectric; @@ -90,6 +91,8 @@ public class GuiIdRegistry { TileFarm.class, + TilePlanter.class, + TileGreenhouse.class, TileClimatiser.class, TileHygroregulator.class, diff --git a/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java b/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java index d29541117..0e84e46ad 100644 --- a/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java +++ b/src/main/java/forestry/core/network/packets/PacketGuiUpdate.java @@ -12,6 +12,12 @@ package forestry.core.network.packets; import java.io.IOException; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.BlockPos; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + import forestry.api.core.ILocatable; import forestry.core.network.ForestryPacket; import forestry.core.network.IForestryPacketClient; @@ -20,10 +26,6 @@ import forestry.core.network.IStreamableGui; import forestry.core.network.PacketBufferForestry; import forestry.core.network.PacketIdClient; import forestry.core.tiles.TileUtil; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; public class PacketGuiUpdate extends ForestryPacket implements IForestryPacketClient { private final BlockPos pos; diff --git a/src/main/java/forestry/core/utils/VectUtil.java b/src/main/java/forestry/core/utils/VectUtil.java index 4b0394fb7..64917ed1d 100644 --- a/src/main/java/forestry/core/utils/VectUtil.java +++ b/src/main/java/forestry/core/utils/VectUtil.java @@ -10,11 +10,12 @@ ******************************************************************************/ package forestry.core.utils; +import com.google.common.collect.AbstractIterator; + import javax.annotation.Nullable; import java.util.Iterator; import java.util.Random; -import com.google.common.collect.AbstractIterator; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; diff --git a/src/main/java/forestry/cultivation/ModuleCultivation.java b/src/main/java/forestry/cultivation/ModuleCultivation.java new file mode 100644 index 000000000..28c23703f --- /dev/null +++ b/src/main/java/forestry/cultivation/ModuleCultivation.java @@ -0,0 +1,117 @@ +package forestry.cultivation; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; + +import javax.annotation.Nullable; +import java.util.Set; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.util.ResourceLocation; + +import forestry.api.modules.ForestryModule; +import forestry.core.ModuleCore; +import forestry.core.circuits.EnumCircuitBoardType; +import forestry.core.config.Constants; +import forestry.core.items.EnumElectronTube; +import forestry.core.items.ItemRegistryCore; +import forestry.core.recipes.RecipeUtil; +import forestry.core.utils.OreDictUtil; +import forestry.cultivation.blocks.BlockRegistryCultivation; +import forestry.modules.BlankForestryModule; +import forestry.modules.ForestryModuleUids; + +@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.CULTIVATION, name = "Cultivation", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.module.cultivation.description") +public class ModuleCultivation extends BlankForestryModule { + @Nullable + private static BlockRegistryCultivation blocks; + + public static BlockRegistryCultivation getBlocks() { + Preconditions.checkState(blocks != null); + return blocks; + } + + @Override + public void registerItemsAndBlocks() { + blocks = new BlockRegistryCultivation(); + } + + @Override + public Set getDependencyUids() { + return ImmutableSet.of(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.CORE), + new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)); + } + + @Override + public void doInit() { + BlockRegistryCultivation blocks = getBlocks(); + + blocks.arboretum.init(); + blocks.farmCrops.init(); + blocks.farmMushroom.init(); + blocks.farmNether.init(); + blocks.farmGourd.init(); + //blocks.plantation.init(); + blocks.peatBog.init(); + } + + @Override + public void registerRecipes() { + BlockRegistryCultivation blocks = getBlocks(); + ItemRegistryCore coreItems = ModuleCore.getItems(); + + RecipeUtil.addRecipe("arboretum", blocks.arboretum, + "GTG", + "TCT", + "GBG", + 'G', OreDictUtil.BLOCK_GLASS, + 'T', coreItems.tubes.get(EnumElectronTube.GOLD, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); + + RecipeUtil.addRecipe("farm_crops", blocks.farmCrops, + "GTG", + "TCT", + "GBG", + 'G', OreDictUtil.BLOCK_GLASS, + 'T', coreItems.tubes.get(EnumElectronTube.BRONZE, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); + + RecipeUtil.addRecipe("peat_bog", blocks.peatBog, + "GTG", + "TCT", + "GBG", + 'G', OreDictUtil.BLOCK_GLASS, + 'T', coreItems.tubes.get(EnumElectronTube.COPPER, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); + + RecipeUtil.addRecipe("farm_mushroom", blocks.farmMushroom, + "BGR", + "GAG", + "RGB", + 'G', OreDictUtil.BLOCK_GLASS, + 'B', Blocks.BROWN_MUSHROOM, + 'R', Blocks.RED_MUSHROOM, + 'A', blocks.arboretum); + + RecipeUtil.addRecipe("farm_gourd", blocks.farmGourd, + "MGP", + "GAG", + "PGM", + 'G', OreDictUtil.BLOCK_GLASS, + 'M', Blocks.MELON_BLOCK, + 'P', Blocks.PUMPKIN, + 'A', blocks.arboretum); + + RecipeUtil.addRecipe("farm_nether", blocks.farmNether, + "WGW", + "GAG", + "WGW", + 'G', OreDictUtil.BLOCK_GLASS, + 'W', Items.NETHER_WART, + 'A', blocks.arboretum); + } +} diff --git a/src/main/java/forestry/cultivation/blocks/BlockPlanter.java b/src/main/java/forestry/cultivation/blocks/BlockPlanter.java new file mode 100644 index 000000000..5f56462b9 --- /dev/null +++ b/src/main/java/forestry/cultivation/blocks/BlockPlanter.java @@ -0,0 +1,17 @@ +package forestry.cultivation.blocks; + +import net.minecraft.block.material.Material; +import net.minecraft.util.BlockRenderLayer; + +import forestry.core.blocks.BlockBase; + +public class BlockPlanter extends BlockBase { + public BlockPlanter(BlockTypePlanter blockType) { + super(blockType, Material.WOOD); + } + + @Override + public BlockRenderLayer getBlockLayer() { + return BlockRenderLayer.CUTOUT; + } +} diff --git a/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java b/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java new file mode 100644 index 000000000..07d8f9516 --- /dev/null +++ b/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java @@ -0,0 +1,31 @@ +package forestry.cultivation.blocks; + +import forestry.core.blocks.BlockRegistry; +import forestry.core.items.ItemBlockForestry; + +public class BlockRegistryCultivation extends BlockRegistry { + public final BlockPlanter arboretum; + public final BlockPlanter farmCrops; + public final BlockPlanter farmMushroom; + public final BlockPlanter farmGourd; + public final BlockPlanter farmNether; + public final BlockPlanter peatBog; + /*public final BlockPlanter plantation;*/ + + public BlockRegistryCultivation() { + arboretum = new BlockPlanter(BlockTypePlanter.ARBORETUM); + registerBlock(arboretum, new ItemBlockForestry<>(arboretum), "arboretum"); + farmCrops = new BlockPlanter(BlockTypePlanter.FARM_CROPS); + registerBlock(farmCrops, new ItemBlockForestry<>(farmCrops), "farm_crops"); + farmMushroom = new BlockPlanter(BlockTypePlanter.FARM_MUSHROOM); + registerBlock(farmMushroom, new ItemBlockForestry<>(farmMushroom), "farm_mushroom"); + farmGourd = new BlockPlanter(BlockTypePlanter.FARM_GOURD); + registerBlock(farmGourd, new ItemBlockForestry<>(farmGourd), "farm_gourd"); + farmNether = new BlockPlanter(BlockTypePlanter.FARM_NETHER); + registerBlock(farmNether, new ItemBlockForestry<>(farmNether), "farm_nether"); + peatBog = new BlockPlanter(BlockTypePlanter.PEAT_POG); + registerBlock(peatBog, new ItemBlockForestry<>(peatBog), "peat_bog"); + /* plantation = new BlockPlanter(BlockTypePlanter.PLANTATION); + registerBlock(plantation, new ItemBlockForestry<>(plantation), "plantation");*/ + } +} diff --git a/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java b/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java new file mode 100644 index 000000000..a2871d288 --- /dev/null +++ b/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java @@ -0,0 +1,40 @@ +package forestry.cultivation.blocks; + +import forestry.core.blocks.IBlockTypeCustom; +import forestry.core.blocks.IMachineProperties; +import forestry.core.blocks.MachineProperties; +import forestry.core.tiles.TileForestry; +import forestry.cultivation.tiles.TileArboretum; +import forestry.cultivation.tiles.TileBog; +import forestry.cultivation.tiles.TileFarmCrops; +import forestry.cultivation.tiles.TileFarmGourd; +import forestry.cultivation.tiles.TileFarmMushroom; +import forestry.cultivation.tiles.TileFarmNether; + +public enum BlockTypePlanter implements IBlockTypeCustom { + ARBORETUM(TileArboretum.class, "arboretum"), + FARM_CROPS(TileFarmCrops.class, "farm_crop"), + FARM_MUSHROOM(TileFarmMushroom.class, "farm_mushroom"), + FARM_GOURD(TileFarmGourd.class, "farm_gourd"), + FARM_NETHER(TileFarmNether.class, "farm_nether"), + PEAT_POG(TileBog.class, "peat_bog"), + + //TODO Add ic2 integration + /*PLANTATION(TilePlantation.class, "plantation")*/; + + private final IMachineProperties machineProperties; + + BlockTypePlanter(Class teClass, String name) { + this.machineProperties = new MachineProperties<>(teClass, name); + } + + @Override + public IMachineProperties getMachineProperties() { + return machineProperties; + } + + @Override + public String getName() { + return getMachineProperties().getName(); + } +} diff --git a/src/main/java/forestry/cultivation/blocks/package-info.java b/src/main/java/forestry/cultivation/blocks/package-info.java new file mode 100644 index 000000000..b9d177317 --- /dev/null +++ b/src/main/java/forestry/cultivation/blocks/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.blocks; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/gui/ContainerPlanter.java b/src/main/java/forestry/cultivation/gui/ContainerPlanter.java new file mode 100644 index 000000000..ec66f1eeb --- /dev/null +++ b/src/main/java/forestry/cultivation/gui/ContainerPlanter.java @@ -0,0 +1,50 @@ +package forestry.cultivation.gui; + +import net.minecraft.entity.player.InventoryPlayer; + +import forestry.core.gui.ContainerLiquidTanks; +import forestry.core.gui.slots.SlotFiltered; +import forestry.core.gui.slots.SlotLiquidIn; +import forestry.core.gui.slots.SlotOutput; +import forestry.core.network.packets.PacketGuiUpdate; +import forestry.cultivation.inventory.InventoryPlanter; +import forestry.cultivation.tiles.TilePlanter; + +public class ContainerPlanter extends ContainerLiquidTanks { + public ContainerPlanter(TilePlanter tileForestry, InventoryPlayer playerInventory) { + super(tileForestry, playerInventory, 21, 110); + + // Resources + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + addSlotToContainer(new SlotFiltered(tile.getInternalInventory(), InventoryPlanter.SLOT_RESOURCES_1 + j + i * 2, 11 + j * 18, 65 + i * 18)); + } + } + + // Germlings + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + addSlotToContainer(new SlotFiltered(tile.getInternalInventory(), InventoryPlanter.SLOT_GERMLINGS_1 + j + i * 2, 71 + j * 18, 65 + i * 18)); + } + } + + // Production + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + addSlotToContainer(new SlotOutput(tile.getInternalInventory(), InventoryPlanter.SLOT_PRODUCTION_1 + j + i * 2, 131 + j * 18, 65 + i * 18)); + } + } + + // Fertilizer + addSlotToContainer(new SlotFiltered(tile.getInternalInventory(), InventoryPlanter.SLOT_FERTILIZER, 83, 22)); + // Can Slot + addSlotToContainer(new SlotLiquidIn(tile.getInternalInventory(), InventoryPlanter.SLOT_CAN, 178, 18)); + } + + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); + PacketGuiUpdate packet = new PacketGuiUpdate(tile); + sendPacketToListeners(packet); + } +} diff --git a/src/main/java/forestry/cultivation/gui/GuiPlanter.java b/src/main/java/forestry/cultivation/gui/GuiPlanter.java new file mode 100644 index 000000000..eadaf7eaa --- /dev/null +++ b/src/main/java/forestry/cultivation/gui/GuiPlanter.java @@ -0,0 +1,81 @@ +package forestry.cultivation.gui; + +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; + +import forestry.core.ModuleCore; +import forestry.core.config.Constants; +import forestry.core.gui.GuiForestryTitled; +import forestry.core.gui.widgets.TankWidget; +import forestry.cultivation.gui.widgets.GhostItemStackWidget; +import forestry.cultivation.inventory.InventoryPlanter; +import forestry.cultivation.tiles.TilePlanter; +import forestry.farming.gui.FarmLedger; + +public class GuiPlanter extends GuiForestryTitled { + private final TilePlanter tile; + + public GuiPlanter(TilePlanter tile, InventoryPlayer playerInventory) { + super(Constants.TEXTURE_PATH_GUI + "/planter.png", new ContainerPlanter(tile, playerInventory), tile); + this.tile = tile; + this.xSize = 202; + this.ySize = 192; + + ItemStack[] resourceStacks = tile.createResourceStacks(); + ItemStack[] germlingStacks = tile.createGermlingStacks(); + ItemStack[] productionStacks = tile.createProductionStacks(); + + widgetManager.add(new TankWidget(widgetManager, 178, 44, 0).setOverlayOrigin(xSize, 18)); + + // Resources + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + int index = j + i * 2; + if(resourceStacks.length == 4) { + widgetManager.add(new GhostItemStackWidget(widgetManager, 11 + j * 18, 65 + i * 18, resourceStacks[index], inventorySlots.getSlot(36 + InventoryPlanter.SLOT_RESOURCES_1 + index))); + } + } + } + + // Germlings + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + int index = j + i * 2; + if(germlingStacks.length == 4){ + widgetManager.add(new GhostItemStackWidget(widgetManager, 71 + j * 18, 65 + i * 18, germlingStacks[index], inventorySlots.getSlot(36 + InventoryPlanter.SLOT_GERMLINGS_1 + index))); + } + } + } + + // Production + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + int index = j + i * 2; + if(productionStacks.length == 4) { + widgetManager.add(new GhostItemStackWidget(widgetManager, 131 + j * 18, 65 + i * 18, productionStacks[index], inventorySlots.getSlot(36 + InventoryPlanter.SLOT_PRODUCTION_1 + j + i * 2))); + } + } + } + + widgetManager.add(new GhostItemStackWidget(widgetManager, 83, 22, new ItemStack(ModuleCore.getItems().fertilizerCompound), inventorySlots.getSlot(36 + InventoryPlanter.SLOT_FERTILIZER))); + } + + @Override + protected void addLedgers() { + addErrorLedger(tile); + addClimateLedger(tile); + ledgerManager.add(new FarmLedger(ledgerManager, tile.getFarmLedgerDelegate())); + addOwnerLedger(tile); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(var1, mouseX, mouseY); + + // Fuel remaining + int fertilizerRemain = tile.getStoredFertilizerScaled(16); + if (fertilizerRemain > 0) { + drawTexturedModalRect(guiLeft + 101, guiTop + 21 + 17 - fertilizerRemain, xSize, 17 - fertilizerRemain, 4, fertilizerRemain); + } + } +} diff --git a/src/main/java/forestry/cultivation/gui/package-info.java b/src/main/java/forestry/cultivation/gui/package-info.java new file mode 100644 index 000000000..a8015890e --- /dev/null +++ b/src/main/java/forestry/cultivation/gui/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.gui; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java new file mode 100644 index 000000000..0a4ef4641 --- /dev/null +++ b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java @@ -0,0 +1,69 @@ +package forestry.cultivation.gui.widgets; + +import javax.annotation.Nullable; +import java.util.Locale; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import forestry.api.farming.FarmDirection; +import forestry.core.gui.tooltips.ToolTip; +import forestry.core.gui.widgets.ItemStackWidget; +import forestry.core.gui.widgets.WidgetManager; +import forestry.core.render.ColourProperties; +import forestry.core.utils.Translator; +import forestry.cultivation.inventory.InventoryPlanter; +import org.lwjgl.opengl.GL11; + +public class GhostItemStackWidget extends ItemStackWidget { + private final Slot slot; + public GhostItemStackWidget(WidgetManager widgetManager, int xPos, int yPos, ItemStack itemStack, Slot slot) { + super(widgetManager, xPos, yPos, itemStack); + this.slot = slot; + } + + @Override + public void draw(int startX, int startY) { + if (!slot.getHasStack()) { + super.draw(startX, startY); + } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_BLEND); + + String directionString = getDirectionString(); + if (!directionString.isEmpty()){ + FontRenderer fontRenderer = manager.minecraft.fontRenderer; + fontRenderer.drawStringWithShadow(getDirectionString(), xPos + startX + 5, yPos + startY + 4, ColourProperties.INSTANCE.get("gui.screen")); + } + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.85F); + + TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); + textureManager.bindTexture(manager.gui.textureFile); + manager.gui.drawTexturedModalRect(xPos + startX, yPos + startY, 206, 0, 16, 16); + + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + } + + private String getDirectionString(){ + if(slot.getSlotIndex() >= InventoryPlanter.SLOT_PRODUCTION_1 || slot.getSlotIndex() < InventoryPlanter.SLOT_RESOURCES_1 + InventoryPlanter.SLOT_RESOURCES_COUNT){ + return ""; + } + int index = slot.getSlotIndex() % 4; + FarmDirection direction = FarmDirection.values()[index]; + String directionString = direction.toString().toLowerCase(Locale.ENGLISH); + return Translator.translateToLocal("for.gui.planter." + directionString); + } + + @Nullable + @Override + public ToolTip getToolTip(int mouseX, int mouseY) { + return null; + } +} diff --git a/src/main/java/forestry/cultivation/gui/widgets/package-info.java b/src/main/java/forestry/cultivation/gui/widgets/package-info.java new file mode 100644 index 000000000..13aec40b2 --- /dev/null +++ b/src/main/java/forestry/cultivation/gui/widgets/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.gui.widgets; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java b/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java new file mode 100644 index 000000000..09267c68e --- /dev/null +++ b/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java @@ -0,0 +1,220 @@ +package forestry.cultivation.inventory; + +import java.util.Stack; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; + +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidUtil; + +import forestry.api.core.ForestryAPI; +import forestry.api.cultivation.IPlanterHousing; +import forestry.api.farming.FarmDirection; +import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmable; +import forestry.core.fluids.FluidHelper; +import forestry.core.fluids.TankManager; +import forestry.core.inventory.InventoryAdapterRestricted; +import forestry.core.inventory.wrappers.InventoryMapper; +import forestry.core.tiles.ILiquidTankTile; +import forestry.core.utils.InventoryUtil; +import forestry.core.utils.SlotUtil; +import forestry.farming.multiblock.IFarmInventoryInternal; + +public class InventoryPlanter extends InventoryAdapterRestricted implements IFarmInventoryInternal { + public static final int SLOT_RESOURCES_1 = 0; + public static final int SLOT_RESOURCES_COUNT = 4; + public static final int SLOT_GERMLINGS_1 = 4; + public static final int SLOT_GERMLINGS_COUNT = 4; + public static final int SLOT_PRODUCTION_1 = 8; + public static final int SLOT_PRODUCTION_COUNT = 4; + + public static final int SLOT_FERTILIZER = 12; + public static final int SLOT_FERTILIZER_COUNT = 1; + public static final int SLOT_CAN = 13; + public static final int SLOT_CAN_COUNT = 1; + + public static final int SLOT_COUNT = SLOT_RESOURCES_COUNT + SLOT_GERMLINGS_COUNT + SLOT_PRODUCTION_COUNT + SLOT_FERTILIZER_COUNT + SLOT_CAN_COUNT; + + private static final int FERTILIZER_MODIFIER = ForestryAPI.activeMode.getIntegerSetting("farms.fertilizer.modifier"); + + private final IPlanterHousing housing; + + private final IInventory resourcesInventory; + private final IInventory germlingsInventory; + private final IInventory productInventory; + private final IInventory fertilizerInventory; + + public InventoryPlanter(IPlanterHousing housing) { + super(SLOT_COUNT, "Items"); + this.housing = housing; + + this.resourcesInventory = new InventoryMapper(this, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT); + this.germlingsInventory = new InventoryMapper(this, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT); + this.productInventory = new InventoryMapper(this, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT); + this.fertilizerInventory = new InventoryMapper(this, SLOT_FERTILIZER, SLOT_FERTILIZER_COUNT); + } + + @Override + public boolean canSlotAccept(int slotIndex, ItemStack itemStack) { + if (SlotUtil.isSlotInRange(slotIndex, SLOT_FERTILIZER, SLOT_FERTILIZER_COUNT)) { + return acceptsAsFertilizer(itemStack); + } else if (SlotUtil.isSlotInRange(slotIndex, SLOT_GERMLINGS_1, SLOT_GERMLINGS_COUNT)) { + return acceptsAsGermling(itemStack); + } else if (SlotUtil.isSlotInRange(slotIndex, SLOT_RESOURCES_1, SLOT_RESOURCES_COUNT)) { + return acceptsAsResource(itemStack); + } else if (SlotUtil.isSlotInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) { + FluidStack fluid = FluidUtil.getFluidContained(itemStack); + return fluid != null && ((ILiquidTankTile) housing).getTankManager().canFillFluidType(fluid); + } + return false; + } + + @Override + public boolean canExtractItem(int slotIndex, ItemStack stack, EnumFacing side) { + return SlotUtil.isSlotInRange(slotIndex, SLOT_PRODUCTION_1, SLOT_PRODUCTION_COUNT); + } + + @Override + public boolean hasResources(NonNullList resources) { + return InventoryUtil.contains(resourcesInventory, resources); + } + + @Override + public void removeResources(NonNullList resources) { + InventoryUtil.removeSets(resourcesInventory, 1, resources, null, false, true, false, true); + } + + @Override + public boolean acceptsAsGermling(ItemStack itemstack) { + if (itemstack.isEmpty()) { + return false; + } + + IFarmLogic logic = housing.getFarmLogic(); + return logic.isAcceptedGermling(itemstack); + + } + + @Override + public boolean acceptsAsResource(ItemStack itemstack) { + if (itemstack.isEmpty()) { + return false; + } + + IFarmLogic logic = housing.getFarmLogic(); + return logic.isAcceptedResource(itemstack); + + } + + @Override + public boolean acceptsAsFertilizer(ItemStack itemstack) { + if (itemstack.isEmpty()) { + return false; + } + + return ForestryAPI.farmRegistry.getFertilizeValue(itemstack) > 0; + } + + @Override + public IInventory getProductInventory() { + return productInventory; + } + + @Override + public IInventory getGermlingsInventory() { + return germlingsInventory; + } + + @Override + public IInventory getResourcesInventory() { + return resourcesInventory; + } + + @Override + public IInventory getFertilizerInventory() { + return fertilizerInventory; + } + + public void drainCan(TankManager tankManager) { + FluidHelper.drainContainers(tankManager, this, SLOT_CAN); + } + + public boolean plantGermling(IFarmable germling, EntityPlayer player, BlockPos pos) { + for(FarmDirection direction : FarmDirection.values()){ + if(plantGermling(germling, player, pos, direction)){ + return true; + } + } + return false; + } + + public boolean plantGermling(IFarmable germling, EntityPlayer player, BlockPos pos, FarmDirection direction) { + int index = direction.ordinal(); + ItemStack germlingStack = germlingsInventory.getStackInSlot(index); + if (germlingStack.isEmpty() || !germling.isGermling(germlingStack)) { + return false; + } + + if (germling.plantSaplingAt(player, germlingStack, player.world, pos)) { + germlingsInventory.decrStackSize(index, 1); + return true; + } + return false; + } + + public void addProduce(ItemStack produce) { + int added = InventoryUtil.addStack(productInventory, produce, true); + produce.shrink(added); + } + + public void stowHarvest(Iterable harvested, Stack pendingProduce) { + for (ItemStack harvest : harvested) { + int added = InventoryUtil.addStack(productInventory, harvest, true); + harvest.shrink(added); + if (!harvest.isEmpty()) { + pendingProduce.push(harvest); + } + } + } + + public boolean tryAddPendingProduce(Stack pendingProduce) { + IInventory productInventory = getProductInventory(); + + ItemStack next = pendingProduce.peek(); + boolean added = InventoryUtil.tryAddStack(productInventory, next, true, true); + + if (added) { + pendingProduce.pop(); + } + + return added; + } + + public int getFertilizerValue() { + ItemStack fertilizerStack = getStackInSlot(SLOT_FERTILIZER); + if (fertilizerStack.isEmpty()) { + return 0; + } + + int fertilizerValue = ForestryAPI.farmRegistry.getFertilizeValue(fertilizerStack); + if (fertilizerValue > 0) { + return fertilizerValue * FERTILIZER_MODIFIER; + } + return 0; + } + + public boolean useFertilizer() { + ItemStack fertilizer = getStackInSlot(SLOT_FERTILIZER); + if (acceptsAsFertilizer(fertilizer)) { + decrStackSize(SLOT_FERTILIZER, 1); + return true; + } + return false; + } +} diff --git a/src/main/java/forestry/cultivation/inventory/package-info.java b/src/main/java/forestry/cultivation/inventory/package-info.java new file mode 100644 index 000000000..3c2a1f622 --- /dev/null +++ b/src/main/java/forestry/cultivation/inventory/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.inventory; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/items/package-info.java b/src/main/java/forestry/cultivation/items/package-info.java new file mode 100644 index 000000000..05d9468d4 --- /dev/null +++ b/src/main/java/forestry/cultivation/items/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.items; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/network/package-info.java b/src/main/java/forestry/cultivation/network/package-info.java new file mode 100644 index 000000000..f0aea46cf --- /dev/null +++ b/src/main/java/forestry/cultivation/network/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.network; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/package-info.java b/src/main/java/forestry/cultivation/package-info.java new file mode 100644 index 000000000..ece106cbb --- /dev/null +++ b/src/main/java/forestry/cultivation/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/tiles/TileArboretum.java b/src/main/java/forestry/cultivation/tiles/TileArboretum.java new file mode 100644 index 000000000..065673270 --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileArboretum.java @@ -0,0 +1,41 @@ +package forestry.cultivation.tiles; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class TileArboretum extends TilePlanter { + public TileArboretum() { + super("farmArboreal"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.SAPLING), + new ItemStack(Blocks.SAPLING, 1, 2), + new ItemStack(Blocks.SAPLING, 1, 2), + new ItemStack(Blocks.SAPLING) + }; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.DIRT), + new ItemStack(Blocks.DIRT), + new ItemStack(Blocks.DIRT), + new ItemStack(Blocks.DIRT) + }; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.LOG), + new ItemStack(Items.APPLE), + new ItemStack(Items.APPLE), + new ItemStack(Blocks.LOG) + }; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TileBog.java b/src/main/java/forestry/cultivation/tiles/TileBog.java new file mode 100644 index 000000000..ebcd6815a --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileBog.java @@ -0,0 +1,36 @@ +package forestry.cultivation.tiles; + +import net.minecraft.item.ItemStack; + +import forestry.core.ModuleCore; + +public class TileBog extends TilePlanter { + public TileBog() { + super("farmPeat"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[0]; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[]{ + new ItemStack(ModuleCore.getBlocks().bogEarth), + new ItemStack(ModuleCore.getBlocks().bogEarth), + new ItemStack(ModuleCore.getBlocks().bogEarth), + new ItemStack(ModuleCore.getBlocks().bogEarth) + }; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(ModuleCore.getItems().peat), + new ItemStack(ModuleCore.getItems().peat), + new ItemStack(ModuleCore.getItems().peat), + new ItemStack(ModuleCore.getItems().peat) + }; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java b/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java new file mode 100644 index 000000000..17a1a865b --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java @@ -0,0 +1,41 @@ +package forestry.cultivation.tiles; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class TileFarmCrops extends TilePlanter { + public TileFarmCrops() { + super("farmCrops"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[]{ + new ItemStack(Items.WHEAT_SEEDS), + new ItemStack(Items.POTATO), + new ItemStack(Items.CARROT), + new ItemStack(Items.BEETROOT_SEEDS) + }; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.DIRT), + new ItemStack(Blocks.DIRT), + new ItemStack(Blocks.DIRT), + new ItemStack(Blocks.DIRT) + }; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(Items.WHEAT), + new ItemStack(Items.POTATO), + new ItemStack(Items.CARROT), + new ItemStack(Items.BEETROOT) + }; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java b/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java new file mode 100644 index 000000000..19d63f6bb --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java @@ -0,0 +1,30 @@ +package forestry.cultivation.tiles; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +public class TileFarmGourd extends TilePlanter { + public TileFarmGourd() { + super("farmGourd"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[0]; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[0]; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.MELON_BLOCK), + new ItemStack(Blocks.PUMPKIN), + new ItemStack(Blocks.PUMPKIN), + new ItemStack(Blocks.MELON_BLOCK) + }; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java b/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java new file mode 100644 index 000000000..ecb696869 --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java @@ -0,0 +1,40 @@ +package forestry.cultivation.tiles; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; + +public class TileFarmMushroom extends TilePlanter { + public TileFarmMushroom() { + super("farmShroom"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.RED_MUSHROOM), + new ItemStack(Blocks.BROWN_MUSHROOM), + new ItemStack(Blocks.BROWN_MUSHROOM), + new ItemStack(Blocks.RED_MUSHROOM) + }; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.MYCELIUM), + new ItemStack(Blocks.DIRT, 1, 2), + new ItemStack(Blocks.DIRT, 1, 2), + new ItemStack(Blocks.MYCELIUM) + }; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.RED_MUSHROOM), + new ItemStack(Blocks.BROWN_MUSHROOM), + new ItemStack(Blocks.BROWN_MUSHROOM), + new ItemStack(Blocks.RED_MUSHROOM) + }; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmNether.java b/src/main/java/forestry/cultivation/tiles/TileFarmNether.java new file mode 100644 index 000000000..be6b651a4 --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileFarmNether.java @@ -0,0 +1,41 @@ +package forestry.cultivation.tiles; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class TileFarmNether extends TilePlanter { + public TileFarmNether() { + super("farmInfernal"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[]{ + new ItemStack(Items.NETHER_WART), + new ItemStack(Items.NETHER_WART), + new ItemStack(Items.NETHER_WART), + new ItemStack(Items.NETHER_WART) + }; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.SOUL_SAND), + new ItemStack(Blocks.SOUL_SAND), + new ItemStack(Blocks.SOUL_SAND), + new ItemStack(Blocks.SOUL_SAND) + }; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(Items.NETHER_WART), + new ItemStack(Items.NETHER_WART), + new ItemStack(Items.NETHER_WART), + new ItemStack(Items.NETHER_WART) + }; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TilePlantation.java b/src/main/java/forestry/cultivation/tiles/TilePlantation.java new file mode 100644 index 000000000..d0dfc9df1 --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TilePlantation.java @@ -0,0 +1,26 @@ +package forestry.cultivation.tiles; + +import net.minecraft.item.ItemStack; + +import forestry.api.farming.IFarmLogic; + +public class TilePlantation extends TilePlanter { + public TilePlantation(IFarmLogic logic) { + super(logic); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[0]; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[0]; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[0]; + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java new file mode 100644 index 000000000..88864b88c --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -0,0 +1,488 @@ +package forestry.cultivation.tiles; + +import javax.annotation.Nullable; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Stack; + +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; + +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import forestry.api.core.EnumHumidity; +import forestry.api.core.EnumTemperature; +import forestry.api.core.IErrorLogic; +import forestry.api.cultivation.IPlanterHousing; +import forestry.api.farming.FarmDirection; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInventory; +import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmable; +import forestry.core.config.Constants; +import forestry.core.errors.EnumErrorCode; +import forestry.core.fluids.FilteredTank; +import forestry.core.fluids.ITankManager; +import forestry.core.fluids.StandardTank; +import forestry.core.fluids.TankManager; +import forestry.core.network.IStreamableGui; +import forestry.core.network.PacketBufferForestry; +import forestry.core.owner.IOwnedTile; +import forestry.core.owner.IOwnerHandler; +import forestry.core.owner.OwnerHandler; +import forestry.core.tiles.IClimatised; +import forestry.core.tiles.ILiquidTankTile; +import forestry.core.tiles.TilePowered; +import forestry.core.utils.ClimateUtil; +import forestry.core.utils.PlayerUtil; +import forestry.core.utils.VectUtil; +import forestry.cultivation.gui.ContainerPlanter; +import forestry.cultivation.gui.GuiPlanter; +import forestry.cultivation.inventory.InventoryPlanter; +import forestry.farming.FarmHelper; +import forestry.farming.FarmHelper.FarmWorkStatus; +import forestry.farming.FarmHelper.Stage; +import forestry.farming.FarmRegistry; +import forestry.farming.FarmTarget; +import forestry.farming.gui.IFarmLedgerDelegate; +import forestry.farming.multiblock.FarmFertilizerManager; +import forestry.farming.multiblock.FarmHydrationManager; + +public abstract class TilePlanter extends TilePowered implements IFarmHousing, IPlanterHousing, IClimatised, ILiquidTankTile, IOwnedTile, IStreamableGui { + + private final static int ALLOWED_EXTENT = 4; + + private int platformHeight = -1; + private final Map> targets = new EnumMap<>(FarmDirection.class); + private final Stack pendingProduce = new Stack<>(); + private final List pendingCrops = new LinkedList<>(); + private final IFarmLogic logic; + private final FarmHydrationManager hydrationManager; + private final FarmFertilizerManager fertilizerManager; + private final InventoryPlanter inventory; + private final TankManager tankManager; + private final StandardTank resourceTank; + private final OwnerHandler ownerHandler = new OwnerHandler(); + private Stage stage = Stage.CULTIVATE; + @Nullable + private Vec3i offset; + @Nullable + private Vec3i area; + @Nullable + public Iterator areaIterator; + + public TilePlanter(String identifier) { + this(FarmRegistry.getInstance().getFarmLogic(identifier)); + } + + protected TilePlanter(IFarmLogic logic) { + super(150, 1500); + setInternalInventory(inventory = new InventoryPlanter(this)); + this.logic = logic; + this.hydrationManager = new FarmHydrationManager(this); + this.fertilizerManager = new FarmFertilizerManager(); + + this.resourceTank = new FilteredTank(Constants.PROCESSOR_TANK_CAPACITY).setFilters(FluidRegistry.WATER); + + this.tankManager = new TankManager(this, resourceTank); + setEnergyPerWorkCycle(10); + setTicksPerWorkCycle(2); + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound data) { + data = super.writeToNBT(data); + hydrationManager.writeToNBT(data); + tankManager.writeToNBT(data); + fertilizerManager.writeToNBT(data); + ownerHandler.writeToNBT(data); + return data; + } + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + hydrationManager.readFromNBT(data); + tankManager.readFromNBT(data); + fertilizerManager.readFromNBT(data); + ownerHandler.readFromNBT(data); + } + + @Override + public NBTTagCompound getUpdateTag() { + NBTTagCompound data = super.getUpdateTag(); + hydrationManager.writeToNBT(data); + tankManager.writeToNBT(data); + fertilizerManager.writeToNBT(data); + return data; + } + + @Override + public void writeGuiData(PacketBufferForestry data) { + tankManager.writeData(data); + hydrationManager.writeData(data); + fertilizerManager.writeData(data); + } + + @Override + public void readGuiData(PacketBufferForestry data) throws IOException { + tankManager.readData(data); + hydrationManager.readData(data); + fertilizerManager.readData(data); + } + + @Override + public IOwnerHandler getOwnerHandler() { + return ownerHandler; + } + + @Override + public void setPos(BlockPos posIn) { + super.setPos(posIn); + this.platformHeight = posIn.getY() - 2; + } + + @Override + public boolean hasWork() { + return true; + } + + @Override + public void invalidate() { + super.invalidate(); + targets.clear(); + } + + @Override + protected void updateServerSide() { + super.updateServerSide(); + hydrationManager.updateServer(world, getCoords()); + + if (updateOnInterval(20)) { + inventory.drainCan(tankManager); + } + } + + @Override + protected boolean workCycle() { + if (targets.isEmpty() || updateOnInterval(10)) { + setUpFarmlandTargets(); + } + IErrorLogic errorLogic = getErrorLogic(); + + boolean hasFertilizer = fertilizerManager.maintainFertilizer(inventory); + if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) { + return false; + } + + if (!pendingProduce.isEmpty()) { + boolean added = inventory.tryAddPendingProduce(pendingProduce); + errorLogic.setCondition(!added, EnumErrorCode.NO_SPACE_INVENTORY); + return added; + } + + // Cull queued crops. + if (!pendingCrops.isEmpty()) { + ICrop first = pendingCrops.get(0); + if (cullCrop(first)) { + pendingCrops.remove(0); + return true; + } else { + return false; + } + } + + // Cultivation and collection + FarmWorkStatus farmWorkStatus = new FarmWorkStatus(); + + List farmDirections = Arrays.asList(FarmDirection.values()); + Collections.shuffle(farmDirections, world.rand); + for (FarmDirection farmSide : farmDirections) { + IFarmLogic logic = getFarmLogic(farmSide); + + // Always try to collect windfall. + if (collectWindfall()) { + farmWorkStatus.didWork = true; + } + + List farmTargets = targets.get(farmSide); + + if (stage == Stage.HARVEST) { + Collection harvested = FarmHelper.harvestTargets(world, farmTargets, logic, Collections.emptySet()); + farmWorkStatus.didWork = !harvested.isEmpty(); + if (!harvested.isEmpty()) { + pendingCrops.addAll(harvested); + pendingCrops.sort(FarmHelper.TopDownICropComparator.INSTANCE); + } + } else if (stage == Stage.CULTIVATE) { + farmWorkStatus = cultivateTargets(farmWorkStatus, farmTargets, farmSide); + } + + if (farmWorkStatus.didWork) { + break; + } + } + + if (stage == Stage.CULTIVATE) { + errorLogic.setCondition(!farmWorkStatus.hasFarmland, EnumErrorCode.NO_FARMLAND); + errorLogic.setCondition(!farmWorkStatus.hasFertilizer, EnumErrorCode.NO_FERTILIZER); + errorLogic.setCondition(!farmWorkStatus.hasLiquid, EnumErrorCode.NO_LIQUID_FARM); + } + + // alternate between cultivation and harvest. + stage = stage.next(); + + return false; + } + + protected final BlockPos translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) { + return VectUtil.scale(farmDirection.getFacing().getDirectionVec(), step).add(pos); + } + + private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List farmTargets, FarmDirection farmSide) { + boolean hasFarmland = false; + for (FarmTarget target : farmTargets) { + if (target.getExtent() > 0) { + hasFarmland = true; + farmWorkStatus.hasFarmland = true; + break; + } + } + + if (hasFarmland && !FarmHelper.isCycleCanceledByListeners(logic, farmSide, Collections.emptySet())) { + final float hydrationModifier = hydrationManager.getHydrationModifier(); + final int fertilizerConsumption = logic.getFertilizerConsumption(); + final int liquidConsumption = logic.getWaterConsumption(hydrationModifier); + final FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption); + + for (FarmTarget target : farmTargets) { + // Check fertilizer and water + if (!fertilizerManager.hasFertilizer(inventory, fertilizerConsumption)) { + farmWorkStatus.hasFertilizer = false; + continue; + } + + if (liquid.amount > 0 && !hasLiquid(liquid)) { + farmWorkStatus.hasLiquid = false; + continue; + } + + if (FarmHelper.cultivateTarget(world, this, target, logic, Collections.emptySet())) { + // Remove fertilizer and water + fertilizerManager.removeFertilizer(inventory, fertilizerConsumption); + removeLiquid(liquid); + + farmWorkStatus.didWork = true; + } + } + } + + return farmWorkStatus; + } + + private boolean collectWindfall() { + NonNullList collected = logic.collect(world, this); + if (collected.isEmpty()) { + return false; + } + + for (ItemStack produce : collected) { + inventory.addProduce(produce); + pendingProduce.push(produce); + } + + return true; + } + + private boolean cullCrop(ICrop crop) { + final int fertilizerConsumption = logic.getFertilizerConsumption(); + + IErrorLogic errorLogic = getErrorLogic(); + + // Check fertilizer + Boolean hasFertilizer = fertilizerManager.hasFertilizer(inventory, fertilizerConsumption); + if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) { + return false; + } + + // Check water + float hydrationModifier = hydrationManager.getHydrationModifier(); + int waterConsumption = logic.getWaterConsumption(hydrationModifier); + FluidStack requiredLiquid = new FluidStack(FluidRegistry.WATER, waterConsumption); + boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid); + + if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_LIQUID_FARM)) { + return false; + } + + NonNullList harvested = crop.harvest(); + if (harvested != null) { + // Remove fertilizer and water + fertilizerManager.removeFertilizer(inventory, fertilizerConsumption); + removeLiquid(requiredLiquid); + + inventory.stowHarvest(harvested, pendingProduce); + } + return true; + } + + @Override + public int getStoredFertilizerScaled(int scale) { + return fertilizerManager.getStoredFertilizerScaled(inventory, scale); + } + + @Override + public boolean hasLiquid(FluidStack liquid) { + FluidStack drained = resourceTank.drainInternal(liquid, false); + return liquid.isFluidStackIdentical(drained); + } + + @Override + public GuiContainer getGui(EntityPlayer player, int data) { + return new GuiPlanter(this, player.inventory); + } + + @Override + public Container getContainer(EntityPlayer player, int data) { + return new ContainerPlanter(this, player.inventory); + } + + @Override + public boolean plantGermling(IFarmable germling, World world, BlockPos pos) { + EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner()); + return player != null && inventory.plantGermling(germling, player, pos); + } + + @Override + public boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction) { + EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner()); + return player != null && inventory.plantGermling(farmable, player, pos, direction); + } + + @Override + public IFarmInventory getFarmInventory() { + return inventory; + } + + @Override + public IFarmLogic getFarmLogic() { + return logic; + } + + @Override + public BlockPos getCoords() { + return pos; + } + + @Override + public Vec3i getOffset() { + if (offset == null) { + Vec3i area = getArea(); + offset = new Vec3i(-area.getX() / 2, -2, -area.getZ() / 2); + } + return offset; + } + + @Override + public Vec3i getArea() { + if (area == null) { + area = new Vec3i(7 + ALLOWED_EXTENT * 2, 13, 7 + ALLOWED_EXTENT * 2); + } + return area; + } + + @Override + public boolean doWork() { + return false; + } + + + @Override + public void removeLiquid(FluidStack liquid) { + resourceTank.drain(liquid.amount, true); + } + + @Override + public void setFarmLogic(FarmDirection direction, IFarmLogic logic) { + } + + @Override + public void resetFarmLogic(FarmDirection direction) { + } + + @Override + public IFarmLogic getFarmLogic(FarmDirection direction) { + return getFarmLogic(); + } + + public IFarmLedgerDelegate getFarmLedgerDelegate() { + return hydrationManager; + } + + @Override + public EnumTemperature getTemperature() { + return EnumTemperature.getFromValue(getExactTemperature()); + } + + @Override + public EnumHumidity getHumidity() { + return EnumHumidity.getFromValue(getExactHumidity()); + } + + @Override + public float getExactTemperature() { + BlockPos coords = getCoordinates(); + return ClimateUtil.getTemperature(getWorldObj(), coords); + } + + @Override + public float getExactHumidity() { + BlockPos coords = getCoordinates(); + return ClimateUtil.getHumidity(getWorldObj(), coords); + } + + @Override + public ITankManager getTankManager() { + return tankManager; + } + + @Override + public boolean isValidPlatform(World world, BlockPos pos) { + return pos.getY() == platformHeight; + } + + @Override + public boolean isSquare() { + return true; + } + + private void setUpFarmlandTargets() { + BlockPos targetStart = getCoords(); + + FarmHelper.createTargets(world, this, targets, targetStart, ALLOWED_EXTENT, 1, 1, pos, pos); + FarmHelper.setExtents(world, this, targets); + } + + public abstract ItemStack[] createGermlingStacks(); + + public abstract ItemStack[] createResourceStacks(); + + public abstract ItemStack[] createProductionStacks(); + +} diff --git a/src/main/java/forestry/cultivation/tiles/package-info.java b/src/main/java/forestry/cultivation/tiles/package-info.java new file mode 100644 index 000000000..451564e86 --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.tiles; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/farming/FarmHelper.java b/src/main/java/forestry/farming/FarmHelper.java index c951cff3e..0f69dd92e 100755 --- a/src/main/java/forestry/farming/FarmHelper.java +++ b/src/main/java/forestry/farming/FarmHelper.java @@ -12,15 +12,62 @@ package forestry.farming; import com.google.common.collect.ImmutableSet; +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import forestry.api.farming.FarmDirection; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmListener; +import forestry.api.farming.IFarmLogic; +import forestry.core.utils.TopDownBlockPosComparator; public class FarmHelper { + public enum Stage { + CULTIVATE, HARVEST; + + public Stage next() { + if (this == CULTIVATE) { + return HARVEST; + } else { + return CULTIVATE; + } + } + } + + public static class FarmWorkStatus { + public boolean didWork = false; + public boolean hasFarmland = false; + public boolean hasFertilizer = true; + public boolean hasLiquid = true; + } + + private static FarmDirection getLayoutDirection(FarmDirection farmSide) { + switch (farmSide) { + case NORTH: + return FarmDirection.WEST; + case WEST: + return FarmDirection.SOUTH; + case SOUTH: + return FarmDirection.EAST; + case EAST: + return FarmDirection.NORTH; + } + return null; + } + public static final ImmutableSet bricks = ImmutableSet.of( Blocks.BRICK_BLOCK, Blocks.STONEBRICK, @@ -38,7 +85,7 @@ public class FarmHelper { /** * @return the corner of the farm for the given side and layout. Returns null if the corner is not in a loaded chunk. */ - public static BlockPos getFarmMultiblockCorner(BlockPos start, FarmDirection farmSide, FarmDirection layoutDirection, BlockPos minFarmCoord, BlockPos maxFarmCoord) { + private static BlockPos getFarmMultiblockCorner(BlockPos start, FarmDirection farmSide, FarmDirection layoutDirection, BlockPos minFarmCoord, BlockPos maxFarmCoord) { BlockPos edge = getFarmMultiblockEdge(start, farmSide, maxFarmCoord, minFarmCoord); return getFarmMultiblockEdge(edge, getOpposite(layoutDirection), maxFarmCoord, minFarmCoord); } @@ -60,4 +107,137 @@ public class FarmHelper { throw new IllegalArgumentException("Invalid farm direction: " + direction); } } + + public static void createTargets(World world, IFarmHousing farmHousing, Map> targets, BlockPos targetStart, final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest, BlockPos minFarmCoord, BlockPos maxFarmCoord) { + for (FarmDirection farmSide : FarmDirection.values()) { + + final int farmWidth; + if (farmSide == FarmDirection.NORTH || farmSide == FarmDirection.SOUTH) { + farmWidth = farmSizeEastWest; + } else { + farmWidth = farmSizeNorthSouth; + } + + // targets extend sideways in a pinwheel pattern around the farm, so they need to go a little extra distance + final int targetMaxLimit = allowedExtent + farmWidth; + + FarmDirection layoutDirection = getLayoutDirection(farmSide); + + List farmSideTargets = new ArrayList<>(); + targets.put(farmSide, farmSideTargets); + + BlockPos targetLocation = FarmHelper.getFarmMultiblockCorner(targetStart, farmSide, layoutDirection, minFarmCoord, maxFarmCoord); + BlockPos firstLocation = targetLocation.offset(farmSide.getFacing()); + BlockPos firstGroundPosition = getGroundPosition(world, farmHousing, firstLocation); + if (firstGroundPosition != null) { + int groundHeight = firstGroundPosition.getY(); + + for (int i = 0; i < allowedExtent; i++) { + targetLocation = targetLocation.offset(farmSide.getFacing()); + BlockPos groundLocation = new BlockPos(targetLocation.getX(), groundHeight, targetLocation.getZ()); + + if (!world.isBlockLoaded(groundLocation)) { + break; + } + + if (!farmHousing.isValidPlatform(world, groundLocation)) { + break; + } + + int targetLimit = targetMaxLimit; + if (!farmHousing.isSquare()) { + targetLimit = targetMaxLimit - i - 1; + } + + FarmTarget target = new FarmTarget(targetLocation, layoutDirection, targetLimit); + farmSideTargets.add(target); + } + } + } + } + + @Nullable + private static BlockPos getGroundPosition(World world, IFarmHousing farmHousing, BlockPos targetPosition) { + if (!world.isBlockLoaded(targetPosition)) { + return null; + } + + for (int yOffset = 2; yOffset > -4; yOffset--) { + BlockPos position = targetPosition.add(0, yOffset, 0); + if (farmHousing.isValidPlatform(world, position)) { + return position; + } + } + + return null; + } + + public static boolean isCycleCanceledByListeners(IFarmLogic logic, FarmDirection direction, Iterable farmListeners) { + for (IFarmListener listener : farmListeners) { + if (listener.cancelTask(logic, direction)) { + return true; + } + } + return false; + } + + public static void setExtents(World world, IFarmHousing farmHousing, Map> targets) { + for (List targetsList : targets.values()) { + if (!targetsList.isEmpty()) { + BlockPos groundPosition = getGroundPosition(world, farmHousing, targetsList.get(0).getStart()); + + for (FarmTarget target : targetsList) { + target.setExtentAndYOffset(world, groundPosition, farmHousing); + } + } + } + } + + public static boolean cultivateTarget(World world, IFarmHousing farmHousing, FarmTarget target, IFarmLogic logic, Iterable farmListeners) { + BlockPos targetPosition = target.getStart().add(0, target.getYOffset(), 0); + if (logic.cultivate(world, farmHousing, targetPosition, target.getDirection(), target.getExtent())) { + for (IFarmListener listener : farmListeners) { + listener.hasCultivated(logic, targetPosition, target.getDirection(), target.getExtent()); + } + return true; + } + + return false; + } + + public static Collection harvestTargets(World world, List farmTargets, IFarmLogic logic, Iterable farmListeners) { + for (FarmTarget target : farmTargets) { + Collection harvested = harvestTarget(world, target, logic, farmListeners); + if (!harvested.isEmpty()) { + return harvested; + } + } + + return Collections.emptyList(); + } + + public static Collection harvestTarget(World world, FarmTarget target, IFarmLogic logic, Iterable farmListeners) { + BlockPos pos = target.getStart().add(0, target.getYOffset(), 0); + Collection harvested = logic.harvest(world, pos, target.getDirection(), target.getExtent()); + if (!harvested.isEmpty()) { + // Let event handlers know. + for (IFarmListener listener : farmListeners) { + listener.hasScheduledHarvest(harvested, logic, pos, target.getDirection(), target.getExtent()); + } + } + return harvested; + } + + public static class TopDownICropComparator implements Comparator { + public static final TopDownICropComparator INSTANCE = new TopDownICropComparator(); + + private TopDownICropComparator() { + + } + + @Override + public int compare(ICrop o1, ICrop o2) { + return TopDownBlockPosComparator.INSTANCE.compare(o1.getPosition(), o2.getPosition()); + } + } } diff --git a/src/main/java/forestry/farming/FarmTarget.java b/src/main/java/forestry/farming/FarmTarget.java index 1b37e3e05..223a2b185 100755 --- a/src/main/java/forestry/farming/FarmTarget.java +++ b/src/main/java/forestry/farming/FarmTarget.java @@ -12,11 +12,11 @@ package forestry.farming; import javax.annotation.Nullable; -import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; +import forestry.api.farming.IFarmHousing; public class FarmTarget { @@ -49,7 +49,7 @@ public class FarmTarget { return direction; } - public void setExtentAndYOffset(World world, @Nullable BlockPos platformPosition) { + public void setExtentAndYOffset(World world, @Nullable BlockPos platformPosition, IFarmHousing housing) { if (platformPosition == null) { extent = 0; return; @@ -60,8 +60,7 @@ public class FarmTarget { if (!world.isBlockLoaded(position)) { break; } - IBlockState blockState = world.getBlockState(position); - if (!FarmHelper.bricks.contains(blockState.getBlock())) { + if (!housing.isValidPlatform(world, position)) { break; } position.move(getDirection().getFacing()); diff --git a/src/main/java/forestry/farming/ModuleFarming.java b/src/main/java/forestry/farming/ModuleFarming.java index a52f4e4d0..352d7c6a5 100644 --- a/src/main/java/forestry/farming/ModuleFarming.java +++ b/src/main/java/forestry/farming/ModuleFarming.java @@ -59,8 +59,8 @@ import forestry.farming.blocks.BlockRegistryFarming; import forestry.farming.blocks.EnumFarmBlockType; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicArboreal; -import forestry.farming.logic.FarmLogicCereal; import forestry.farming.logic.FarmLogicCocoa; +import forestry.farming.logic.FarmLogicCrops; import forestry.farming.logic.FarmLogicGourd; import forestry.farming.logic.FarmLogicInfernal; import forestry.farming.logic.FarmLogicMushroom; @@ -68,13 +68,12 @@ import forestry.farming.logic.FarmLogicOrchard; import forestry.farming.logic.FarmLogicPeat; import forestry.farming.logic.FarmLogicReeds; import forestry.farming.logic.FarmLogicSucculent; -import forestry.farming.logic.FarmLogicVegetable; -import forestry.farming.logic.FarmableAgingCrop; -import forestry.farming.logic.FarmableGE; -import forestry.farming.logic.FarmableGourd; -import forestry.farming.logic.FarmableStacked; -import forestry.farming.logic.FarmableVanillaMushroom; -import forestry.farming.logic.FarmableVanillaSapling; +import forestry.farming.logic.farmables.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableGE; +import forestry.farming.logic.farmables.FarmableGourd; +import forestry.farming.logic.farmables.FarmableStacked; +import forestry.farming.logic.farmables.FarmableVanillaMushroom; +import forestry.farming.logic.farmables.FarmableVanillaSapling; import forestry.farming.models.EnumFarmBlockTexture; import forestry.farming.proxy.ProxyFarming; import forestry.farming.tiles.TileFarmControl; @@ -129,7 +128,7 @@ public class ModuleFarming extends BlankForestryModule { registry.registerFarmables("farmArboreal", new FarmableGE()); } - registry.registerFarmables("farmOrchard", + registry.registerFarmables("farmCrops", new FarmableAgingCrop(new ItemStack(Items.WHEAT_SEEDS), Blocks.WHEAT, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.POTATO), Blocks.POTATOES, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.CARROT), Blocks.CARROTS, BlockCrops.AGE, 7, 0), @@ -141,8 +140,6 @@ public class ModuleFarming extends BlankForestryModule { IBlockState plantedRedMushroom = blocks.mushroom.getDefaultState().withProperty(BlockMushroom.VARIANT, BlockMushroom.MushroomType.RED); registry.registerFarmables("farmShroom", new FarmableVanillaMushroom(new ItemStack(Blocks.RED_MUSHROOM), plantedRedMushroom, Blocks.RED_MUSHROOM_BLOCK)); - registry.registerFarmables("farmWheat", new FarmableAgingCrop(new ItemStack(Items.WHEAT_SEEDS), Blocks.WHEAT, BlockCrops.AGE, 7)); - registry.registerFarmables("farmGourd", new FarmableGourd(new ItemStack(Items.PUMPKIN_SEEDS), Blocks.PUMPKIN_STEM, Blocks.PUMPKIN)); registry.registerFarmables("farmGourd", new FarmableGourd(new ItemStack(Items.MELON_SEEDS), Blocks.MELON_STEM, Blocks.MELON_BLOCK)); @@ -152,10 +149,6 @@ public class ModuleFarming extends BlankForestryModule { registry.registerFarmables("farmSucculentes", new FarmableStacked(new ItemStack(Blocks.CACTUS), Blocks.CACTUS, 3)); - registry.registerFarmables("farmVegetables", new FarmableAgingCrop(new ItemStack(Items.POTATO), Blocks.POTATOES, BlockCrops.AGE, 7)); - registry.registerFarmables("farmVegetables", new FarmableAgingCrop(new ItemStack(Items.CARROT), Blocks.CARROTS, BlockCrops.AGE, 7)); - registry.registerFarmables("farmVegetables", new FarmableAgingCrop(new ItemStack(Items.BEETROOT_SEEDS), Blocks.BEETROOTS, BlockBeetroot.BEETROOT_AGE, 3)); - //Forestry fertilizer registry.registerFertilizer(new ItemStack(coreItems.fertilizerCompound, 1, OreDictionary.WILDCARD_VALUE), 500); @@ -191,14 +184,12 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmArborealManaged = new CircuitFarmLogic("managedArboreal", new FarmLogicArboreal()); Circuits.farmShroomManaged = new CircuitFarmLogic("managedShroom", new FarmLogicMushroom()); Circuits.farmPeatManaged = new CircuitFarmLogic("managedPeat", new FarmLogicPeat()); - Circuits.farmCerealManaged = new CircuitFarmLogic("managedCereal", new FarmLogicCereal()); - Circuits.farmVegetableManaged = new CircuitFarmLogic("managedVegetable", new FarmLogicVegetable()); + Circuits.farmCropsManaged = new CircuitFarmLogic("managedCrops", new FarmLogicCrops()); Circuits.farmInfernalManaged = new CircuitFarmLogic("managedInfernal", new FarmLogicInfernal()); Circuits.farmPeatManual = new CircuitFarmLogic("manualPeat", new FarmLogicPeat()).setManual(); Circuits.farmShroomManual = new CircuitFarmLogic("manualShroom", new FarmLogicMushroom()).setManual(); - Circuits.farmCerealManual = new CircuitFarmLogic("manualCereal", new FarmLogicCereal()).setManual(); - Circuits.farmVegetableManual = new CircuitFarmLogic("manualVegetable", new FarmLogicVegetable()).setManual(); + Circuits.farmCropsManual = new CircuitFarmLogic("manualCrops", new FarmLogicCrops()).setManual(); Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", new FarmLogicSucculent()).setManual(); Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", new FarmLogicReeds()).setManual(); Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", new FarmLogicGourd()).setManual(); @@ -209,9 +200,10 @@ public class ModuleFarming extends BlankForestryModule { // Make Forestry farming logics accessible to plugins via FarmRegistry FarmRegistry.getInstance().registerFarmLogic("farmArboreal",((CircuitFarmLogic)Circuits.farmArborealManaged).getFarmLogic()); FarmRegistry.getInstance().registerFarmLogic("farmShroom",((CircuitFarmLogic)Circuits.farmShroomManaged).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmWheat",((CircuitFarmLogic)Circuits.farmCerealManaged).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmVegetables",((CircuitFarmLogic)Circuits.farmVegetableManaged).getFarmLogic()); + FarmRegistry.getInstance().registerFarmLogic("farmCrops",((CircuitFarmLogic)Circuits.farmCropsManaged).getFarmLogic()); FarmRegistry.getInstance().registerFarmLogic("farmInfernal",((CircuitFarmLogic)Circuits.farmInfernalManaged).getFarmLogic()); + FarmRegistry.getInstance().registerFarmLogic("farmGourd", ((CircuitFarmLogic)Circuits.farmGourdManual).getFarmLogic()); + FarmRegistry.getInstance().registerFarmLogic("farmPeat", ((CircuitFarmLogic)Circuits.farmPeatManaged).getFarmLogic()); } @Override @@ -277,15 +269,13 @@ public class ModuleFarming extends BlankForestryModule { ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmArborealManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPeatManaged); - ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCerealManaged); - ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuits.farmVegetableManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCropsManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.BLAZE, 1), Circuits.farmInfernalManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.APATITE, 1), Circuits.farmShroomManaged); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmOrchardManual); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPeatManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCerealManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.IRON, 1), Circuits.farmVegetableManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCropsManual); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.GOLD, 1), Circuits.farmSucculentManual); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.DIAMOND, 1), Circuits.farmPoalesManual); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.OBSIDIAN, 1), Circuits.farmGourdManual); diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index b5318b478..23c3c9931 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -118,6 +118,11 @@ public abstract class FarmLogic implements IFarmLogic { } } + @Override + public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { + // do nothing as soil is not managed by farm + } + // for debugging @Override public String toString() { diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 6d6da69bc..29645131e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -145,17 +145,17 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { BlockPos soilPosition = position.down(); IBlockState soilState = world.getBlockState(soilPosition); if (isAcceptedSoil(soilState)) { - return plantSapling(world, farmHousing, position); + return plantSapling(world, farmHousing, position, direction); } } } return false; } - private boolean plantSapling(World world, IFarmHousing farmHousing, BlockPos position) { + private boolean plantSapling(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction) { Collections.shuffle(farmables); for (IFarmable candidate : farmables) { - if (farmHousing.plantGermling(candidate, world, position)) { + if (farmHousing.plantGermling(candidate, world, position, direction)) { return true; } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCereal.java b/src/main/java/forestry/farming/logic/FarmLogicCereal.java deleted file mode 100755 index 3d148d0f3..000000000 --- a/src/main/java/forestry/farming/logic/FarmLogicCereal.java +++ /dev/null @@ -1,37 +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.farming.logic; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import forestry.api.core.ForestryAPI; - -public class FarmLogicCereal extends FarmLogicCrops { - - public FarmLogicCereal() { - super(ForestryAPI.farmRegistry.getFarmables("farmWheat")); - } - - @Override - public String getName() { - if (isManual) { - return "Manual Farm"; - } else { - return "Managed Farm"; - } - } - - @Override - public ItemStack getIconItemStack() { - return new ItemStack(Items.WHEAT); - } -} diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 6d9b743bd..5e816d77f 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -35,6 +35,7 @@ import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; +import forestry.farming.logic.farmables.FarmableCocoa; public class FarmLogicCocoa extends FarmLogic { private final IFarmable cocoa = new FarmableCocoa(); @@ -73,11 +74,6 @@ public class FarmLogicCocoa extends FarmLogic { public boolean isAcceptedWindfall(ItemStack stack) { return false; } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - // do nothing as soil is not managed by farm - } @Override public NonNullList collect(World world, IFarmHousing farmHousing) { @@ -88,7 +84,6 @@ public class FarmLogicCocoa extends FarmLogic { @Override public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - if (!lastExtentsCultivation.containsKey(pos)) { lastExtentsCultivation.put(pos, 0); } @@ -99,7 +94,7 @@ public class FarmLogicCocoa extends FarmLogic { } BlockPos position = translateWithOffset(pos.up(), direction, lastExtent); - boolean result = tryPlantingCocoa(world, farmHousing, position); + boolean result = tryPlantingCocoa(world, farmHousing, position, direction); lastExtent++; lastExtentsCultivation.put(pos, lastExtent); @@ -128,14 +123,14 @@ public class FarmLogicCocoa extends FarmLogic { return crops; } - private boolean tryPlantingCocoa(World world, IFarmHousing farmHousing, BlockPos position) { + private boolean tryPlantingCocoa(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection farmDirection) { BlockPos.MutableBlockPos current = new BlockPos.MutableBlockPos(position); IBlockState blockState = world.getBlockState(current); while (isJungleTreeTrunk(blockState)) { for (EnumFacing direction : EnumFacing.HORIZONTALS) { BlockPos candidate = new BlockPos(current.getX() + direction.getFrontOffsetX(), current.getY(), current.getZ() + direction.getFrontOffsetZ()); if (world.isAirBlock(candidate)) { - return farmHousing.plantGermling(cocoa, world, candidate); + return farmHousing.plantGermling(cocoa, world, candidate, farmDirection); } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 3e77448cf..bf0678a9c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -15,6 +15,7 @@ import java.util.Stack; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; @@ -25,10 +26,15 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; +import forestry.farming.FarmRegistry; -public abstract class FarmLogicCrops extends FarmLogicWatered { +public class FarmLogicCrops extends FarmLogicWatered { private final Iterable seeds; + public FarmLogicCrops() { + this(FarmRegistry.getInstance().getFarmables("farmCrops")); + } + protected FarmLogicCrops(Iterable seeds) { super(new ItemStack(Blocks.DIRT), Blocks.FARMLAND.getDefaultState()); @@ -78,16 +84,16 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { IBlockState groundState = world.getBlockState(position.down()); if (isAcceptedGround(groundState)) { - return trySetCrop(world, farmHousing, position); + return trySetCrop(world, farmHousing, position, direction); } } return false; } - private boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position) { + private boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction) { for (IFarmable candidate : seeds) { - if (farmHousing.plantGermling(candidate, world, position)) { + if (farmHousing.plantGermling(candidate, world, position, direction)) { return true; } } @@ -112,4 +118,18 @@ public abstract class FarmLogicCrops extends FarmLogicWatered { return crops; } + @Override + public ItemStack getIconItemStack() { + return new ItemStack(Items.WHEAT); + } + + @Override + public String getName() { + if (isManual) { + return "Manual Crop Farm"; + } else { + return "Managed Crop Farm"; + } + } + } diff --git a/src/main/java/forestry/farming/logic/FarmLogicExU.java b/src/main/java/forestry/farming/logic/FarmLogicExU.java index 92cac7a94..84b0fd1bd 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicExU.java +++ b/src/main/java/forestry/farming/logic/FarmLogicExU.java @@ -13,21 +13,21 @@ package forestry.farming.logic; import java.util.Collection; import java.util.Stack; -import forestry.farming.FarmRegistry; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; +import forestry.farming.FarmRegistry; public class FarmLogicExU extends FarmLogicHomogeneous { @@ -102,17 +102,7 @@ public class FarmLogicExU extends FarmLogicHomogeneous { continue; } - return trySetCrop(world, farmHousing, position); - } - - return false; - } - - private boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position) { - for (IFarmable candidate : farmables) { - if (farmHousing.plantGermling(candidate, world, position)) { - return true; - } + return trySetCrop(world, farmHousing, position, direction); } return false; diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index ce62f72a6..ede28bc10 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -96,10 +96,4 @@ public class FarmLogicGourd extends FarmLogic { } return crops; } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - // do nothing as soil is not managed by farm - - } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index 0bee068ea..f719d1690 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -13,11 +13,7 @@ package forestry.farming.logic; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import forestry.api.farming.FarmDirection; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; -import forestry.farming.FarmHelper; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; @@ -25,9 +21,12 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public abstract class FarmLogicHomogeneous extends FarmLogic { +import forestry.api.farming.FarmDirection; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; - private final List soils = new ArrayList<>(); +public abstract class FarmLogicHomogeneous extends FarmLogicSoil { protected final List farmables; protected NonNullList produce = NonNullList.create(); @@ -36,10 +35,6 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { addSoil(resource, soilState, false); this.farmables = new ArrayList<>(farmables); } - - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){ - soils.add(new Soil(resource, soilState, hasMetaData)); - } protected boolean isAcceptedSoil(IBlockState blockState) { for(Soil soil : soils){ @@ -86,6 +81,26 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { return false; } + protected boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction, boolean shuffle) { + for (IFarmable candidate : farmables) { + if (farmHousing.plantGermling(candidate, world, position, direction)) { + return true; + } + } + + return false; + } + + protected boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction) { + for (IFarmable candidate : farmables) { + if (farmHousing.plantGermling(candidate, world, position, direction)) { + return true; + } + } + + return false; + } + @Override public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { return maintainSoil(world, farmHousing, pos, direction, extent) || @@ -104,7 +119,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { BlockPos position = translateWithOffset(pos, direction, i); IBlockState soilState = world.getBlockState(position); - if (FarmHelper.bricks.contains(soilState.getBlock())) { + if (farmHousing.isValidPlatform(world, pos)) { break; } @@ -113,8 +128,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogic { } BlockPos platformPosition = position.down(); - IBlockState platformState = world.getBlockState(platformPosition); - if (!FarmHelper.bricks.contains(platformState.getBlock())) { + if (!farmHousing.isValidPlatform(world, platformPosition)) { break; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index ada4a287f..c84476578 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -90,17 +90,7 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { BlockPos soilPosition = position.down(); IBlockState soilState = world.getBlockState(soilPosition); if (isAcceptedSoil(soilState)) { - return trySetCrop(world, farmHousing, position); - } - } - - return false; - } - - private boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position) { - for (IFarmable candidate : farmables) { - if (farmHousing.plantGermling(candidate, world, position)) { - return true; + return trySetCrop(world, farmHousing, position, direction); } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 3d486f326..cb8501bb1 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -36,6 +36,7 @@ import forestry.api.farming.IFarmable; import forestry.api.genetics.IFruitBearer; import forestry.core.ModuleCore; import forestry.core.tiles.TileUtil; +import forestry.farming.logic.crops.CropFruit; public class FarmLogicOrchard extends FarmLogic { @@ -105,7 +106,6 @@ public class FarmLogicOrchard extends FarmLogic { @Override public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - if (!lastExtents.containsKey(pos)) { lastExtents.put(pos, 0); } @@ -132,11 +132,6 @@ public class FarmLogicOrchard extends FarmLogic { public String getName() { return "Orchard"; } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - // do nothing as soil is not managed by farm - } private Collection getHarvestBlocks(World world, BlockPos position) { Set seen = new HashSet<>(); @@ -235,7 +230,6 @@ public class FarmLogicOrchard extends FarmLogic { @Nullable private ICrop getCrop(World world, BlockPos position) { - IFruitBearer fruitBearer = TileUtil.getTile(world, position, IFruitBearer.class); if (fruitBearer != null) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 1bf4022eb..85c4bef7a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -23,6 +23,7 @@ import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.core.ModuleCore; import forestry.core.blocks.BlockBogEarth; +import forestry.farming.logic.crops.CropPeat; public class FarmLogicPeat extends FarmLogicWatered { private static final ItemStack bogEarth = ModuleCore.getBlocks().bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 1); diff --git a/src/main/java/forestry/farming/logic/FarmLogicReeds.java b/src/main/java/forestry/farming/logic/FarmLogicReeds.java index 986a72cca..cc32c662b 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicReeds.java +++ b/src/main/java/forestry/farming/logic/FarmLogicReeds.java @@ -10,16 +10,9 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; import java.util.Collection; import java.util.Stack; -import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.core.utils.ItemStackUtil; -import forestry.farming.FarmRegistry; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -27,23 +20,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmable; import forestry.farming.FarmRegistry; -import forestry.api.core.ForestryAPI; -import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.core.utils.ItemStackUtil; - -public class FarmLogicReeds extends FarmLogic { - +public class FarmLogicReeds extends FarmLogicSoil { private final Collection germlings = FarmRegistry.getInstance().getFarmables("farmPoales"); - private ArrayList soils = new ArrayList<>(); public FarmLogicReeds() { @@ -65,11 +50,6 @@ public class FarmLogicReeds extends FarmLogic { } } - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - this.soils.add(new Soil(resource,soilState,hasMetaData)); - } - @Override public int getFertilizerConsumption() { return 10; diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 3e9cb8df0..66da5f732 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -27,6 +27,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; +import forestry.farming.logic.crops.CropRubber; import forestry.plugins.PluginIC2; public class FarmLogicRubber extends FarmLogic { @@ -130,10 +131,5 @@ public class FarmLogicRubber extends FarmLogic { return crops; } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - // do nothing as soil is not managed by farm - } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSoil.java b/src/main/java/forestry/farming/logic/FarmLogicSoil.java new file mode 100644 index 000000000..d58e1f53c --- /dev/null +++ b/src/main/java/forestry/farming/logic/FarmLogicSoil.java @@ -0,0 +1,20 @@ +package forestry.farming.logic; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +public abstract class FarmLogicSoil extends FarmLogic { + protected final Set soils = new HashSet<>(); + + public FarmLogicSoil() { + } + + @Override + public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { + soils.add(new Soil(resource,soilState,hasMetaData)); + } + +} diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index e53b76870..560162033 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; import java.util.Collection; import java.util.Stack; @@ -21,6 +20,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; @@ -28,10 +28,8 @@ import forestry.api.farming.IFarmable; import forestry.core.utils.ItemStackUtil; import forestry.farming.FarmRegistry; -public class FarmLogicSucculent extends FarmLogic { - +public class FarmLogicSucculent extends FarmLogicSoil { private final Collection germlings = FarmRegistry.getInstance().getFarmables("farmSucculentes"); - private ArrayList soils = new ArrayList<>(); public FarmLogicSucculent() { addSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); @@ -50,11 +48,6 @@ public class FarmLogicSucculent extends FarmLogic { return "Managed Succulent Farm"; } } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - this.soils.add(new Soil(resource,soilState,hasMetaData)); - } @Override public int getFertilizerConsumption() { diff --git a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java b/src/main/java/forestry/farming/logic/FarmLogicVegetable.java deleted file mode 100755 index 7a7fda24f..000000000 --- a/src/main/java/forestry/farming/logic/FarmLogicVegetable.java +++ /dev/null @@ -1,38 +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.farming.logic; - -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import forestry.farming.FarmRegistry; - -public class FarmLogicVegetable extends FarmLogicCrops { - - public FarmLogicVegetable() { - super(FarmRegistry.getInstance().getFarmables("farmVegetables")); - } - - @Override - public ItemStack getIconItemStack() { - return new ItemStack(Items.CARROT); - } - - @Override - public String getName() { - if (isManual) { - return "Manual Vegetable Farm"; - } else { - return "Managed Vegetable Farm"; - } - } - -} diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 7102a54b0..e7143f186 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -10,9 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -20,19 +17,16 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; + import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; + import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; import forestry.core.utils.BlockUtil; -import forestry.farming.FarmHelper; -public abstract class FarmLogicWatered extends FarmLogic { - - - private final List soils = new ArrayList<>(); - +public abstract class FarmLogicWatered extends FarmLogicSoil { private static final FluidStack STACK_WATER = new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME); protected NonNullList produce = NonNullList.create(); @@ -40,11 +34,6 @@ public abstract class FarmLogicWatered extends FarmLogic { protected FarmLogicWatered(ItemStack resource, IBlockState ground) { addSoil(resource,ground,false); } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - soils.add(new Soil(resource,soilState,hasMetaData)); - } @Override public int getFertilizerConsumption() { @@ -99,11 +88,8 @@ public abstract class FarmLogicWatered extends FarmLogic { return true; } - if (maintainCrops(world, farmHousing, pos.up(), direction, extent)) { - return true; - } + return maintainCrops(world, farmHousing, pos.up(), direction, extent); - return false; } private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { @@ -119,8 +105,7 @@ public abstract class FarmLogicWatered extends FarmLogic { } BlockPos platformPosition = position.down(); - IBlockState blockState = world.getBlockState(platformPosition); - if (!FarmHelper.bricks.contains(blockState.getBlock())) { + if (!farmHousing.isValidPlatform(world, platformPosition)) { break; } @@ -149,8 +134,7 @@ public abstract class FarmLogicWatered extends FarmLogic { BlockPos position = translateWithOffset(pos, direction, i); BlockPos platformPosition = position.down(); - IBlockState blockState = world.getBlockState(platformPosition); - if (!FarmHelper.bricks.contains(blockState.getBlock())) { + if (!farmHousing.isValidPlatform(world, platformPosition)) { break; } diff --git a/src/main/java/forestry/farming/logic/Crop.java b/src/main/java/forestry/farming/logic/crops/Crop.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/forestry/farming/logic/Crop.java rename to src/main/java/forestry/farming/logic/crops/Crop.java index fc2e1636a..9cb0ba818 --- a/src/main/java/forestry/farming/logic/Crop.java +++ b/src/main/java/forestry/farming/logic/crops/Crop.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; import javax.annotation.Nullable; diff --git a/src/main/java/forestry/farming/logic/CropBasicAgriCraft.java b/src/main/java/forestry/farming/logic/crops/CropBasicAgriCraft.java similarity index 98% rename from src/main/java/forestry/farming/logic/CropBasicAgriCraft.java rename to src/main/java/forestry/farming/logic/crops/CropBasicAgriCraft.java index b17359173..6ec4cf8ef 100644 --- a/src/main/java/forestry/farming/logic/CropBasicAgriCraft.java +++ b/src/main/java/forestry/farming/logic/crops/CropBasicAgriCraft.java @@ -8,9 +8,8 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; -import forestry.core.utils.BlockUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; @@ -18,6 +17,8 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.core.utils.BlockUtil; + public class CropBasicAgriCraft extends Crop { private final IBlockState blockState; diff --git a/src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java b/src/main/java/forestry/farming/logic/crops/CropBasicGrowthCraft.java similarity index 98% rename from src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java rename to src/main/java/forestry/farming/logic/crops/CropBasicGrowthCraft.java index 811d54d70..59b2401cc 100644 --- a/src/main/java/forestry/farming/logic/CropBasicGrowthCraft.java +++ b/src/main/java/forestry/farming/logic/crops/CropBasicGrowthCraft.java @@ -8,11 +8,8 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; -import forestry.core.config.Constants; -import forestry.core.network.packets.PacketFXSignal; -import forestry.core.utils.NetworkUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; @@ -20,6 +17,10 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.core.config.Constants; +import forestry.core.network.packets.PacketFXSignal; +import forestry.core.utils.NetworkUtil; + public class CropBasicGrowthCraft extends Crop { private final IBlockState blockState; diff --git a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java similarity index 95% rename from src/main/java/forestry/farming/logic/CropBasicIC2Crop.java rename to src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java index 64cc5315e..ba5444119 100644 --- a/src/main/java/forestry/farming/logic/CropBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java @@ -1,4 +1,4 @@ -package forestry.farming.logic; +package forestry.farming.logic.crops; import javax.annotation.Nonnull; @@ -12,7 +12,6 @@ import net.minecraft.world.World; import net.minecraftforge.fml.common.Optional; import forestry.plugins.PluginIC2; - import ic2.api.crops.ICropTile; public class CropBasicIC2Crop extends Crop { @@ -40,10 +39,7 @@ public class CropBasicIC2Crop extends Crop { */ @Optional.Method(modid = PluginIC2.modId) public static boolean isIC2Crop(TileEntity tileEntity) { - if (tileEntity instanceof ICropTile) { - return true; - } - return false; + return tileEntity instanceof ICropTile; } /** diff --git a/src/main/java/forestry/farming/logic/CropDestroy.java b/src/main/java/forestry/farming/logic/crops/CropDestroy.java similarity index 98% rename from src/main/java/forestry/farming/logic/CropDestroy.java rename to src/main/java/forestry/farming/logic/crops/CropDestroy.java index 96f30285b..bd9d68263 100644 --- a/src/main/java/forestry/farming/logic/CropDestroy.java +++ b/src/main/java/forestry/farming/logic/crops/CropDestroy.java @@ -8,13 +8,10 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; import javax.annotation.Nullable; -import forestry.core.config.Constants; -import forestry.core.network.packets.PacketFXSignal; -import forestry.core.utils.NetworkUtil; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; @@ -22,6 +19,10 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.core.config.Constants; +import forestry.core.network.packets.PacketFXSignal; +import forestry.core.utils.NetworkUtil; + public class CropDestroy extends Crop { protected final IBlockState blockState; diff --git a/src/main/java/forestry/farming/logic/CropDestroyDouble.java b/src/main/java/forestry/farming/logic/crops/CropDestroyDouble.java similarity index 91% rename from src/main/java/forestry/farming/logic/CropDestroyDouble.java rename to src/main/java/forestry/farming/logic/crops/CropDestroyDouble.java index d8a21ff52..fea34f0ae 100644 --- a/src/main/java/forestry/farming/logic/CropDestroyDouble.java +++ b/src/main/java/forestry/farming/logic/crops/CropDestroyDouble.java @@ -1,4 +1,4 @@ -package forestry.farming.logic; +package forestry.farming.logic.crops; import javax.annotation.Nullable; @@ -37,8 +37,8 @@ public class CropDestroyDouble extends Crop { Block block = blockState.getBlock(); Block blockUp = blockStateUp.getBlock(); NonNullList harvested = NonNullList.create(); - harvested.addAll(block.getDrops(world, pos, blockState, 0)); - harvested.addAll(blockUp.getDrops(world, pos.up(), blockStateUp, 0)); + block.getDrops(harvested, world, pos, blockState, 0); + blockUp.getDrops(harvested, world, pos.up(), blockStateUp, 0); PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState); NetworkUtil.sendNetworkPacket(packet, pos, world); diff --git a/src/main/java/forestry/farming/logic/CropFruit.java b/src/main/java/forestry/farming/logic/crops/CropFruit.java old mode 100755 new mode 100644 similarity index 97% rename from src/main/java/forestry/farming/logic/CropFruit.java rename to src/main/java/forestry/farming/logic/crops/CropFruit.java index 880cee929..27304ce1d --- a/src/main/java/forestry/farming/logic/CropFruit.java +++ b/src/main/java/forestry/farming/logic/crops/CropFruit.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; diff --git a/src/main/java/forestry/farming/logic/CropPeat.java b/src/main/java/forestry/farming/logic/crops/CropPeat.java old mode 100755 new mode 100644 similarity index 98% rename from src/main/java/forestry/farming/logic/CropPeat.java rename to src/main/java/forestry/farming/logic/crops/CropPeat.java index c92659ede..a0ad615ec --- a/src/main/java/forestry/farming/logic/CropPeat.java +++ b/src/main/java/forestry/farming/logic/crops/CropPeat.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; diff --git a/src/main/java/forestry/farming/logic/CropRubber.java b/src/main/java/forestry/farming/logic/crops/CropRubber.java old mode 100755 new mode 100644 similarity index 98% rename from src/main/java/forestry/farming/logic/CropRubber.java rename to src/main/java/forestry/farming/logic/crops/CropRubber.java index dc11ef1e2..47572d1e2 --- a/src/main/java/forestry/farming/logic/CropRubber.java +++ b/src/main/java/forestry/farming/logic/crops/CropRubber.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.crops; import com.google.common.base.Optional; import com.google.common.collect.ImmutableCollection; diff --git a/src/main/java/forestry/farming/logic/crops/package-info.java b/src/main/java/forestry/farming/logic/crops/package-info.java new file mode 100644 index 000000000..479c24953 --- /dev/null +++ b/src/main/java/forestry/farming/logic/crops/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.farming.logic.crops; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/farming/logic/FarmableAgingCrop.java b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java similarity index 96% rename from src/main/java/forestry/farming/logic/FarmableAgingCrop.java rename to src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java index 222dec7a8..53f539291 100644 --- a/src/main/java/forestry/farming/logic/FarmableAgingCrop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java @@ -1,11 +1,9 @@ -package forestry.farming.logic; +package forestry.farming.logic.farmables; + +import com.google.common.base.Preconditions; import javax.annotation.Nullable; -import com.google.common.base.Preconditions; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; @@ -14,6 +12,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; +import forestry.farming.logic.crops.CropDestroy; + /** * For blocks that are harvestable once they are a certain age. */ diff --git a/src/main/java/forestry/farming/logic/FarmableBase.java b/src/main/java/forestry/farming/logic/farmables/FarmableBase.java similarity index 94% rename from src/main/java/forestry/farming/logic/FarmableBase.java rename to src/main/java/forestry/farming/logic/farmables/FarmableBase.java index 01dccc01e..5a83ffadd 100644 --- a/src/main/java/forestry/farming/logic/FarmableBase.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableBase.java @@ -1,14 +1,16 @@ -package forestry.farming.logic; +package forestry.farming.logic.farmables; -import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmable; -import forestry.core.utils.BlockUtil; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; +import forestry.farming.logic.crops.CropDestroy; + public abstract class FarmableBase implements IFarmable { protected final ItemStack germling; protected final IBlockState plantedState; diff --git a/src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java b/src/main/java/forestry/farming/logic/farmables/FarmableBasicAgricraft.java similarity index 92% rename from src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java rename to src/main/java/forestry/farming/logic/farmables/FarmableBasicAgricraft.java index a3391c911..a13a4e1ea 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicAgricraft.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableBasicAgricraft.java @@ -8,14 +8,16 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; -import forestry.api.farming.ICrop; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.farming.logic.crops.CropBasicAgriCraft; + public class FarmableBasicAgricraft extends FarmableBase { public FarmableBasicAgricraft(ItemStack germling, IBlockState plantedState, IBlockState matureState, boolean replant) { super(germling, plantedState, matureState, replant); diff --git a/src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java b/src/main/java/forestry/farming/logic/farmables/FarmableBasicGrowthCraft.java similarity index 97% rename from src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java rename to src/main/java/forestry/farming/logic/farmables/FarmableBasicGrowthCraft.java index fe5c42420..c3e863f8a 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicGrowthCraft.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableBasicGrowthCraft.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; //TODO GrowthCraft for 1.9 public class FarmableBasicGrowthCraft { diff --git a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java b/src/main/java/forestry/farming/logic/farmables/FarmableBasicIC2Crop.java similarity index 95% rename from src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java rename to src/main/java/forestry/farming/logic/farmables/FarmableBasicIC2Crop.java index 944792619..42627e27c 100644 --- a/src/main/java/forestry/farming/logic/FarmableBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableBasicIC2Crop.java @@ -1,4 +1,4 @@ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import javax.annotation.Nullable; @@ -13,8 +13,8 @@ import net.minecraftforge.fml.common.Optional; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.farming.logic.crops.CropBasicIC2Crop; import forestry.plugins.PluginIC2; - import ic2.api.crops.ICropTile; public class FarmableBasicIC2Crop implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableCocoa.java b/src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java old mode 100755 new mode 100644 similarity index 96% rename from src/main/java/forestry/farming/logic/FarmableCocoa.java rename to src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java index 0f821f020..1c35f2788 --- a/src/main/java/forestry/farming/logic/FarmableCocoa.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableCocoa.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.BlockCocoa; import net.minecraft.entity.player.EntityPlayer; diff --git a/src/main/java/forestry/farming/logic/FarmableDoubleCrop.java b/src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java similarity index 91% rename from src/main/java/forestry/farming/logic/FarmableDoubleCrop.java rename to src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java index d524506ac..5e3b62a2e 100644 --- a/src/main/java/forestry/farming/logic/FarmableDoubleCrop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java @@ -1,4 +1,4 @@ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; @@ -6,6 +6,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.ICrop; +import forestry.farming.logic.crops.CropDestroyDouble; public class FarmableDoubleCrop extends FarmableBase { private final IBlockState topMatureState; diff --git a/src/main/java/forestry/farming/logic/FarmableGE.java b/src/main/java/forestry/farming/logic/farmables/FarmableGE.java old mode 100755 new mode 100644 similarity index 95% rename from src/main/java/forestry/farming/logic/FarmableGE.java rename to src/main/java/forestry/farming/logic/farmables/FarmableGE.java index 208f07e81..0ccbf303c --- a/src/main/java/forestry/farming/logic/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableGE.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -23,6 +23,7 @@ import forestry.api.arboriculture.TreeManager; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.arboriculture.ModuleArboriculture; +import forestry.farming.logic.crops.CropDestroy; public class FarmableGE implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableGourd.java b/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java old mode 100755 new mode 100644 similarity index 95% rename from src/main/java/forestry/farming/logic/FarmableGourd.java rename to src/main/java/forestry/farming/logic/farmables/FarmableGourd.java index 3c1efe3b2..6cd382579 --- a/src/main/java/forestry/farming/logic/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -20,6 +20,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; +import forestry.farming.logic.crops.CropDestroy; public class FarmableGourd implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableRusticGrape.java b/src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java similarity index 94% rename from src/main/java/forestry/farming/logic/FarmableRusticGrape.java rename to src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java index 598103d91..4fbde5151 100644 --- a/src/main/java/forestry/farming/logic/FarmableRusticGrape.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java @@ -1,4 +1,4 @@ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import com.google.common.base.Preconditions; @@ -14,6 +14,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; +import forestry.farming.logic.crops.CropDestroy; public class FarmableRusticGrape implements IFarmable { public static final PropertyBool GRAPES = PropertyBool.create("grapes"); diff --git a/src/main/java/forestry/farming/logic/FarmableRusticSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java similarity index 95% rename from src/main/java/forestry/farming/logic/FarmableRusticSapling.java rename to src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java index 7ca0e7e33..79e321e88 100644 --- a/src/main/java/forestry/farming/logic/FarmableRusticSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java @@ -1,4 +1,4 @@ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -12,6 +12,7 @@ import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.network.packets.PacketFXSignal; import forestry.core.utils.NetworkUtil; +import forestry.farming.logic.crops.CropDestroy; public class FarmableRusticSapling implements IFarmable { diff --git a/src/main/java/forestry/farming/logic/FarmableSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java similarity index 97% rename from src/main/java/forestry/farming/logic/FarmableSapling.java rename to src/main/java/forestry/farming/logic/farmables/FarmableSapling.java index cd3d2553d..95df1a937 100644 --- a/src/main/java/forestry/farming/logic/FarmableSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -26,6 +26,7 @@ import forestry.api.farming.IFarmable; import forestry.core.network.packets.PacketFXSignal; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.NetworkUtil; +import forestry.farming.logic.crops.CropDestroy; public class FarmableSapling implements IFarmable { protected final ItemStack germling; diff --git a/src/main/java/forestry/farming/logic/FarmableStacked.java b/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java old mode 100755 new mode 100644 similarity index 95% rename from src/main/java/forestry/farming/logic/FarmableStacked.java rename to src/main/java/forestry/farming/logic/farmables/FarmableStacked.java index 2bc8bea39..adc3f3e8d --- a/src/main/java/forestry/farming/logic/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -20,6 +20,7 @@ import net.minecraft.world.World; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; +import forestry.farming.logic.crops.CropDestroy; public class FarmableStacked implements IFarmable { protected final ItemStack germling; diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java b/src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java similarity index 93% rename from src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java rename to src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java index ab3af235b..57333114b 100644 --- a/src/main/java/forestry/farming/logic/FarmableVanillaMushroom.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableVanillaMushroom.java @@ -8,15 +8,17 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; -import forestry.api.farming.ICrop; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import forestry.api.farming.ICrop; +import forestry.farming.logic.crops.CropDestroy; + public class FarmableVanillaMushroom extends FarmableBase { private final Block hugeMushroomBlock; diff --git a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableVanillaSapling.java old mode 100755 new mode 100644 similarity index 95% rename from src/main/java/forestry/farming/logic/FarmableVanillaSapling.java rename to src/main/java/forestry/farming/logic/farmables/FarmableVanillaSapling.java index c22cc397e..7009613b4 --- a/src/main/java/forestry/farming/logic/FarmableVanillaSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableVanillaSapling.java @@ -8,7 +8,7 @@ * Various Contributors including, but not limited to: * SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges ******************************************************************************/ -package forestry.farming.logic; +package forestry.farming.logic.farmables; import net.minecraft.init.Blocks; import net.minecraft.init.Items; diff --git a/src/main/java/forestry/farming/logic/farmables/package-info.java b/src/main/java/forestry/farming/logic/farmables/package-info.java new file mode 100644 index 000000000..661f5e768 --- /dev/null +++ b/src/main/java/forestry/farming/logic/farmables/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.farming.logic.farmables; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/farming/multiblock/FakeFarmController.java b/src/main/java/forestry/farming/multiblock/FakeFarmController.java index a9ed92059..db497891c 100644 --- a/src/main/java/forestry/farming/multiblock/FakeFarmController.java +++ b/src/main/java/forestry/farming/multiblock/FakeFarmController.java @@ -10,6 +10,15 @@ ******************************************************************************/ package forestry.farming.multiblock; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3i; +import net.minecraft.world.World; + +import net.minecraftforge.fluids.FluidStack; + import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitSocketType; import forestry.api.farming.FarmDirection; @@ -23,13 +32,6 @@ import forestry.core.inventory.IInventoryAdapter; import forestry.core.multiblock.FakeMultiblockController; import forestry.farming.gui.IFarmLedgerDelegate; import forestry.farming.logic.FarmLogicArboreal; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3i; -import net.minecraft.world.World; -import net.minecraftforge.fluids.FluidStack; public class FakeFarmController extends FakeMultiblockController implements IFarmControllerInternal { public static final FakeFarmController instance = new FakeFarmController(); @@ -138,6 +140,11 @@ public class FakeFarmController extends FakeMultiblockController implements IFar return "for.multiblock.farm.type"; } + @Override + public boolean isValidPlatform(World world, BlockPos pos) { + return false; + } + private static class FakeFarmInventory implements IFarmInventory { public static final FakeFarmInventory instance = new FakeFarmInventory(); diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index a7a4371d8..27dd0941d 100755 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -15,11 +15,9 @@ import com.google.common.base.Preconditions; import javax.annotation.Nullable; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; @@ -50,7 +48,6 @@ import forestry.api.core.EnumTemperature; import forestry.api.core.IErrorLogic; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmInventory; import forestry.api.farming.IFarmListener; import forestry.api.farming.IFarmLogic; @@ -73,9 +70,10 @@ import forestry.core.network.PacketBufferForestry; import forestry.core.tiles.ILiquidTankTile; import forestry.core.utils.ClimateUtil; import forestry.core.utils.PlayerUtil; -import forestry.core.utils.TopDownBlockPosComparator; import forestry.core.utils.Translator; import forestry.farming.FarmHelper; +import forestry.farming.FarmHelper.FarmWorkStatus; +import forestry.farming.FarmHelper.Stage; import forestry.farming.FarmTarget; import forestry.farming.gui.IFarmLedgerDelegate; import forestry.farming.logic.FarmLogicArboreal; @@ -84,32 +82,6 @@ import forestry.farming.tiles.TileFarmPlain; public class FarmController extends RectangularMultiblockControllerBase implements IFarmControllerInternal, ILiquidTankTile { - private enum Stage { - CULTIVATE, HARVEST; - - public Stage next() { - if (this == CULTIVATE) { - return HARVEST; - } else { - return CULTIVATE; - } - } - } - - private static FarmDirection getLayoutDirection(FarmDirection farmSide) { - switch (farmSide) { - case NORTH: - return FarmDirection.WEST; - case WEST: - return FarmDirection.SOUTH; - case SOUTH: - return FarmDirection.EAST; - case EAST: - return FarmDirection.NORTH; - } - return null; - } - private final Map> targets = new EnumMap<>(FarmDirection.class); private int allowedExtent = 0; @Nullable @@ -473,11 +445,11 @@ public class FarmController extends RectangularMultiblockControllerBase implemen List farmTargets = targets.get(farmSide); if (stage == Stage.HARVEST) { - Collection harvested = harvestTargets(world, farmTargets, logic, farmListeners); + Collection harvested = FarmHelper.harvestTargets(world, farmTargets, logic, farmListeners); farmWorkStatus.didWork = !harvested.isEmpty(); if (!harvested.isEmpty()) { pendingCrops.addAll(harvested); - pendingCrops.sort(TopDownICropComparator.INSTANCE); + pendingCrops.sort(FarmHelper.TopDownICropComparator.INSTANCE); harvestProvider = logic; } } else if (stage == Stage.CULTIVATE) { @@ -513,102 +485,8 @@ public class FarmController extends RectangularMultiblockControllerBase implemen // Set the maximum allowed extent. allowedExtent = Math.max(sizeNorthSouth, sizeEastWest) * Config.farmSize + 1; - createTargets(world, targets, targetStart, allowedExtent, sizeNorthSouth, sizeEastWest, min, max); - setExtents(world, targets); - } - - private static void createTargets(World world, Map> targets, BlockPos targetStart, final int allowedExtent, final int farmSizeNorthSouth, final int farmSizeEastWest, BlockPos minFarmCoord, BlockPos maxFarmCoord) { - for (FarmDirection farmSide : FarmDirection.values()) { - - final int farmWidth; - if (farmSide == FarmDirection.NORTH || farmSide == FarmDirection.SOUTH) { - farmWidth = farmSizeEastWest; - } else { - farmWidth = farmSizeNorthSouth; - } - - // targets extend sideways in a pinwheel pattern around the farm, so they need to go a little extra distance - final int targetMaxLimit = allowedExtent + farmWidth; - - FarmDirection layoutDirection = getLayoutDirection(farmSide); - - List farmSideTargets = new ArrayList<>(); - targets.put(farmSide, farmSideTargets); - - BlockPos targetLocation = FarmHelper.getFarmMultiblockCorner(targetStart, farmSide, layoutDirection, minFarmCoord, maxFarmCoord); - BlockPos firstLocation = targetLocation.offset(farmSide.getFacing()); - BlockPos firstGroundPosition = getGroundPosition(world, firstLocation); - if (firstGroundPosition != null) { - int groundHeight = firstGroundPosition.getY(); - - for (int i = 0; i < allowedExtent; i++) { - targetLocation = targetLocation.offset(farmSide.getFacing()); - BlockPos groundLocation = new BlockPos(targetLocation.getX(), groundHeight, targetLocation.getZ()); - - if (!world.isBlockLoaded(groundLocation)) { - break; - } - - IBlockState blockState = world.getBlockState(groundLocation); - if (!FarmHelper.bricks.contains(blockState.getBlock())) { - break; - } - - int targetLimit = targetMaxLimit; - if (!Config.squareFarms) { - targetLimit = targetMaxLimit - i - 1; - } - - FarmTarget target = new FarmTarget(targetLocation, layoutDirection, targetLimit); - farmSideTargets.add(target); - } - } - } - } - - @Nullable - private static BlockPos getGroundPosition(World world, BlockPos targetPosition) { - if (!world.isBlockLoaded(targetPosition)) { - return null; - } - - for (int yOffset = 2; yOffset > -4; yOffset--) { - BlockPos position = targetPosition.add(0, yOffset, 0); - IBlockState blockState = world.getBlockState(position); - if (FarmHelper.bricks.contains(blockState.getBlock())) { - return position; - } - } - - return null; - } - - private static boolean isCycleCanceledByListeners(IFarmLogic logic, FarmDirection direction, Iterable farmListeners) { - for (IFarmListener listener : farmListeners) { - if (listener.cancelTask(logic, direction)) { - return true; - } - } - return false; - } - - private static void setExtents(World world, Map> targets) { - for (List targetsList : targets.values()) { - if (!targetsList.isEmpty()) { - BlockPos groundPosition = getGroundPosition(world, targetsList.get(0).getStart()); - - for (FarmTarget target : targetsList) { - target.setExtentAndYOffset(world, groundPosition); - } - } - } - } - - private static class FarmWorkStatus { - public boolean didWork = false; - public boolean hasFarmland = false; - public boolean hasFertilizer = true; - public boolean hasLiquid = true; + FarmHelper.createTargets(world, this, targets, targetStart, allowedExtent, sizeNorthSouth, sizeEastWest, min, max); + FarmHelper.setExtents(world, this, targets); } private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List farmTargets, IFarmLogic logic, FarmDirection farmSide) { @@ -621,7 +499,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } } - if (hasFarmland && !isCycleCanceledByListeners(logic, farmSide, farmListeners)) { + if (hasFarmland && !FarmHelper.isCycleCanceledByListeners(logic, farmSide, farmListeners)) { final float hydrationModifier = hydrationManager.getHydrationModifier(); final int fertilizerConsumption = logic.getFertilizerConsumption(); final int liquidConsumption = logic.getWaterConsumption(hydrationModifier); @@ -639,7 +517,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen continue; } - if (cultivateTarget(world, this, target, logic, farmListeners)) { + if (FarmHelper.cultivateTarget(world, this, target, logic, farmListeners)) { // Remove fertilizer and water fertilizerManager.removeFertilizer(inventory, fertilizerConsumption); removeLiquid(liquid); @@ -652,41 +530,6 @@ public class FarmController extends RectangularMultiblockControllerBase implemen return farmWorkStatus; } - private static boolean cultivateTarget(World world, IFarmHousing farmHousing, FarmTarget target, IFarmLogic logic, Iterable farmListeners) { - BlockPos targetPosition = target.getStart().add(0, target.getYOffset(), 0); - if (logic.cultivate(world, farmHousing, targetPosition, target.getDirection(), target.getExtent())) { - for (IFarmListener listener : farmListeners) { - listener.hasCultivated(logic, targetPosition, target.getDirection(), target.getExtent()); - } - return true; - } - - return false; - } - - private static Collection harvestTargets(World world, List farmTargets, IFarmLogic logic, Iterable farmListeners) { - for (FarmTarget target : farmTargets) { - Collection harvested = harvestTarget(world, target, logic, farmListeners); - if (!harvested.isEmpty()) { - return harvested; - } - } - - return Collections.emptyList(); - } - - private static Collection harvestTarget(World world, FarmTarget target, IFarmLogic logic, Iterable farmListeners) { - BlockPos pos = target.getStart().add(0, target.getYOffset(), 0); - Collection harvested = logic.harvest(world, pos, target.getDirection(), target.getExtent()); - if (!harvested.isEmpty()) { - // Let event handlers know. - for (IFarmListener listener : farmListeners) { - listener.hasScheduledHarvest(harvested, logic, pos, target.getDirection(), target.getExtent()); - } - } - return harvested; - } - private boolean collectWindfall(IFarmLogic logic) { NonNullList collected = logic.collect(world, this); if (collected.isEmpty()) { @@ -835,22 +678,20 @@ public class FarmController extends RectangularMultiblockControllerBase implemen return CircuitSocketType.FARM; } + @Override + public boolean isValidPlatform(World world, BlockPos pos) { + IBlockState blockState = world.getBlockState(pos); + return FarmHelper.bricks.contains(blockState.getBlock()); + } + + @Override + public boolean isSquare() { + return Config.squareFarms; + } + // for debugging @Override public String toString() { return MoreObjects.toStringHelper(this).add("stage", stage).add("logic", farmLogics.toString()).toString(); } - - private static class TopDownICropComparator implements Comparator { - public static final TopDownICropComparator INSTANCE = new TopDownICropComparator(); - - private TopDownICropComparator() { - - } - - @Override - public int compare(ICrop o1, ICrop o2) { - return TopDownBlockPosComparator.INSTANCE.compare(o1.getPosition(), o2.getPosition()); - } - } } diff --git a/src/main/java/forestry/farming/multiblock/FarmFertilizerManager.java b/src/main/java/forestry/farming/multiblock/FarmFertilizerManager.java index e7e3cb935..99887e966 100644 --- a/src/main/java/forestry/farming/multiblock/FarmFertilizerManager.java +++ b/src/main/java/forestry/farming/multiblock/FarmFertilizerManager.java @@ -12,11 +12,12 @@ package forestry.farming.multiblock; import java.io.IOException; +import net.minecraft.nbt.NBTTagCompound; + import forestry.api.core.INbtReadable; import forestry.api.core.INbtWritable; import forestry.core.network.IStreamable; import forestry.core.network.PacketBufferForestry; -import net.minecraft.nbt.NBTTagCompound; public class FarmFertilizerManager implements INbtWritable, INbtReadable, IStreamable { private static final int BUFFER_FERTILIZER = 200; @@ -26,7 +27,7 @@ public class FarmFertilizerManager implements INbtWritable, INbtReadable, IStrea storedFertilizer = 0; } - public boolean hasFertilizer(InventoryFarm inventory, int amount) { + public boolean hasFertilizer(IFarmInventoryInternal inventory, int amount) { if (inventory.getFertilizerValue() < 0) { return true; } @@ -34,7 +35,7 @@ public class FarmFertilizerManager implements INbtWritable, INbtReadable, IStrea return storedFertilizer >= amount; } - public void removeFertilizer(InventoryFarm inventory, int amount) { + public void removeFertilizer(IFarmInventoryInternal inventory, int amount) { if (inventory.getFertilizerValue() < 0) { return; } @@ -45,7 +46,7 @@ public class FarmFertilizerManager implements INbtWritable, INbtReadable, IStrea } } - public boolean maintainFertilizer(InventoryFarm inventory) { + public boolean maintainFertilizer(IFarmInventoryInternal inventory) { if (storedFertilizer <= BUFFER_FERTILIZER) { int fertilizerValue = inventory.getFertilizerValue(); if (fertilizerValue < 0) { @@ -69,7 +70,7 @@ public class FarmFertilizerManager implements INbtWritable, INbtReadable, IStrea return data; } - public int getStoredFertilizerScaled(InventoryFarm inventory, int scale) { + public int getStoredFertilizerScaled(IFarmInventoryInternal inventory, int scale) { if (storedFertilizer == 0) { return 0; } diff --git a/src/main/java/forestry/farming/multiblock/IFarmInventoryInternal.java b/src/main/java/forestry/farming/multiblock/IFarmInventoryInternal.java new file mode 100644 index 000000000..823c4b6e2 --- /dev/null +++ b/src/main/java/forestry/farming/multiblock/IFarmInventoryInternal.java @@ -0,0 +1,10 @@ +package forestry.farming.multiblock; + +import forestry.api.farming.IFarmInventory; + +public interface IFarmInventoryInternal extends IFarmInventory { + + int getFertilizerValue(); + + boolean useFertilizer(); +} diff --git a/src/main/java/forestry/farming/multiblock/InventoryFarm.java b/src/main/java/forestry/farming/multiblock/InventoryFarm.java index 2703411f3..3d9306e69 100644 --- a/src/main/java/forestry/farming/multiblock/InventoryFarm.java +++ b/src/main/java/forestry/farming/multiblock/InventoryFarm.java @@ -24,7 +24,6 @@ import net.minecraftforge.fluids.FluidUtil; import forestry.api.core.ForestryAPI; import forestry.api.farming.FarmDirection; -import forestry.api.farming.IFarmInventory; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmable; import forestry.core.fluids.FluidHelper; @@ -32,10 +31,9 @@ import forestry.core.fluids.TankManager; import forestry.core.inventory.InventoryAdapterRestricted; import forestry.core.inventory.wrappers.InventoryMapper; import forestry.core.utils.InventoryUtil; -import forestry.core.utils.PlayerUtil; import forestry.core.utils.SlotUtil; -public class InventoryFarm extends InventoryAdapterRestricted implements IFarmInventory { +public class InventoryFarm extends InventoryAdapterRestricted implements IFarmInventoryInternal { public static final int SLOT_RESOURCES_1 = 0; public static final int SLOT_RESOURCES_COUNT = 6; public static final int SLOT_GERMLINGS_1 = 6; diff --git a/src/main/java/forestry/modules/ForestryModuleUids.java b/src/main/java/forestry/modules/ForestryModuleUids.java index fe4f8c8c9..a7dfb8dc0 100644 --- a/src/main/java/forestry/modules/ForestryModuleUids.java +++ b/src/main/java/forestry/modules/ForestryModuleUids.java @@ -18,6 +18,7 @@ public class ForestryModuleUids { public static final String CRATE = "crates"; public static final String BACKPACKS = "backpacks"; public static final String DATABASE = "database"; + public static final String CULTIVATION = "cultivation"; //Mod Plugins public static final String BIOMES_O_PLENTY = "biomes.o.plenty"; diff --git a/src/main/java/forestry/plugins/PluginActuallyAdditions.java b/src/main/java/forestry/plugins/PluginActuallyAdditions.java index ecf152245..0b67e44d4 100644 --- a/src/main/java/forestry/plugins/PluginActuallyAdditions.java +++ b/src/main/java/forestry/plugins/PluginActuallyAdditions.java @@ -17,7 +17,7 @@ import forestry.api.modules.ForestryModule; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; -import forestry.farming.logic.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableAgingCrop; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") diff --git a/src/main/java/forestry/plugins/PluginBetterWithMods.java b/src/main/java/forestry/plugins/PluginBetterWithMods.java index 60f1c38c8..91ba8beca 100644 --- a/src/main/java/forestry/plugins/PluginBetterWithMods.java +++ b/src/main/java/forestry/plugins/PluginBetterWithMods.java @@ -13,7 +13,7 @@ import forestry.api.modules.ForestryModule; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; -import forestry.farming.logic.FarmableDoubleCrop; +import forestry.farming.logic.farmables.FarmableDoubleCrop; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java index d19c035d5..625b3c745 100644 --- a/src/main/java/forestry/plugins/PluginExtraUtilities.java +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -38,7 +38,7 @@ import forestry.core.utils.ModUtil; import forestry.farming.FarmRegistry; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicExU; -import forestry.farming.logic.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableAgingCrop; import forestry.modules.BlankForestryModule; import forestry.modules.ForestryModuleUids; diff --git a/src/main/java/forestry/plugins/PluginHarvestCraft.java b/src/main/java/forestry/plugins/PluginHarvestCraft.java index 71d5c8296..f2329e230 100644 --- a/src/main/java/forestry/plugins/PluginHarvestCraft.java +++ b/src/main/java/forestry/plugins/PluginHarvestCraft.java @@ -30,7 +30,7 @@ import forestry.core.config.Constants; import forestry.core.fluids.Fluids; import forestry.core.items.ItemRegistryCore; import forestry.core.recipes.RecipeUtil; -import forestry.farming.logic.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableAgingCrop; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") @@ -199,8 +199,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, berrySeed, Fluids.SEED_OIL.getFluid(seedamount)); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && berrySeed != null && berryBlock != null) { - farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(berrySeed, berryBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(berrySeed, berryBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(berrySeed, berryBlock, plantAGE, 3, 0)); } plants.add(berryName); } @@ -217,8 +216,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, fruitSeed, Fluids.SEED_OIL.getFluid(seedamount)); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && fruitSeed != null && fruitBlock != null) { - farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(fruitSeed, fruitBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(fruitSeed, fruitBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(fruitSeed, fruitBlock, plantAGE, 3, 0)); } plants.add(fruitName); } @@ -236,8 +234,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, vegetableSeed, Fluids.SEED_OIL.getFluid(seedamount)); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && vegetableSeed != null && vegetableBlock != null) { - farmRegistry.registerFarmables("farmVegetables", new FarmableAgingCrop(vegetableSeed, vegetableBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(vegetableSeed, vegetableBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(vegetableSeed, vegetableBlock, plantAGE, 3, 0)); } plants.add(vegetableName); } @@ -256,8 +253,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.moistenerManager.addRecipe(grainSeed, new ItemStack(Blocks.MYCELIUM), 5000); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && grainSeed != null && grainBlock != null) { - farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(grainSeed, grainBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(grainSeed, grainBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(grainSeed, grainBlock, plantAGE, 3, 0)); } plants.add(grainName); } @@ -303,8 +299,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, genericCropSeed, Fluids.SEED_OIL.getFluid(seedamount)); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && genericCropSeed != null && genericCropBlock != null) { - farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(genericCropSeed, genericCropBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(genericCropSeed, genericCropBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(genericCropSeed, genericCropBlock, plantAGE, 3, 0)); } plants.add(cropName); } @@ -315,8 +310,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, mustardCropSeed, Fluids.SEED_OIL.getFluid(seedamount)); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && mustardCropSeed != null && mustardCropBlock != null) { - farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(mustardCropSeed, mustardCropBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(mustardCropSeed, mustardCropBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(mustardCropSeed, mustardCropBlock, plantAGE, 3, 0)); } if (mustardFruit != null) { RecipeUtil.addFermenterRecipes(mustardFruit, ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS); @@ -337,8 +331,7 @@ public class PluginHarvestCraft extends CompatPlugin { RecipeManagers.squeezerManager.addRecipe(10, cropnutSeed, Fluids.SEED_OIL.getFluid(seedamount)); } if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)) && cropnutSeed != null && cropnutBlock != null) { - farmRegistry.registerFarmables("farmWheat", new FarmableAgingCrop(cropnutSeed, cropnutBlock, plantAGE, 3)); - farmRegistry.registerFarmables("farmOrchard", new FarmableAgingCrop(cropnutSeed, cropnutBlock, plantAGE, 3, 0)); + farmRegistry.registerFarmables("farmCrops", new FarmableAgingCrop(cropnutSeed, cropnutBlock, plantAGE, 3, 0)); } if (cropnut != null) { RecipeManagers.squeezerManager.addRecipe(20, cropnut, Fluids.SEED_OIL.getFluid(12 * seedamount)); diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index a143e8435..687a629f2 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -61,10 +61,9 @@ import forestry.energy.circuits.CircuitElectricEfficiency; import forestry.farming.FarmRegistry; import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicRubber; -import forestry.farming.logic.FarmableBasicIC2Crop; +import forestry.farming.logic.farmables.FarmableBasicIC2Crop; import forestry.modules.BlankForestryModule; import forestry.modules.ForestryModuleUids; - import ic2.api.item.IC2Items; import ic2.api.recipe.Recipes; diff --git a/src/main/java/forestry/plugins/PluginImmersiveEngineering.java b/src/main/java/forestry/plugins/PluginImmersiveEngineering.java index 37ae523a2..c97bf05fd 100644 --- a/src/main/java/forestry/plugins/PluginImmersiveEngineering.java +++ b/src/main/java/forestry/plugins/PluginImmersiveEngineering.java @@ -22,7 +22,7 @@ import forestry.api.modules.ForestryModule; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; -import forestry.farming.logic.FarmableDoubleCrop; +import forestry.farming.logic.farmables.FarmableDoubleCrop; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") diff --git a/src/main/java/forestry/plugins/PluginMysticalAgriculture.java b/src/main/java/forestry/plugins/PluginMysticalAgriculture.java index a8a192b14..643a56eff 100644 --- a/src/main/java/forestry/plugins/PluginMysticalAgriculture.java +++ b/src/main/java/forestry/plugins/PluginMysticalAgriculture.java @@ -13,7 +13,7 @@ import forestry.api.modules.ForestryModule; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; -import forestry.farming.logic.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableAgingCrop; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index fee432f6c..ef1befabc 100644 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -48,8 +48,8 @@ import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.core.utils.ModUtil; import forestry.farming.FarmRegistry; -import forestry.farming.logic.FarmableAgingCrop; -import forestry.farming.logic.FarmableSapling; +import forestry.farming.logic.farmables.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableSapling; import forestry.modules.BlankForestryModule; import forestry.modules.ForestryModuleUids; @@ -220,7 +220,7 @@ public class PluginNatura extends BlankForestryModule { return; } - FarmRegistry.getInstance().registerFarmables("farmWheat", + FarmRegistry.getInstance().registerFarmables("farmCrops", new FarmableAgingCrop( seedItem, block, diff --git a/src/main/java/forestry/plugins/PluginRoots.java b/src/main/java/forestry/plugins/PluginRoots.java index ebe7f3056..fb077bc21 100644 --- a/src/main/java/forestry/plugins/PluginRoots.java +++ b/src/main/java/forestry/plugins/PluginRoots.java @@ -12,7 +12,7 @@ import forestry.api.modules.ForestryModule; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; -import forestry.farming.logic.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableAgingCrop; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") diff --git a/src/main/java/forestry/plugins/PluginRustic.java b/src/main/java/forestry/plugins/PluginRustic.java index e9bc0b304..405825de7 100644 --- a/src/main/java/forestry/plugins/PluginRustic.java +++ b/src/main/java/forestry/plugins/PluginRustic.java @@ -12,9 +12,9 @@ import forestry.api.modules.ForestryModule; import forestry.api.recipes.RecipeManagers; import forestry.core.config.Constants; import forestry.core.fluids.Fluids; -import forestry.farming.logic.FarmableAgingCrop; -import forestry.farming.logic.FarmableRusticGrape; -import forestry.farming.logic.FarmableRusticSapling; +import forestry.farming.logic.farmables.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableRusticGrape; +import forestry.farming.logic.farmables.FarmableRusticSapling; import forestry.modules.ForestryModuleUids; @SuppressWarnings("unused") diff --git a/src/main/resources/assets/forestry/blockstates/arboretum.json b/src/main/resources/assets/forestry/blockstates/arboretum.json new file mode 100644 index 000000000..38cfda3d7 --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/arboretum.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:arboretum" }, + "facing=east": { "model": "forestry:arboretum", "y": 90 }, + "facing=south": { "model": "forestry:arboretum", "y": 180 }, + "facing=west": { "model": "forestry:arboretum", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/farm_crops.json b/src/main/resources/assets/forestry/blockstates/farm_crops.json new file mode 100644 index 000000000..f5d9956f2 --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/farm_crops.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:farm_crops" }, + "facing=east": { "model": "forestry:farm_crops", "y": 90 }, + "facing=south": { "model": "forestry:farm_crops", "y": 180 }, + "facing=west": { "model": "forestry:farm_crops", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/farm_gourd.json b/src/main/resources/assets/forestry/blockstates/farm_gourd.json new file mode 100644 index 000000000..3f2e93938 --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/farm_gourd.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:farm_gourd" }, + "facing=east": { "model": "forestry:farm_gourd", "y": 90 }, + "facing=south": { "model": "forestry:farm_gourd", "y": 180 }, + "facing=west": { "model": "forestry:farm_gourd", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/farm_mushroom.json b/src/main/resources/assets/forestry/blockstates/farm_mushroom.json new file mode 100644 index 000000000..1fd7c7fa6 --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/farm_mushroom.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:farm_mushroom" }, + "facing=east": { "model": "forestry:farm_mushroom", "y": 90 }, + "facing=south": { "model": "forestry:farm_mushroom", "y": 180 }, + "facing=west": { "model": "forestry:farm_mushroom", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/farm_nether.json b/src/main/resources/assets/forestry/blockstates/farm_nether.json new file mode 100644 index 000000000..2affb37af --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/farm_nether.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:farm_nether" }, + "facing=east": { "model": "forestry:farm_nether", "y": 90 }, + "facing=south": { "model": "forestry:farm_nether", "y": 180 }, + "facing=west": { "model": "forestry:farm_nether", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/peat_bog.json b/src/main/resources/assets/forestry/blockstates/peat_bog.json new file mode 100644 index 000000000..fbd9a1f1c --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/peat_bog.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:peat_bog" }, + "facing=east": { "model": "forestry:peat_bog", "y": 90 }, + "facing=south": { "model": "forestry:peat_bog", "y": 180 }, + "facing=west": { "model": "forestry:peat_bog", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/blockstates/plantation.json b/src/main/resources/assets/forestry/blockstates/plantation.json new file mode 100644 index 000000000..37abb8efb --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/plantation.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:plantation" }, + "facing=east": { "model": "forestry:plantation", "y": 90 }, + "facing=south": { "model": "forestry:plantation", "y": 180 }, + "facing=west": { "model": "forestry:plantation", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/models/block/arboretum.json b/src/main/resources/assets/forestry/models/block/arboretum.json new file mode 100644 index 000000000..f67ff350c --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/arboretum.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/arboretum_particle", + "texture": "forestry:blocks/arboretum" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/farm_crops.json b/src/main/resources/assets/forestry/models/block/farm_crops.json new file mode 100644 index 000000000..4665ccd49 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/farm_crops.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/farm_crops_particle", + "texture": "forestry:blocks/farm_crops" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/farm_gourd.json b/src/main/resources/assets/forestry/models/block/farm_gourd.json new file mode 100644 index 000000000..27486a1e7 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/farm_gourd.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/farm_gourd_particle", + "texture": "forestry:blocks/farm_gourd" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/farm_mushroom.json b/src/main/resources/assets/forestry/models/block/farm_mushroom.json new file mode 100644 index 000000000..0835f8385 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/farm_mushroom.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/farm_mushroom_particle", + "texture": "forestry:blocks/farm_mushroom" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/farm_nether.json b/src/main/resources/assets/forestry/models/block/farm_nether.json new file mode 100644 index 000000000..38939afd0 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/farm_nether.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/farm_nether_particle", + "texture": "forestry:blocks/farm_nether" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/peat_bog.json b/src/main/resources/assets/forestry/models/block/peat_bog.json new file mode 100644 index 000000000..930fd9fa8 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/peat_bog.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/peat_bog_particle", + "texture": "forestry:blocks/peat_bog" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/block/plantation.json b/src/main/resources/assets/forestry/models/block/plantation.json new file mode 100644 index 000000000..cbd8eb271 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/plantation.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/plantation_particle", + "texture": "forestry:blocks/plantation" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/item/arboretum.json b/src/main/resources/assets/forestry/models/item/arboretum.json new file mode 100644 index 000000000..44bea737c --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/arboretum.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/arboretum" +} diff --git a/src/main/resources/assets/forestry/models/item/farm_crops.json b/src/main/resources/assets/forestry/models/item/farm_crops.json new file mode 100644 index 000000000..62eb2bffe --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/farm_crops.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/farm_crops" +} diff --git a/src/main/resources/assets/forestry/models/item/farm_gourd.json b/src/main/resources/assets/forestry/models/item/farm_gourd.json new file mode 100644 index 000000000..da1f79c97 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/farm_gourd.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/farm_gourd" +} diff --git a/src/main/resources/assets/forestry/models/item/farm_mushroom.json b/src/main/resources/assets/forestry/models/item/farm_mushroom.json new file mode 100644 index 000000000..ef45652eb --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/farm_mushroom.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/farm_mushroom" +} diff --git a/src/main/resources/assets/forestry/models/item/farm_nether.json b/src/main/resources/assets/forestry/models/item/farm_nether.json new file mode 100644 index 000000000..31e2689fe --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/farm_nether.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/farm_nether" +} diff --git a/src/main/resources/assets/forestry/models/item/peat_bog.json b/src/main/resources/assets/forestry/models/item/peat_bog.json new file mode 100644 index 000000000..b697de6c8 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/peat_bog.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/peat_bog" +} diff --git a/src/main/resources/assets/forestry/models/item/plantation.json b/src/main/resources/assets/forestry/models/item/plantation.json new file mode 100644 index 000000000..40309ffdf --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/plantation.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/plantation" +} diff --git a/src/main/resources/assets/forestry/textures/blocks/arboretum.png b/src/main/resources/assets/forestry/textures/blocks/arboretum.png new file mode 100644 index 0000000000000000000000000000000000000000..10fbf0364141430d466c010fd05831a97cdcc2fd GIT binary patch literal 1880 zcmV-e2dDUnP)*hSYo|`XwU)H0jV+j>|woSmaUFez&!>S{j(UD)apldP!z_992WQpBV?Af^z00^Bg z8aDPnb}tO8j#OMhsp3FWBq*|kx=YxauF1apv80Nl=kgF0weAuCz>fPzp~qC1H3#YS zSU;Yc%fWIEc08dSq{E%@dQ!J_aUA^M0t`$x1bJZruW^{Ibs2o5^sa9I_2&$nx zFX?0qX3g;#CckX4{rs|ps_i}AFc=mC{(>GjeTBm<|*9yVRC>hOYn-6##5!&bTYOE%wrT;f-HGY zMUf>I^AkxKN!6 z+Ruy56C%?Ki1hQK^Mpvu1A6V}Mdt~T;ecNIdC_@7WH_MLeqMB*5E%{->E}h~36Yow zi1hQK^MpI|fFaHU`e(`><@BrDNsu(Jj9Zv4#2IO}+u!-#&q6xL!!`g_?zP>E$ZOYe zEOiryt*ba)EdrEz#=p`(4FEbz`Vn+ea(lcRB5E1HangG>$pb(eIM zrcB$#8(;q^g@wT4r4mL)g+su!-L`;3`=*%^ zrtP9zd?zHRd|$!4o3>%*d>y-U8{p*Yp7J`HR~Kugsg@T#@*i zzgv7K9`O43Cgg|?cijl;mkd06J;T^PY+slI46E)_=7mpwV+!!fP#y>>ABOKF&r^Bi zz9~E~7HjOUO>xck!@fVPPLS#QJwaufNj9USTfAtVA9S4{)7e}*WvH9ymo0RQ7tQm7 zt`p?2I6bs)nmy@e91w=@N1h*KoglYj@Mfgej`3UJy*z&#BcpL-(n)-J;xY=ZiLEDr z12egS?}r+I5?ix>z8R@?i>G=1gZve&>`Y?gii*VD5~fmK9v}36XcnN=UAreuMd5nV zPVsym*Ur~a&uu_?Qbz82630ipJU+<%9r&qzJ3Q!8nE%mqzT)EI)oa+ZWy+Vw2e}`X z2Bky$rU{+2gc%?eSJ*Ww_)g1mp?aOiMh!1q3J0sZFs6?hUf2NC-8!l5dH0M8URd6q z&5>q*td+|}4KM5gbVA!nZBJ+RQNjxwfTp%iYJ2*FMU?Qu2H;;*3ajmD?vE0_uOt{& z+tWfPO8CB!U?=H?C#k65`!*75SKHH=qa|;Y@B`-no{ed}A0>R>3!zqo(=0}#fEP9Z zb)#l67j#3~=|u@IY=E)Gn^2wf_q5H85?)j!%B1{D41C*Z+HO6P))#E2RI`|YBIba80NJ2(ZF?eGQVgosUAySUSW>hib~WgJnHPkE0ov9;^{Z>9 zbKM!5T?6%t2D6F#;{a{jS_5TU0(Wfj@D#Vp^qT&;Ozzmiwglq8>--Hn9s|KZ&z~g# O0000DXsLt@lm zIC;`5e*gzhkTq)JfkZuc5JNR+&{+@%cPlxtv72h~SCD1DV-{9w>GFc6cy{Kafwm+`|0NM$gCeL*q znq!KZHbut)s+vD%+7yOP(Ct3~ie^=T)!(PrRBSGpA!CRPq76b&+5nE_!R`6CwC~mX zLp`B=bpmeBgJTVD)v==u%WQz@xsrX;aYte%o~MVA~lP z12QpyR#9LybhP`Pz>L9^_iPHl3u4%4=r9^Oc9y%rx7Amys)b#>;|%7uEdRZ0Q|#yV z7m5K4lzMG90I2BDYbxBH7cz{sWe4llmW{6MU+-i^!M5cEApijD9WV55=p?kia17vY zJ#MfYV1tDOj~`4yKIWOS9mk&!0Mn+J=pxlS^NKT1xzFt{5(5+fp&~`)Tr)a&8NxXMQ3h$R zSyfQg{Ca@7KbvPEV%jvcKMn)pV*Zg}0H5;W(%@bgz?9=_0z)U*Um>CR-{|@wp_UZ` z+E*un#k~rmI1J$9pVb6>1;_?VgA--MfXQLlKM?Oao}t#HqU3hF5VRuOka${i^vl#oae9K7@p_zSQj#YNX5pt zuvoE^#N%z##f3{Z0RV5j@)Uks-igigd9Dj_0hxwGk|CT2K7SC|zn5&D4UyOsH!SYc zcuVV4ou)Z|=5(E=DW%h#oe3AvYig*Emn1L38lzkzsnwm9n`Fubs55X|5&5XB2zQ7o zCCfEZ86aBTiV&eP$x9hPw6;rNY&by+3auh1c36aG+$60)%;wqg zWZr1}oZUW@eS7c#gtkZ73|nf(-vsI2mKtMA&E4ZQ-UW27=$b%LS(<%|&J_S%6UY>C zFWlYh0n>Mb^3DAcoh!T>1YGSSajt&6HS`@Av8Hpy`|}cjn#)*kj&W_oqIUs+tEbP4 zPU`In?*d&j@D+erD2mEPCn6?4hqjL*07YdZUr8vg_A#I_Y^hJqTF6e%bBHZjQ{y|SXRlK~oMV8-h8b`?9G z8>q7xtT)GBkFsQ7GBXU)?&bKW$7B|Y%s}?v=llil4eFuZ5@PcJ0000`e>1bYp7Gj_?X}}XrU9JRY1{%XDv5YNRI*S|)xH4_kX9+E2za6j zm5@+*DDYGTq`s670i|mDP!-+~Uka!d1to%zs>Dg_kmiHLcC(wc4nYezH@ll6`l8>E>zu5JwSf-&qOYCcB$^csW z<&}^}K6@LkUnOr_EV&i3mVsp&R3oAG?5tVyc`%>hh2vMzl}t4f036&ugx!AjUyEPOj~?!;iG-jo5*~Z*7XDfV z*RLXkP$BMyv0;~QMiiXb;Noh8lQk%Lg5C_s7w(2a>6ceR7H_O|%mLaCFbsq7QHO!y zUBG!|D4>k@!w86-05CATi}6v9f6gt}gr*zDh9*OOwX(5S_Ty(S6pW8LO23;NU;-?Z zd;+%^6V$r#Ng3?R)tm)xk%f}4&ix?53k6;%7_?2ibw}(OFxfL;suYpWPS&W=Z^QwO za{fKz06S+kG+fHktpGa_ZvI+DF}l>3d7aF8nF6bocwdSa3Z>t54oH%qTG|o&?ppp7%*fV(Ljy8VgYJ;#KB;(r^_i3H`2efMLX6 zR{wTo-X|rAu}lNQi2qrpp{~7=UQ^}241c+=Zh%lI{nT+l^2%#;4Q|E((zs+z;A9Pk zY@;UsOJ1B3spWvjp1YMeZd?#G;(%oS%bFlr0ZNhAU@AG_nMVgVee?BeJqJjm{0eGc zIz^Vqmv2TJ6=F&_Ad|67^0vi^v*koHdS3Zib|OH+uo2+wCyG zj(oNw4p??Wj-M(T+rk0elCE>W`}2VH(9`Ybb>|6Pp9gf>&+E<;QZo9m=LxCdfKK~)-FZT4I6$YL*PSP%VjiH=&+E<;-k%3_aUQUJuIx}=IeM?K za~b@g!obcC5G*ZlzOcsar5^mCvQDy_pMUz;KeTKxyX^pJ+_z>Hn9pA0rTlfCUc168 zH%r*LOw03a=>@teeo*08yNmSyq|B=quk*r%D?ISmEN?89@qPr{-#(n$w;9oL0yAAeOHb-Vp@%+$7nx1Q?fFDFn0Z$&;CpLcAh^^w= zAwlcUt2{MvHS8I&<%2TJ60ZC&d57Zmq3jdqmPKvp6A)mO* z=D$Ug^Ot<4r!CIB5pnk&COiIh5rDJv9@7&JV%g*E`Lj$LEk+;3WucQM{I-!`JJ(B+q|$=dABnC1nyOiCFLO?oylKL} z=Nyn^V_EN~3BT=y&}M|wC`Z$P*LHvmqeeMbABM8iOA}t(0fYHW+x@+4bJK*^6+<#< o@{bsjZKoeZ4MQ_6c-?mRe}hFf(Ll?$1poj507*qoM6N<$g2_!X?*IS* literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/farm_gourd_particle.png b/src/main/resources/assets/forestry/textures/blocks/farm_gourd_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..9d194158606f8fe59ec86aa473fcddfeecfe9435 GIT binary patch literal 470 zcmV;{0V)28P)Lx$Xb}0b@x- zK~y-)rIWoA77TJG&2BPp7jXo3LPbM`a@2`IXX)6yP|!5{~*l_ z%2EsJirf3u&U@oGOvl~)tc)>)Iz>kb0CzX7JtlF1$>d>;juJwhVvIowAs7uBbo#@b zi7jT6^(M=U0Cf68MuP@I2qeI4p^3x!R-j$7i*C!`dyB(4vxNrO76^P2}Pyhe` literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/farm_mushroom.png b/src/main/resources/assets/forestry/textures/blocks/farm_mushroom.png new file mode 100644 index 0000000000000000000000000000000000000000..435a43e5e07c674041f1fc6fb9238543652b3b3f GIT binary patch literal 2014 zcmV<42O;>0P)j^CCp_LC~i_KtTj`3BHIgB1i%f*ac@b?q+6oCNrDt=Ij@lUV+ z_}!}p8bjLU3LB4qiZ}`p(jp2x>Wx*poi;*R07QX@VT$Z?irw3~1)$~c_qu%ivtJ?# zJfvO1AM_DYV3-1x#Mzv*?GvA!N|mj@{RQ12l~Mp)xpWcRk_2JITHU2HY!HM|HaB{` zdw-wQ7vRHp-e9xQ1Ym3HHfu?rPi|bH;|=(4HzEu?jHFM+a%crZ`j3C^guk>)00=3N zc8NF&Pt1*C&TC|`Wm}TpzxcvTPETHY>7lvx`YQMOigtUClH-yn#a_RQTyN6dxs4wW z`QpbOd`r+6sBorM^HNgqQD~vBLKeo!y6-! z;GKB#H($O^5Jp6Sm)&#}c(hd=-`k~Z865WZSzlSs2@N zQA*+Wx(wUz&CLPY8(kK`* zopxrAqmYfN!7vW+!hnixGYC8?c8L#_pxfG|S#{ZMwXj4DX;e=5kK=%GXMSNEAfz>R z;pymmK9+d@p9W!+F?#BMYk!x9T_&jkk901KWELYg;_ZUPWRT)!t%Jg&oOXUE=FfdH<(9=!N zeSYLIhAA)%gVaBYj}{}PWYevY9B<$w7n*cEkM*icqka*K0c%w^^Di6+NJi68kGvI!GP8v!EH2I zZ8qt)cDYz@@aFbiR?1~AH(d_n8t?4kit|Re9#X#4n18xuiH;p zdOu)ZJ+IqOC`>ifMr=kQS|@7&k>iOe@&{JF}rbFIEYr}ZFX;!!3CP)R&fnu?>4-&}iU;teXLuq=xp z2(pkCLU8F1f8x#)SEt&wvw)BmuRZ_0nRfA8Kl!BscMsjza zxQdjLD2gW9wK*V;!ij*VZoH!MzXLcce%eq<5r!d2k`Tu+S6=@!aU3Ir$ijV+U3&xa zH9f$0fA*@%FXp$`pEL3`|5@>~L;ye#1em7D?Js=(q3D=o*FFNN6iyfOt7pHReQSO( z`PblQ!OxoKtJNw|6yZ2WD$@7;ne5ZPe_EYj)*Gv17c*|u8>^fZubbx=T_>1nZ*J0J z(lGCK+ME@yo97o@Cz#XD=~Fje$)5B$4w!}qNRouNzw%`)%fc{>qdMMkh>x2ti?+{P z3FaAm9H~uW{L}DCDWsGnNkR|=D5bJIE`(UPed-3J#5V5c$C27u@%cQTXYDkPFWNr6 zCwN@lO?uK<+A#%Z#p~wzMb`<&qD$eYfAQlikK4A5@B288gAn4x8C{h9YxlN|$t|%Y z2CSKihP308c4p!TDwPUR;31?%eEd4VsZ=xEufP974nKK=rCl2N{^|Hx%XqDNJ&!FK zUb_??t?s5VebMmR8<2+EEVX?;Jd1+Y9^d%UPt~}8c3Q|44Sx=5P|RH0r#<^3;q~7Q z9;dchYWwtsMUn8@8*r2cXRGbg++QU8xsu?t+CD9GiiAHm5}YNyhFj6MX|A-+kJL4!E8=6JI>&oH(0k?$piEnGSTmS$707*qoM6N<$g2b!XegFUf literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/farm_mushroom_particle.png b/src/main/resources/assets/forestry/textures/blocks/farm_mushroom_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..9c651a543c723ff353d0184445deb2a18a7f7ce0 GIT binary patch literal 469 zcmV;`0V@89P)Wn^g&|F1vRNBl7-kwOTPc84^HT_+V; zm0XmiBLPU0n55l72!RBcW)rem4&ah~>@*t-Z`mwonoR(H2m%$ZOsw#c&lh}M822O6 z7tyz?I#?C6Bw}TYvRoqaV-`ddGFW1-s`~I_gbaQ~^fmCmEKTC20jg`D>g=Oo|Ia~M zt3kInSUW&WPE$`?{)qL82 zK~#9!?OMHW+eQ@s-I&-Z4l~pa@VP z&QNp<(52|sCFl@05DI_PsvJ_5NZ;!~9(BA>CdH%5YmqmY%`dHUNCl|KmnWc;35*5QMSv!eb)%VZ5>9p}5y0X(75_>zUq6gDs+xKbO~)>-;`>oZ zne~lw000bxz-4kga`UQqjK_*l6f+Pab1I`So?Bby7+i_e1pweI5Sjb7%P^RT%y%@( z0WM>?8&8RgMAi(EH9wcJbc3qT%gqK+JT7GvWNBP(xl`7@Wlca&u}<&~_Q_EVGRNpO0df zu$BX!_wE%g%Hsgl|7A{~W`HT5I9ZpliUaoguS=)GItR#2T}4PwQz}KK$j8HJc(jEB z9G3Xp?~`z@Vy49ynBtqCQafHRlJyg1{Stxuz(-E9-j7d@DJR%e9>AI|hXG)j^GY0W zB?Nw(gsc`0Xi6IAfOq|XMAN4AylFq7@qR$ndfv33U`;=uYCUh-Pp~2nFs#{eY_VylFqdnp&W0J#X4iu%;F;spn1m30Cw2OzL^leu5SKfU5PpX+Oal z4yansoAwi|;Q*6*-n5@!ML)o#o;U3$yz2)v*biu2HUQcH=%@R;^mu!RHUN6C)gw7x zG+#>?v_byt_tX1f6wN*VpSOSqTRr;f&fWBsA8+rZ_czV|FD&4@`@7g(yNgxF!Lz{$ z0N}k|FTF3CHzL7!IQH-R-HIC zIXdlUaI@ym0kfv4%NV{LzA5z~hpQ_DU~YUFk*9fd+Q*k$y}9QryFgeFe)hW^QbX9h z__A_z+Q-+MJv`dp$tAg>`N|5=)5(XoyQFUBsbaz|W0)5|k31Wk;K^AZFD_0h%~w)@ znvy=e-KB5-zD(cxsph|9%BHYo@MYt;B)S(DC%Gm*Yu+?ZaAYq}-%OrJY!$p|oL^X; zaG?0?ERkk@(CyH?c+)t)=sbZJ`RRVQlb&=Q2NdD!i1Ulg6WHPE3dyjhlbHUjhru%V zABS&X66a0li}Hk&1of9MBEhowyf|Kz2P|TKrULkkm!Fk4&x@}s&MzuYa8%PSN`+NZ zFPjSMr!UbAj@EpDp->bAZamGT*le zUwa}ni*WLM)CRn<0;Cz``J8TsveL5&Z>#_>$pp&O_p;2j32!P)GO7Ac3~JdK66Knv dEqK#%_#eU6y=%;__wWD!002ovPDHLkV1lEd_=5ld literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/farm_nether_particle.png b/src/main/resources/assets/forestry/textures/blocks/farm_nether_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..4c91f68b1a9b9dbbc6ab36d3c94dcd2f5c642759 GIT binary patch literal 387 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPdBd>_OJhT4GW(EdE0Z$jl5R21GC)@iUHV`;kU)~k$ zvb{%e?hUPvwh_NFBY(vTaEHuPc2!vFX4iJC?=!o`qiLUi-m|s0y}e0)?%vsq56%`S z<+#pxfAqxbwH!x#wfL8M_ulLAnrha<^5$%SN9hr}`L?aR>UXE}wLjP?P;&4?#I4!S z!~b{A40Orld$@An<5?Ca%eUw)ayjpMGWqkj#gmfv9!~z!T*SH}WM#|ZcTnwJBelF{r5}E*0>Y6VA literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/peat_bog.png b/src/main/resources/assets/forestry/textures/blocks/peat_bog.png new file mode 100644 index 0000000000000000000000000000000000000000..700845a12f905251450cf84b5539ef253ac77fc7 GIT binary patch literal 1561 zcmV+!2Il#RP)UGkjH+D5;5)8Ucc$>mnbJtg;A@Z!XY+OaYn?1yjJc3{10I2{%3Zw#v1A-)z2x$&VMSeB!Lkiri830(F-!O@HFCx9R z6%qu6PSrJaA5nt89#YtfFLFcU&De)e0VaTHNU>%DOhB(yuXh^;brt|_gE=0TD_qW} zxMds&^7X*?kTI@tkINMR;MY-BI-+qg3h0MU1;DsK;Cr}RJYgPBAf-gcI0zwFBumUDV>~=1n8y<^F7){glUQb= zHwRc7fRfy`rXd9&w4wmC@?1(l5coS6oQ4!hN^raT{x~4`g4_tR$++a|0Q4H!J+PD# zaZsEelmpZoT<^4IHQpb21Wc3-lVn8zCz*r{^85dumUuCp6s`^+V;q6+;c`CJUXi4- z^c{n8KuGHqSF+`0cVouGsq;$Nm$O*EWu@%na)o(3(Re9~3^6zdm?WsKRbwa*Ffmn8 z$||x`VKAGFwenKRXXggzfGP>9tBQM5OiYyoA2%x<>x*PrihWaY$`949)@H=K=CK{k-iwVeolC-+tb9p5V?rpl3g?=K($E z2~NxdZ2NiJdBWiH0NZ}vcAntGJfLqsZ#z$LrWfej&)d!uoaqH@`gz-Vf)n$AzWu!I zJi(cHK;M4ecAnr22lVadZRZKjaDYueZ#z$LVjf`A&)d!uzRv>&oCh4wlszT#sSG`u zr%eDJAxOD^M~VL2w4ZFh@qvi9d$oM$0vuAWDMg$1kCp|7lF*}C(P&2sTPE~pDbcvU zW#Zd502f7C+p=9c6cUUVskUw3$^aj(M$%+wbDU)|ak|IQO=&6>z#so^8e`NXMJ^;j zbFa|l^v(cH`&I@BDR6zW=|m(S-;5-1IKE9(EbDl$DAu-b)eEF8A@t#@P$CukJz*cd zLl%HX2`)lUyLaSM9pi2L)&>YGf9Lbt3u!82x^PI#{}b$jZxhCIg%p{E9tGn?jJNGu zhk*H(KEJ(?zx}h;3RL5_`bN9pyX1L*miXY1{kFf~RwwvzKx&n#6NNnlZ=2^&T_;dA zn`=@=xp|UF9Ew+ON5%0)=;_$L2)&cjb)w!Rtt^iShU0 z&6LGO{<~l^kDq$KGYQr`d=m*Cg161{r>qm`zK3sWmV3r1YswY@oycMWfCfG)Lt z7jX@L5D9jv?OnqkjRd=-7n7u1!5@tTn=Gqh&Lk;U@F(X0la0HOj%)aX3!yf`aSd;6 z0Odw?F;_=WuHmf>5YhISGYb#b@U}t}lbSzbsG9>+t?dflwjKT-UfydeHR8a#00000 LNkvXXu0mjfdph3b literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/peat_bog_particle.png b/src/main/resources/assets/forestry/textures/blocks/peat_bog_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..416d80ed6ba4dbbf290e64ba717dfed0c7308e5b GIT binary patch literal 412 zcmV;N0b~A&P)k80w0w}Ekx(GR8+tltP7#?hBrFjP=B307C>o5 z1>QfCW!#ee=K8G`;z+*Dd3)yOB!};)YXb`);^IE*cEJ<~bjeK!T@i?}tGPoQNP<$e zS$<;rhnegBtGsc%M0k?u`WtKiHlb&GyPk;T5OX~>!Bor$V$w|rU~beo=^n(X>Zxlk z!WA;V=QP=W8SFRrU**I=RoaJf^4()P*7rRo6>z(ihO-YH z`I&Pp)G_oW$?b(YbhUdyeohfiW9UpMm*vRU9c5;h%aT7$62!bXzVZS90000bwGkg3!st!&SHvzzz)-uHfF z*^wh}%eWZ>0DAotuEPWALj!q9{_HK*k{Dd%d381Ar)s5Jh!7c<^}eyrC2e+)-C= z^@eNpPIliG5>d3F&aadMh?JVm-Rx}+l-DH;YuQ`Z3{$T+)PB9*KwD(5cYl@R-%hGR z005q~(vka`$41VtoCCaySEx8i9Jk@RiY|~OLNPj>Ck6GGCuLi`Y@MVnq&mNH4$w(3 z9|Cy~&@p)-Wrt)(VIUFJm{NR?aaYX&c@m^6#l0>%CQpK-ECB4Zvn$2Et~hy$etwl4 zz!_uUobP$NVOZM()-jxOFvdXVDdsnW?EcU`uH2v2DMVr+)%kH8P!#k33kT>auP6JO_|c zogUOW8HGyZN4vxHXbT6pj+@2Yy?YO}W~N@+%=lFwjysIa4?a0j+6=vuYli6jD(e8Y z>UNk2cODLi<2LTz{fjMx16Cy~=YW^Nk4BoPq1PhFmFF^ zI!~}>9x!h|Z#qw~h6Cp9=S}Ac)^LDHKW{ouuwouy($AaD6JE{(RyYq}Sh2kI+I}h1 z6mBJRaRBJ|dSGDKdEUY1dVop$jaK)?9*D>^#aCY*fa|947(-hO^|^dyyL7+N>f*&V z03`Zpf`ic}7-R5U7fIU3)9nW2pfD@jf1wTFxGo&-LpmIBs{EB@7UvxOZX42BM-Ws8YmO?h0hI0=^#Yevuui*6q>#7D=_WsNqP(*5^>@+c*$1ft!FSAbI;~2b%)Fv^08QwI{ zFRM;aBv|y}Cz0T^_(kOTW!4EUfhN6ay=WPy>^Quh$BSwJ088JWn1+{K3jg`b9hkJc zru(I7kPb~FH1VOyjOYrig#nUI0SS#3{+j!pQ5k>E7xMJFj+@WvkCd0uI4 zPccU&uTA)+bAZmqRPWn_Uw9!jj&O=%)CRn<0mzMtVlMB7)aluTH#R^J22=O<)aKfR sHx))qs{a#%-gb(vD0EF*@TTqXe^%`T=7+w^*#H0l07*qoM6N<$f@mo>7XSbN literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/plantation_particle.png b/src/main/resources/assets/forestry/textures/blocks/plantation_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..3ae105a84399d524ffc9f21bd41c037dfa24dc93 GIT binary patch literal 445 zcmV;u0Yd(XP)w8zrMXw?n|_5&6tRX$0sha z*>qBW>#C}dogk6}aDR9EXD9Q;5|JF)2~}00f*`KwmH+@^m>_`d0ORH0UvYhZ7GPhr{uC zUhFkAdwTAt!&Vq)e@TrPjfDGO!WLTl`er-A%oIPdeTlQ%-qzXF=X&p2G!Sr|`lt&b zZ*saTivsAsLLlXQHrCf8OO`%Z<81`4TPDJfq9mF1-kC+TMNNVo+oE=99~KrCGJSl; zn$o+qw187l@ccl{-7=nvQ#-@xHrT17y3_$xD0J=_tEdFC8>v3RaNQ8t+STl$U<0l{n(WQNdzcY!Y`@W!)_uHgJv)UD zYY0|a>o^KLdexO8)Zj5#-o4Q{7PV7AzrOUbb+kDE``GLK^Ee)$&xVPK2|K9~zLyco`7%$jqNoa-3d!>pE2j>DpJ@()VnM zr%&((+-YdqOv|o66mH!`XSnJkqj6o2TFu|1TvmVBfp-KXqWuy)CaV~9=YfO{`>z&+|iG42vAKgptC zZRKO3&YU&&?fC3#lvOA7TzQjef4{eXL0r`e+$uARN}IHI>R;!8s-CX+S%Ik7y5rxv z@r|R0zfBykA)g3bSje8Y!OvKT7+|smjq+lxKQ?BdJzX-Y;H%ZbB=;&v#bL-eaq$3D zD)}+p+pR*nzR@jJEf~dfi?Q$dU@RGL?md|J8g*86xP^d$SSv2WDR8{F5jQew_hhqF zv6q@Wvg-8SL8z)KE{)^s%C=JPnl@RIHOp8cFp$P>!*3r=$d=FM7OfQ4&ycsXLy`~Y zAgu0so;(+Wj*w@GvDS8}SH2c#qOW<6Lw|RW{-khqsVMly($Lfd@7%(Bag#9GN2Js- z)bzJk7g1+h*1wVF=*wrJL*)7I%V~4d&`SC(btnP?JIxP^biIEsKVQ_bhJ8&E{X z)Qjig@uoflBG7eG>D@EBL^JtPu1W$5wYhuO*NKIX-LOGjf!wyYTbR+^l&x?XH$1Gy zpTr_bl}$-K3e{9Abw7oxEx_(H5lly;FzM-Z_p42q$9zc)A=Wvk?8sfh_xo7=Q-;!f zRc-1#FF;aqsxn~WN@=l}h@iB@^Y4p?3RHW-KkGd8_4h$7K@ns>yG`s~r_0hjg@Dyc zWC#+3`eHLa&igSObfXid7Jk0_s)J+q;2oxLa@`Dj3fGb?si$H}(mrrz8Byv&(tz3V$zYCzw<7VuQ}b;feFbGrzlmJLD8jlh%8_dWO;^C#_=b~ynRxe%MZPDcvV^6Z%V*dzbr z9#L;$vT5f0;1`!mx;i`gZ}BcF=snS@4t^Yrv?g846wNGk44Nz7%T@D<6yF(OhEz6O zi>Yhov7^Wo#>=Z`qtR$ranIIL>kjN~IIqvePX`1yEaW~9_pViGr_>hX`V89+Lj01= zrijeU_b|$Wp_^r4Su}*9b_UT}z`gf^~ZC>@g#~wf1 z1UZ!N!^pRZ+oCXE5}JWeWq}89WetYSwJ`EXDI8Z!Cr`QK}w1C_%J@DjmPpknwfQ&G1C3Uad+9wlodZ@9x=rcIJ|G0* z81f1-|6Co3cCVu4ZPSqi!O68y@`##Tx^ac~GjQ32Sx?S6D53nPygu17mlV$%4lnm> z-xL*;wR)(D-r#??y1fz)8$uu95g!l~aIIIKl(Axyu#@anaxV8$DaZlPFQT@d6DxJg zy%7&`7QaHr9??u24_yiT@($}i9v>_A+ITAWuJ8|~?OUs=HSW)0QkmqMagWfO7xKp9 z%?pKX!B=~n$ z$+1WYd7}?|Uy~8XPT}q)M7o7<(6TYBe9jFr{6;~vPxGsj^5OpQelu@&FAU>TH`_DW z%l9&Kdiy;2)!>S&G_A=Jxt%)M)Sa}tp|y*SDGy80E1)#4wwU$C8gBLK-t=Vr8p3wb z$JVFaieQ~8xD)~Yh)QKYZs!F~bh-W!5^~~1x-jm#D86yu~H6Hs*8UK^tMjUXB7ScBGWamce`4RWXCZ+%$?l?f8@2K_EJ-1fky z30Dr~01X~CXAb4ajqzYgJ!xic?(N;WV$meZ{SFL>0RS5SfPrY>4<-oE1AxN-z`TE}Q%>rC7Ybaye0lWYm9y?$ zpI7=8Nw@M;T;0I_v0SOsE;=Hwm=AsC*PGN*E${hFO=%29dIUyv0B|BOsFJB9+piH2ARJ|i zR`}Dh{;gO&AQv1B0J*oywYkN-ehqcdup(+}NP|_(AzeRg8;CiI?3}y|+Ry$hK|T4* zxSs}3eE46n_Pg{TXLbg!&Ri1)VqFJ!HJW@Gaen%`T+-l3Q(FM7)E?+N!AZRkEX*K4 z6IX2J1 zSa{Om|{f?;rlliY+{hR83 nY3BcBLG&Mw$zOqwUf$GQC>LAy?}jjz0Dy_1xj~J-bL>9=pwFV- literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/gui/buttons.png b/src/main/resources/assets/forestry/textures/gui/buttons.png index dc5ee1feeba2f6c88deff70725c9c5b6aca7eb25..c2d3824e4fcef2172cf26d9a8a391f5285d235d6 100755 GIT binary patch delta 37 tcmX@&bHrzY7GwBE?K6xl^?fbZC;w)&;CjT!D`p_kb9sXDW?Lq96#yI>4VC}^ delta 37 tcmX@&bHrzY79+z(?K6xlp^IBsCjVx%;Cjd<%B!va@=)K4&9+SJDgXxa4SxUt diff --git a/src/main/resources/assets/forestry/textures/gui/planter.png b/src/main/resources/assets/forestry/textures/gui/planter.png new file mode 100644 index 0000000000000000000000000000000000000000..2b71e1ff1f9b6fff778c5977b57075db2eb67e43 GIT binary patch literal 727 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K58CaNs)Vi3hp+HJ2z$e7@7#M_xhSoDMba!{J zQV`jpAaX^D$K2c;sN_Eo2r+ySVJ;~t2}$3z3}i-0kY6x^!?PP{AWo9Ey9+}HtE>l* z!&%@FS+M{_tiuK( z4qMZDK2ETly}hZLvAJE~18Y@_+`{5pY?mBfOv`K3J1bb!a!$@mv3#ZUn;i=~gH8t3 z$L=@hOu2A+`o2H9(u=NKvgS6Oo9}(ayej+so)tHrZ84T;YO*d-dJvZ2zfDZ+N2KRB%eq-=i$U9ih={gEM(6yZEiZE!1U{K!s)olIv1wTownCa&|yK{yW8gb_!6&XPh$PY>Y|h| zh4sG?6UPMBtCt0`85*~7w`|+H?j37l(#_j@6jn-^?R_gOFrP`jdqP*oTmi;S4Vn%O zIuCkQ_%i+4et6p6cl#6zKSt^^acpr}VD)zXj;tA6KBwj;zggADz{H`@03^2fCB%e& zS|=6a0^tJ%MFm9#p|T1Nu1Bh!SyprjIxsM@2mpyyNm))TT5VB{aRy)d!W?XWiAQ9x kR{i^L?*K}j$ROhfgYwi5ug#sdfKnENr>mdKI;Vst0Et!;Y5)KL literal 0 HcmV?d00001 From 521514f3d2e7c1e97d32f4da0165b8dc6778ad88 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Sun, 14 Jan 2018 02:53:56 +0100 Subject: [PATCH 02/12] Remove Unused Files --- lang | 2 +- .../api/cultivation/IPlanterHousing.java | 29 -- .../inventory/InventoryPlanter.java | 9 +- .../cultivation/items/package-info.java | 10 - .../cultivation/network/package-info.java | 10 - .../cultivation/tiles/TilePlanter.java | 348 +++++++++--------- .../forestry/textures/gui/arboretum.png | Bin 3384 -> 0 bytes 7 files changed, 177 insertions(+), 231 deletions(-) delete mode 100644 src/main/java/forestry/api/cultivation/IPlanterHousing.java delete mode 100644 src/main/java/forestry/cultivation/items/package-info.java delete mode 100644 src/main/java/forestry/cultivation/network/package-info.java delete mode 100644 src/main/resources/assets/forestry/textures/gui/arboretum.png diff --git a/lang b/lang index cf9f2c21f..7b6f08376 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit cf9f2c21f53e6ad4ce180bdccf258ff7e717ce94 +Subproject commit 7b6f08376464eaade21f3a438981e519e046fa57 diff --git a/src/main/java/forestry/api/cultivation/IPlanterHousing.java b/src/main/java/forestry/api/cultivation/IPlanterHousing.java deleted file mode 100644 index 3d1a4a1c8..000000000 --- a/src/main/java/forestry/api/cultivation/IPlanterHousing.java +++ /dev/null @@ -1,29 +0,0 @@ -package forestry.api.cultivation; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import forestry.api.farming.IFarmInventory; -import forestry.api.farming.IFarmLogic; -import forestry.api.farming.IFarmable; -import forestry.api.genetics.IHousing; - -public interface IPlanterHousing extends IHousing { - /** - * Callback for {@link IFarmLogic}s to plant a sapling, seed, germling, stem. - * Will remove the appropriate germling from the farm's inventory. - * It's up to the logic to only call this on a valid location. - * - * @return true if planting was successful, false otherwise. - */ - boolean plantGermling(IFarmable germling, World world, BlockPos pos); - - /* INTERACTION WITH HATCHES */ - IFarmInventory getFarmInventory(); - - /* LOGIC */ - IFarmLogic getFarmLogic(); - - /* GUI */ - int getStoredFertilizerScaled(int scale); -} diff --git a/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java b/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java index 09267c68e..00feb1680 100644 --- a/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java +++ b/src/main/java/forestry/cultivation/inventory/InventoryPlanter.java @@ -13,7 +13,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; import forestry.api.core.ForestryAPI; -import forestry.api.cultivation.IPlanterHousing; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmable; @@ -21,9 +20,9 @@ import forestry.core.fluids.FluidHelper; import forestry.core.fluids.TankManager; import forestry.core.inventory.InventoryAdapterRestricted; import forestry.core.inventory.wrappers.InventoryMapper; -import forestry.core.tiles.ILiquidTankTile; import forestry.core.utils.InventoryUtil; import forestry.core.utils.SlotUtil; +import forestry.cultivation.tiles.TilePlanter; import forestry.farming.multiblock.IFarmInventoryInternal; public class InventoryPlanter extends InventoryAdapterRestricted implements IFarmInventoryInternal { @@ -43,14 +42,14 @@ public class InventoryPlanter extends InventoryAdapterRestricted implements IFar private static final int FERTILIZER_MODIFIER = ForestryAPI.activeMode.getIntegerSetting("farms.fertilizer.modifier"); - private final IPlanterHousing housing; + private final TilePlanter housing; private final IInventory resourcesInventory; private final IInventory germlingsInventory; private final IInventory productInventory; private final IInventory fertilizerInventory; - public InventoryPlanter(IPlanterHousing housing) { + public InventoryPlanter(TilePlanter housing) { super(SLOT_COUNT, "Items"); this.housing = housing; @@ -70,7 +69,7 @@ public class InventoryPlanter extends InventoryAdapterRestricted implements IFar return acceptsAsResource(itemStack); } else if (SlotUtil.isSlotInRange(slotIndex, SLOT_CAN, SLOT_CAN_COUNT)) { FluidStack fluid = FluidUtil.getFluidContained(itemStack); - return fluid != null && ((ILiquidTankTile) housing).getTankManager().canFillFluidType(fluid); + return fluid != null && housing.getTankManager().canFillFluidType(fluid); } return false; } diff --git a/src/main/java/forestry/cultivation/items/package-info.java b/src/main/java/forestry/cultivation/items/package-info.java deleted file mode 100644 index 05d9468d4..000000000 --- a/src/main/java/forestry/cultivation/items/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -package forestry.cultivation.items; - -import javax.annotation.ParametersAreNonnullByDefault; - -import mcp.MethodsReturnNonnullByDefault; - -import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/network/package-info.java b/src/main/java/forestry/cultivation/network/package-info.java deleted file mode 100644 index f0aea46cf..000000000 --- a/src/main/java/forestry/cultivation/network/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -@ParametersAreNonnullByDefault -@FieldsAreNonnullByDefault -@MethodsReturnNonnullByDefault -package forestry.cultivation.network; - -import javax.annotation.ParametersAreNonnullByDefault; - -import mcp.MethodsReturnNonnullByDefault; - -import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index 88864b88c..2bede2c47 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -6,7 +6,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.EnumMap; -import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -28,7 +27,6 @@ import net.minecraftforge.fluids.FluidStack; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; import forestry.api.core.IErrorLogic; -import forestry.api.cultivation.IPlanterHousing; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; @@ -64,28 +62,28 @@ import forestry.farming.gui.IFarmLedgerDelegate; import forestry.farming.multiblock.FarmFertilizerManager; import forestry.farming.multiblock.FarmHydrationManager; -public abstract class TilePlanter extends TilePowered implements IFarmHousing, IPlanterHousing, IClimatised, ILiquidTankTile, IOwnedTile, IStreamableGui { +public abstract class TilePlanter extends TilePowered implements IFarmHousing, IClimatised, ILiquidTankTile, IOwnedTile, IStreamableGui { private final static int ALLOWED_EXTENT = 4; - private int platformHeight = -1; private final Map> targets = new EnumMap<>(FarmDirection.class); private final Stack pendingProduce = new Stack<>(); private final List pendingCrops = new LinkedList<>(); private final IFarmLogic logic; + private final FarmHydrationManager hydrationManager; private final FarmFertilizerManager fertilizerManager; private final InventoryPlanter inventory; private final TankManager tankManager; private final StandardTank resourceTank; private final OwnerHandler ownerHandler = new OwnerHandler(); + + private int platformHeight = -1; private Stage stage = Stage.CULTIVATE; @Nullable private Vec3i offset; @Nullable private Vec3i area; - @Nullable - public Iterator areaIterator; public TilePlanter(String identifier) { this(FarmRegistry.getInstance().getFarmLogic(identifier)); @@ -105,53 +103,6 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I setTicksPerWorkCycle(2); } - @Override - public NBTTagCompound writeToNBT(NBTTagCompound data) { - data = super.writeToNBT(data); - hydrationManager.writeToNBT(data); - tankManager.writeToNBT(data); - fertilizerManager.writeToNBT(data); - ownerHandler.writeToNBT(data); - return data; - } - - @Override - public void readFromNBT(NBTTagCompound data) { - super.readFromNBT(data); - hydrationManager.readFromNBT(data); - tankManager.readFromNBT(data); - fertilizerManager.readFromNBT(data); - ownerHandler.readFromNBT(data); - } - - @Override - public NBTTagCompound getUpdateTag() { - NBTTagCompound data = super.getUpdateTag(); - hydrationManager.writeToNBT(data); - tankManager.writeToNBT(data); - fertilizerManager.writeToNBT(data); - return data; - } - - @Override - public void writeGuiData(PacketBufferForestry data) { - tankManager.writeData(data); - hydrationManager.writeData(data); - fertilizerManager.writeData(data); - } - - @Override - public void readGuiData(PacketBufferForestry data) throws IOException { - tankManager.readData(data); - hydrationManager.readData(data); - fertilizerManager.readData(data); - } - - @Override - public IOwnerHandler getOwnerHandler() { - return ownerHandler; - } - @Override public void setPos(BlockPos posIn) { super.setPos(posIn); @@ -163,12 +114,6 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return true; } - @Override - public void invalidate() { - super.invalidate(); - targets.clear(); - } - @Override protected void updateServerSide() { super.updateServerSide(); @@ -251,8 +196,90 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return false; } - protected final BlockPos translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) { - return VectUtil.scale(farmDirection.getFacing().getDirectionVec(), step).add(pos); + @Override + public NBTTagCompound writeToNBT(NBTTagCompound data) { + data = super.writeToNBT(data); + hydrationManager.writeToNBT(data); + tankManager.writeToNBT(data); + fertilizerManager.writeToNBT(data); + ownerHandler.writeToNBT(data); + return data; + } + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + hydrationManager.readFromNBT(data); + tankManager.readFromNBT(data); + fertilizerManager.readFromNBT(data); + ownerHandler.readFromNBT(data); + } + + @Override + public void writeGuiData(PacketBufferForestry data) { + tankManager.writeData(data); + hydrationManager.writeData(data); + fertilizerManager.writeData(data); + } + + @Override + public void readGuiData(PacketBufferForestry data) throws IOException { + tankManager.readData(data); + hydrationManager.readData(data); + fertilizerManager.readData(data); + } + + private void setUpFarmlandTargets() { + BlockPos targetStart = getCoords(); + + FarmHelper.createTargets(world, this, targets, targetStart, ALLOWED_EXTENT, 1, 1, pos, pos); + FarmHelper.setExtents(world, this, targets); + } + + private boolean cullCrop(ICrop crop) { + final int fertilizerConsumption = logic.getFertilizerConsumption(); + + IErrorLogic errorLogic = getErrorLogic(); + + // Check fertilizer + Boolean hasFertilizer = fertilizerManager.hasFertilizer(inventory, fertilizerConsumption); + if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) { + return false; + } + + // Check water + float hydrationModifier = hydrationManager.getHydrationModifier(); + int waterConsumption = logic.getWaterConsumption(hydrationModifier); + FluidStack requiredLiquid = new FluidStack(FluidRegistry.WATER, waterConsumption); + boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid); + + if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_LIQUID_FARM)) { + return false; + } + + NonNullList harvested = crop.harvest(); + if (harvested != null) { + // Remove fertilizer and water + fertilizerManager.removeFertilizer(inventory, fertilizerConsumption); + removeLiquid(requiredLiquid); + + inventory.stowHarvest(harvested, pendingProduce); + } + return true; + } + + private boolean collectWindfall() { + NonNullList collected = logic.collect(world, this); + if (collected.isEmpty()) { + return false; + } + + for (ItemStack produce : collected) { + inventory.addProduce(produce); + pendingProduce.push(produce); + } + + return true; } private FarmWorkStatus cultivateTargets(FarmWorkStatus farmWorkStatus, List farmTargets, FarmDirection farmSide) { @@ -296,100 +323,19 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return farmWorkStatus; } - private boolean collectWindfall() { - NonNullList collected = logic.collect(world, this); - if (collected.isEmpty()) { - return false; - } - - for (ItemStack produce : collected) { - inventory.addProduce(produce); - pendingProduce.push(produce); - } - - return true; - } - - private boolean cullCrop(ICrop crop) { - final int fertilizerConsumption = logic.getFertilizerConsumption(); - - IErrorLogic errorLogic = getErrorLogic(); - - // Check fertilizer - Boolean hasFertilizer = fertilizerManager.hasFertilizer(inventory, fertilizerConsumption); - if (errorLogic.setCondition(!hasFertilizer, EnumErrorCode.NO_FERTILIZER)) { - return false; - } - - // Check water - float hydrationModifier = hydrationManager.getHydrationModifier(); - int waterConsumption = logic.getWaterConsumption(hydrationModifier); - FluidStack requiredLiquid = new FluidStack(FluidRegistry.WATER, waterConsumption); - boolean hasLiquid = requiredLiquid.amount == 0 || hasLiquid(requiredLiquid); - - if (errorLogic.setCondition(!hasLiquid, EnumErrorCode.NO_LIQUID_FARM)) { - return false; - } - - NonNullList harvested = crop.harvest(); - if (harvested != null) { - // Remove fertilizer and water - fertilizerManager.removeFertilizer(inventory, fertilizerConsumption); - removeLiquid(requiredLiquid); - - inventory.stowHarvest(harvested, pendingProduce); - } - return true; - } - - @Override - public int getStoredFertilizerScaled(int scale) { - return fertilizerManager.getStoredFertilizerScaled(inventory, scale); - } - - @Override - public boolean hasLiquid(FluidStack liquid) { - FluidStack drained = resourceTank.drainInternal(liquid, false); - return liquid.isFluidStackIdentical(drained); - } - - @Override - public GuiContainer getGui(EntityPlayer player, int data) { - return new GuiPlanter(this, player.inventory); - } - - @Override - public Container getContainer(EntityPlayer player, int data) { - return new ContainerPlanter(this, player.inventory); - } - - @Override - public boolean plantGermling(IFarmable germling, World world, BlockPos pos) { - EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner()); - return player != null && inventory.plantGermling(germling, player, pos); - } - - @Override - public boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction) { - EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner()); - return player != null && inventory.plantGermling(farmable, player, pos, direction); - } - - @Override - public IFarmInventory getFarmInventory() { - return inventory; - } - - @Override - public IFarmLogic getFarmLogic() { - return logic; - } - @Override public BlockPos getCoords() { return pos; } + @Override + public Vec3i getArea() { + if (area == null) { + area = new Vec3i(7 + ALLOWED_EXTENT * 2, 13, 7 + ALLOWED_EXTENT * 2); + } + return area; + } + @Override public Vec3i getOffset() { if (offset == null) { @@ -399,25 +345,54 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return offset; } - @Override - public Vec3i getArea() { - if (area == null) { - area = new Vec3i(7 + ALLOWED_EXTENT * 2, 13, 7 + ALLOWED_EXTENT * 2); - } - return area; - } - @Override public boolean doWork() { return false; } + @Override + public boolean hasLiquid(FluidStack liquid) { + FluidStack drained = resourceTank.drainInternal(liquid, false); + return liquid.isFluidStackIdentical(drained); + } @Override public void removeLiquid(FluidStack liquid) { resourceTank.drain(liquid.amount, true); } + @Override + public boolean plantGermling(IFarmable germling, World world, BlockPos pos) { + EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner()); + return player != null && inventory.plantGermling(germling, player, pos); + } + + @Override + public IOwnerHandler getOwnerHandler() { + return ownerHandler; + } + + @Override + public boolean plantGermling(IFarmable farmable, World world, BlockPos pos, FarmDirection direction) { + EntityPlayer player = PlayerUtil.getFakePlayer(world, getOwnerHandler().getOwner()); + return player != null && inventory.plantGermling(farmable, player, pos, direction); + } + + @Override + public boolean isValidPlatform(World world, BlockPos pos) { + return pos.getY() == platformHeight; + } + + @Override + public boolean isSquare() { + return true; + } + + @Override + public IFarmInventory getFarmInventory() { + return inventory; + } + @Override public void setFarmLogic(FarmDirection direction, IFarmLogic logic) { } @@ -431,6 +406,44 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return getFarmLogic(); } + public IFarmLogic getFarmLogic() { + return logic; + } + + @Override + public int getStoredFertilizerScaled(int scale) { + return fertilizerManager.getStoredFertilizerScaled(inventory, scale); + } + + @Override + public void invalidate() { + super.invalidate(); + targets.clear(); + } + + @Override + public NBTTagCompound getUpdateTag() { + NBTTagCompound data = super.getUpdateTag(); + hydrationManager.writeToNBT(data); + tankManager.writeToNBT(data); + fertilizerManager.writeToNBT(data); + return data; + } + + protected final BlockPos translateWithOffset(BlockPos pos, FarmDirection farmDirection, int step) { + return VectUtil.scale(farmDirection.getFacing().getDirectionVec(), step).add(pos); + } + + @Override + public GuiContainer getGui(EntityPlayer player, int data) { + return new GuiPlanter(this, player.inventory); + } + + @Override + public Container getContainer(EntityPlayer player, int data) { + return new ContainerPlanter(this, player.inventory); + } + public IFarmLedgerDelegate getFarmLedgerDelegate() { return hydrationManager; } @@ -462,27 +475,10 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return tankManager; } - @Override - public boolean isValidPlatform(World world, BlockPos pos) { - return pos.getY() == platformHeight; - } - - @Override - public boolean isSquare() { - return true; - } - - private void setUpFarmlandTargets() { - BlockPos targetStart = getCoords(); - - FarmHelper.createTargets(world, this, targets, targetStart, ALLOWED_EXTENT, 1, 1, pos, pos); - FarmHelper.setExtents(world, this, targets); - } - public abstract ItemStack[] createGermlingStacks(); public abstract ItemStack[] createResourceStacks(); public abstract ItemStack[] createProductionStacks(); - + } diff --git a/src/main/resources/assets/forestry/textures/gui/arboretum.png b/src/main/resources/assets/forestry/textures/gui/arboretum.png deleted file mode 100644 index 8b8117d148f0cccdd709cda39216f360420f63b9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3384 zcmb_e3pAAL8vbVx5fW-#Lb;P$8Elu$79pWwkRe3nGUT4SL3X+3IxZ2D+c1NP2*prj za!bWfqA4@(xhJ{K8E5aa_CEXUz1KSHob|77{qOg#?|r}LeV+IG|1aU9xe+J3AUgm6 zoF>KwmH+@^m>_`d0ORH0UvYhZ7GPhr{uC zUhFkAdwTAt!&Vq)e@TrPjfDGO!WLTl`er-A%oIPdeTlQ%-qzXF=X&p2G!Sr|`lt&b zZ*saTivsAsLLlXQHrCf8OO`%Z<81`4TPDJfq9mF1-kC+TMNNVo+oE=99~KrCGJSl; zn$o+qw187l@ccl{-7=nvQ#-@xHrT17y3_$xD0J=_tEdFC8>v3RaNQ8t+STl$U<0l{n(WQNdzcY!Y`@W!)_uHgJv)UD zYY0|a>o^KLdexO8)Zj5#-o4Q{7PV7AzrOUbb+kDE``GLK^Ee)$&xVPK2|K9~zLyco`7%$jqNoa-3d!>pE2j>DpJ@()VnM zr%&((+-YdqOv|o66mH!`XSnJkqj6o2TFu|1TvmVBfp-KXqWuy)CaV~9=YfO{`>z&+|iG42vAKgptC zZRKO3&YU&&?fC3#lvOA7TzQjef4{eXL0r`e+$uARN}IHI>R;!8s-CX+S%Ik7y5rxv z@r|R0zfBykA)g3bSje8Y!OvKT7+|smjq+lxKQ?BdJzX-Y;H%ZbB=;&v#bL-eaq$3D zD)}+p+pR*nzR@jJEf~dfi?Q$dU@RGL?md|J8g*86xP^d$SSv2WDR8{F5jQew_hhqF zv6q@Wvg-8SL8z)KE{)^s%C=JPnl@RIHOp8cFp$P>!*3r=$d=FM7OfQ4&ycsXLy`~Y zAgu0so;(+Wj*w@GvDS8}SH2c#qOW<6Lw|RW{-khqsVMly($Lfd@7%(Bag#9GN2Js- z)bzJk7g1+h*1wVF=*wrJL*)7I%V~4d&`SC(btnP?JIxP^biIEsKVQ_bhJ8&E{X z)Qjig@uoflBG7eG>D@EBL^JtPu1W$5wYhuO*NKIX-LOGjf!wyYTbR+^l&x?XH$1Gy zpTr_bl}$-K3e{9Abw7oxEx_(H5lly;FzM-Z_p42q$9zc)A=Wvk?8sfh_xo7=Q-;!f zRc-1#FF;aqsxn~WN@=l}h@iB@^Y4p?3RHW-KkGd8_4h$7K@ns>yG`s~r_0hjg@Dyc zWC#+3`eHLa&igSObfXid7Jk0_s)J+q;2oxLa@`Dj3fGb?si$H}(mrrz8Byv&(tz3V$zYCzw<7VuQ}b;feFbGrzlmJLD8jlh%8_dWO;^C#_=b~ynRxe%MZPDcvV^6Z%V*dzbr z9#L;$vT5f0;1`!mx;i`gZ}BcF=snS@4t^Yrv?g846wNGk44Nz7%T@D<6yF(OhEz6O zi>Yhov7^Wo#>=Z`qtR$ranIIL>kjN~IIqvePX`1yEaW~9_pViGr_>hX`V89+Lj01= zrijeU_b|$Wp_^r4Su}*9b_UT}z`gf^~ZC>@g#~wf1 z1UZ!N!^pRZ+oCXE5}JWeWq}89WetYSwJ`EXDI8Z!Cr`QK}w1C_%J@DjmPpknwfQ&G1C3Uad+9wlodZ@9x=rcIJ|G0* z81f1-|6Co3cCVu4ZPSqi!O68y@`##Tx^ac~GjQ32Sx?S6D53nPygu17mlV$%4lnm> z-xL*;wR)(D-r#??y1fz)8$uu95g!l~aIIIKl(Axyu#@anaxV8$DaZlPFQT@d6DxJg zy%7&`7QaHr9??u24_yiT@($}i9v>_A+ITAWuJ8|~?OUs=HSW)0QkmqMagWfO7xKp9 z%?pKX!B=~n$ z$+1WYd7}?|Uy~8XPT}q)M7o7<(6TYBe9jFr{6;~vPxGsj^5OpQelu@&FAU>TH`_DW z%l9&Kdiy;2)!>S&G_A=Jxt%)M)Sa}tp|y*SDGy80E1)#4wwU$C8gBLK-t=Vr8p3wb z$JVFaieQ~8xD)~Yh)QKYZs!F~bh-W!5^~~1x-jm#D86yu~H6Hs*8UK^tMjUXB7ScBGWamce`4RWXCZ+%$?l?f8@2K_EJ-1fky z30Dr~01X~CXAb4ajqzYgJ!xic?(N;WV$meZ{SFL>0RS5SfPrY>4<-oE1AxN-z`TE}Q%>rC7Ybaye0lWYm9y?$ zpI7=8Nw@M;T;0I_v0SOsE;=Hwm=AsC*PGN*E${hFO=%29dIUyv0B|BOsFJB9+piH2ARJ|i zR`}Dh{;gO&AQv1B0J*oywYkN-ehqcdup(+}NP|_(AzeRg8;CiI?3}y|+Ry$hK|T4* zxSs}3eE46n_Pg{TXLbg!&Ri1)VqFJ!HJW@Gaen%`T+-l3Q(FM7)E?+N!AZRkEX*K4 z6IX2J1 zSa{Om|{f?;rlliY+{hR83 nY3BcBLG&Mw$zOqwUf$GQC>LAy?}jjz0Dy_1xj~J-bL>9=pwFV- From 10fec504571bf3f392b0013cfda018699174b04c Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Sun, 14 Jan 2018 17:31:53 +0100 Subject: [PATCH 03/12] Improve Farm Logic System and add ring farm layout --- lang | 2 +- .../forestry/api/farming/IFarmHousing.java | 4 + .../forestry/api/farming/IFarmInstance.java | 30 +++++ .../java/forestry/api/farming/IFarmLogic.java | 49 +++++++- .../forestry/api/farming/IFarmRegistry.java | 62 +++++++++- .../api/farming/ISimpleFarmLogic.java | 10 +- src/main/java/forestry/api/farming/ISoil.java | 16 +++ .../java/forestry/core/blocks/BlockBase.java | 5 +- .../core/circuits/CircuitRegistry.java | 6 +- .../java/forestry/core/circuits/Circuits.java | 17 ++- .../java/forestry/core/config/Config.java | 9 ++ .../cultivation/ModuleCultivation.java | 6 + .../cultivation/blocks/BlockPlanter.java | 85 ++++++++++++++ .../blocks/BlockRegistryCultivation.java | 34 ++++-- .../blocks/PlanterStateMapper.java | 43 +++++++ .../cultivation/items/ItemBlockPlanter.java | 19 +++ .../cultivation/items/package-info.java | 10 ++ .../cultivation/tiles/TilePlantation.java | 7 +- .../cultivation/tiles/TilePlanter.java | 44 +++++-- .../forestry/farming/DummyFarmRegistry.java | 40 ++++++- .../java/forestry/farming/FarmRegistry.java | 63 +++++++--- .../java/forestry/farming/ModuleFarming.java | 75 ++++++++---- .../farming/circuits/CircuitFarmLogic.java | 16 ++- .../farming/logic/FakeFarmInstance.java | 54 +++++++++ .../forestry/farming/logic/FarmInstance.java | 80 +++++++++++++ .../forestry/farming/logic/FarmLogic.java | 70 ++++++++---- .../farming/logic/FarmLogicArboreal.java | 26 +++-- .../farming/logic/FarmLogicCocoa.java | 5 + .../farming/logic/FarmLogicCrops.java | 48 ++------ .../forestry/farming/logic/FarmLogicExU.java | 35 +----- .../farming/logic/FarmLogicGourd.java | 32 +----- .../farming/logic/FarmLogicHomogeneous.java | 79 ++++--------- .../farming/logic/FarmLogicInfernal.java | 12 +- .../farming/logic/FarmLogicMushroom.java | 7 +- .../farming/logic/FarmLogicOrchard.java | 13 +-- .../forestry/farming/logic/FarmLogicPeat.java | 16 +-- .../farming/logic/FarmLogicReeds.java | 44 +------ .../farming/logic/FarmLogicRubber.java | 6 +- .../farming/logic/FarmLogicSimple.java | 12 +- .../forestry/farming/logic/FarmLogicSoil.java | 19 +-- .../farming/logic/FarmLogicSucculent.java | 47 ++------ .../farming/logic/FarmLogicWatered.java | 49 +++----- .../java/forestry/farming/logic/Soil.java | 56 ++++----- .../farming/logic/crops/CropBasicIC2Crop.java | 3 + .../farming/logic/crops/CropDestroy.java | 27 +++++ .../logic/farmables/FarmableAgingCrop.java | 2 +- .../logic/farmables/FarmableSapling.java | 108 +++++++++--------- .../forestry/farming/logic/package-info.java | 5 +- .../multiblock/FakeFarmController.java | 4 +- .../farming/multiblock/FarmController.java | 4 +- .../plugins/PluginExtraUtilities.java | 25 ++-- src/main/java/forestry/plugins/PluginIC2.java | 5 +- .../java/forestry/plugins/PluginNatura.java | 8 +- 53 files changed, 1019 insertions(+), 534 deletions(-) create mode 100644 src/main/java/forestry/api/farming/IFarmInstance.java create mode 100644 src/main/java/forestry/api/farming/ISoil.java create mode 100644 src/main/java/forestry/cultivation/blocks/PlanterStateMapper.java create mode 100644 src/main/java/forestry/cultivation/items/ItemBlockPlanter.java create mode 100644 src/main/java/forestry/cultivation/items/package-info.java create mode 100644 src/main/java/forestry/farming/logic/FakeFarmInstance.java create mode 100644 src/main/java/forestry/farming/logic/FarmInstance.java diff --git a/lang b/lang index 7b6f08376..4ee2f885f 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 7b6f08376464eaade21f3a438981e519e046fa57 +Subproject commit 4ee2f885f8f6af1b3d498667bae4d59dbcd69551 diff --git a/src/main/java/forestry/api/farming/IFarmHousing.java b/src/main/java/forestry/api/farming/IFarmHousing.java index cc19ebd9f..c6a22061e 100644 --- a/src/main/java/forestry/api/farming/IFarmHousing.java +++ b/src/main/java/forestry/api/farming/IFarmHousing.java @@ -61,6 +61,10 @@ public interface IFarmHousing extends IErrorLogicSource { return false; } + default boolean canPlantSoil(boolean manual){ + return true; + } + /* INTERACTION WITH HATCHES */ IFarmInventory getFarmInventory(); diff --git a/src/main/java/forestry/api/farming/IFarmInstance.java b/src/main/java/forestry/api/farming/IFarmInstance.java new file mode 100644 index 000000000..6903e2711 --- /dev/null +++ b/src/main/java/forestry/api/farming/IFarmInstance.java @@ -0,0 +1,30 @@ +package forestry.api.farming; + +import java.util.Collection; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +/** + * @since Forestry 5.8 + */ +public interface IFarmInstance { + + default void registerSoil(ItemStack resource, IBlockState soilState){ + registerSoil(resource, soilState, false); + } + + void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData); + + boolean isAcceptedSoil(IBlockState blockState); + + boolean isAcceptedResource(ItemStack itemStack); + + String getIdentifier(); + + Collection getSoils(); + + Collection getFarmables(); + + IFarmLogic getLogic(boolean manuel); +} diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index 873fcc353..640e53661 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -8,6 +8,7 @@ package forestry.api.farming; import java.util.Collection; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; @@ -17,10 +18,20 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import forestry.api.core.ForestryAPI; + public interface IFarmLogic { + /** + * @return The amount of fertilizer that the {@link IFarmHousing} automatically removes after this logic cultivated + * a block or harvested a crop. + */ int getFertilizerConsumption(); + /** + * @return The amount of water that the {@link IFarmHousing} automatically removes after this logic cultivated + * a block or harvested a crop. + */ int getWaterConsumption(float hydrationModifier); boolean isAcceptedResource(ItemStack itemstack); @@ -33,20 +44,50 @@ public interface IFarmLogic { Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent); - IFarmLogic setManual(boolean manual); + /** + * @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmInstance} and + * have a immutable manual state. TODO Remove this method in 1.13 + */ + @Deprecated + default IFarmLogic setManual(boolean manual){ + return this; + } - void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData); + /** + * @since Forestry 5.8 + * + * @return Returns the {@link IFarmInstance} that created this logic. Returns a fake instance from + * {@link IFarmRegistry#createFakeInstance(IFarmLogic)} if the logic is older that Forestry 5.8. + */ + default IFarmInstance getInstance(){ + return ForestryAPI.farmRegistry.createFakeInstance(this); + } + /** + * Use {@link IFarmRegistry#getFarm(String)} to get the soil container for the farm logic and register the soil + * with {@link IFarmInstance#registerSoil(ItemStack, IBlockState, boolean)}. + */ + @Deprecated + default void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){ + // + } + + /** + * @return A short localized name for this logic. + */ String getName(); /* GUI ONLY */ /** - * @deprecated TODO remove this method in 1.13 + * @deprecated No longer needed because mc always uses the same map for blocks and items. + * TODO remove this method in 1.13 */ @Deprecated @SideOnly(Side.CLIENT) - ResourceLocation getTextureMap(); + default ResourceLocation getTextureMap(){ + return TextureMap.LOCATION_BLOCKS_TEXTURE; + } /** * @return the itemStack that represents this farm logic. Used as an icon for the farm logic. diff --git a/src/main/java/forestry/api/farming/IFarmRegistry.java b/src/main/java/forestry/api/farming/IFarmRegistry.java index 0b8d8bb9a..760c6ce08 100644 --- a/src/main/java/forestry/api/farming/IFarmRegistry.java +++ b/src/main/java/forestry/api/farming/IFarmRegistry.java @@ -7,6 +7,7 @@ package forestry.api.farming; import javax.annotation.Nullable; import java.util.Collection; +import java.util.function.BiFunction; import net.minecraft.item.ItemStack; @@ -16,9 +17,29 @@ public interface IFarmRegistry { * Registers farming logic in registry under given identifier * @param identifier Valid identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom * @param logic corresponding instance of logic + * + * @deprecated Since Forestry 5.8. Use {@link #registerLogic(String, BiFunction, String...)} or + * {@link #registerLogic(IFarmInstance)}. */ - void registerFarmLogic(String identifier, IFarmLogic logic); - + @Deprecated + void registerLogic(String identifier, IFarmLogic logic); + + /** + * Registers farming logic in registry + * @since Forestry 5.8 + */ + IFarmInstance registerLogic(IFarmInstance farmInstance); + + /** + * Registers farming logic in registry under given identifier + * + * @param identifier Valid identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom + * @param logicFactory factory that creates the corresponding instance of logic + * @param farmablesIdentifiers Identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom + * @since Forestry 5.8 + */ + IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers); + /** * Can be used to add IFarmables to some of the vanilla farm logics. *

@@ -32,14 +53,18 @@ public interface IFarmRegistry { * Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic. * * @return Null if the farming plugin is not active. + * + * @deprecated Since Forestry 5.8. Use {@link #createCropLogic(IFarmInstance, boolean, ISimpleFarmLogic)} instead. */ @Nullable - IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic); + @Deprecated + default IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic){ + return null; + } /** - * * @param itemStack - * @param value The value of the fertitlizer.The value of the forestry fertelizer is 500. + * @param value The value of the fertitlizer. The value of the forestry fertelizer is 500. */ void registerFertilizer(ItemStack itemStack, int value); @@ -47,5 +72,32 @@ public interface IFarmRegistry { * @return The value of the fertitlizer */ int getFertilizeValue(ItemStack itemStack); + + /** + * Returns a fake {@link IFarmInstance} that returns the given logic at {@link IFarmInstance#getLogic(boolean)}. + * + * @since Forestry 5.8 + * @deprecated Only for backwards comparability. + */ + @Deprecated + IFarmInstance createFakeInstance(IFarmLogic logic); + + /** + * Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic. + * + * @return Null if the farming plugin is not active. + */ + @Nullable + IFarmLogic createCropLogic(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic); + + /** + * + * @param identifier + * @return + * + * @since Forestry 5.8 + */ + @Nullable + IFarmInstance getFarm(String identifier); } diff --git a/src/main/java/forestry/api/farming/ISimpleFarmLogic.java b/src/main/java/forestry/api/farming/ISimpleFarmLogic.java index 71728b3a8..8ecc9df54 100644 --- a/src/main/java/forestry/api/farming/ISimpleFarmLogic.java +++ b/src/main/java/forestry/api/farming/ISimpleFarmLogic.java @@ -8,7 +8,9 @@ package forestry.api.farming; import net.minecraft.item.ItemStack; /** - * A simple version of the IFarmLogic. + * A simple version of the IFarmLogic. + * + * @apiNote TODO Remove this in 1.13 */ public interface ISimpleFarmLogic { @@ -16,7 +18,11 @@ public interface ISimpleFarmLogic { * @return the itemStack that represents this farm logic. Used as an icon for the farm logic. */ ItemStack getIconItemStack(); - + + /** + * @deprecated Since 5.8 + */ + @Deprecated Iterable getSeeds(); String getName(); diff --git a/src/main/java/forestry/api/farming/ISoil.java b/src/main/java/forestry/api/farming/ISoil.java new file mode 100644 index 000000000..03d2a08b0 --- /dev/null +++ b/src/main/java/forestry/api/farming/ISoil.java @@ -0,0 +1,16 @@ +package forestry.api.farming; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +/** + * @since Forestry 5.8 + */ +public interface ISoil { + + ItemStack getResource(); + + IBlockState getSoilState(); + + boolean hasMetaData(); +} diff --git a/src/main/java/forestry/core/blocks/BlockBase.java b/src/main/java/forestry/core/blocks/BlockBase.java index 1922d22ca..7c422379b 100755 --- a/src/main/java/forestry/core/blocks/BlockBase.java +++ b/src/main/java/forestry/core/blocks/BlockBase.java @@ -76,7 +76,6 @@ public class BlockBase

& IBlockType & IStringSerializable> ext public final P blockType; private final ParticleHelper.Callback particleCallback; - protected final BlockStateContainer blockState; public BlockBase(P blockType, Material material) { super(material); @@ -88,9 +87,7 @@ public class BlockBase

& IBlockType & IStringSerializable> ext this.hasCustom = blockType instanceof IBlockTypeCustom; this.lightOpacity = (!hasTESR && !hasCustom) ? 255 : 0; - this.blockState = this.createBlockState(); - IBlockState state = this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH); - this.setDefaultState(state); + this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); particleCallback = new MachineParticleCallback<>(this, blockType); } diff --git a/src/main/java/forestry/core/circuits/CircuitRegistry.java b/src/main/java/forestry/core/circuits/CircuitRegistry.java index 28fb56e59..f2c0cc6df 100755 --- a/src/main/java/forestry/core/circuits/CircuitRegistry.java +++ b/src/main/java/forestry/core/circuits/CircuitRegistry.java @@ -77,11 +77,7 @@ public class CircuitRegistry implements ICircuitRegistry { @Override @Nullable public ICircuitLayout getLayout(String uid) { - if (layoutMap.containsKey(uid)) { - return layoutMap.get(uid); - } else { - return null; - } + return layoutMap.getOrDefault(uid, null); } /* CIRCUITS */ diff --git a/src/main/java/forestry/core/circuits/Circuits.java b/src/main/java/forestry/core/circuits/Circuits.java index b45a1b1e3..aeee7dd36 100644 --- a/src/main/java/forestry/core/circuits/Circuits.java +++ b/src/main/java/forestry/core/circuits/Circuits.java @@ -8,29 +8,38 @@ public class Circuits { public static ICircuit energyElectricEfficiency1; public static ICircuit energyElectricBoost1; public static ICircuit energyElectricBoost2; + public static ICircuit farmArborealManaged; + public static ICircuit farmOrchardManaged; public static ICircuit farmShroomManaged; public static ICircuit farmCropsManaged; public static ICircuit farmPeatManaged; public static ICircuit farmSucculentManaged; public static ICircuit farmPoaleManaged; - public static ICircuit farmFungal; public static ICircuit farmInfernalManaged; + public static ICircuit farmEnderManaged; + public static ICircuit farmOrchidManaged; public static ICircuit farmGourdManaged; + + + public static ICircuit farmArborealManual; + public static ICircuit farmOrchardManual; public static ICircuit farmShroomManual; public static ICircuit farmCropsManual; public static ICircuit farmPeatManual; public static ICircuit farmSucculentManual; public static ICircuit farmPoalesManual; + public static ICircuit farmInfernalManual; + public static ICircuit farmEnderManual; + public static ICircuit farmOrchidManual; public static ICircuit farmGourdManual; public static ICircuit farmCocoaManual; - public static ICircuit farmOrchardManual; public static ICircuit farmRubberManual; - public static ICircuit farmEnderManaged; - public static ICircuit farmOrchidManaged; + public static ICircuit machineSpeedUpgrade1; public static ICircuit machineSpeedUpgrade2; public static ICircuit machineEfficiencyUpgrade1; + public static ICircuit climatiserTemperature1; public static ICircuit climatiserTemperature2; public static ICircuit climatiserHumidity1; diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 970418c5a..546901e34 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -102,6 +102,11 @@ public class Config { private static boolean enableExUtilRedOrchid = true; private static boolean enableMagicalCropsSupport = true; + // Cultivation + public static int planterExtend = 4; + public static boolean ringFarms = false; + public static int ringSize = 4; + // Mail public static boolean mailAlertEnabled = true; public static GuiMailboxInfo.XPosition mailAlertXPosition = GuiMailboxInfo.XPosition.LEFT; @@ -266,6 +271,10 @@ public class Config { enableExUtilRedOrchid = configCommon.getBooleanLocalized("tweaks.farms", "redorchid", enableExUtilRedOrchid); enableMagicalCropsSupport = configCommon.getBooleanLocalized("tweaks.farms", "magicalcrops", enableMagicalCropsSupport); + planterExtend = configCommon.getIntLocalized("tweaks.cultivation", "extend", planterExtend, 1, 15); + ringFarms = configCommon.getBooleanLocalized("tweaks.cultivation", "ring", ringFarms); + ringSize = configCommon.getIntLocalized("tweaks.cultivation", "ring_size", ringSize, 1, 8); + CapsuleFluidPickup = configCommon.getBooleanLocalized("tweaks", "capsule", CapsuleFluidPickup); climateSourceRange = configCommon.getIntLocalized("tweaks.greenhouse", "range", climateSourceRange, 9, 270); diff --git a/src/main/java/forestry/cultivation/ModuleCultivation.java b/src/main/java/forestry/cultivation/ModuleCultivation.java index 28c23703f..3e33df0c8 100644 --- a/src/main/java/forestry/cultivation/ModuleCultivation.java +++ b/src/main/java/forestry/cultivation/ModuleCultivation.java @@ -18,6 +18,7 @@ import forestry.core.items.EnumElectronTube; import forestry.core.items.ItemRegistryCore; import forestry.core.recipes.RecipeUtil; import forestry.core.utils.OreDictUtil; +import forestry.cultivation.blocks.BlockPlanter; import forestry.cultivation.blocks.BlockRegistryCultivation; import forestry.modules.BlankForestryModule; import forestry.modules.ForestryModuleUids; @@ -113,5 +114,10 @@ public class ModuleCultivation extends BlankForestryModule { 'G', OreDictUtil.BLOCK_GLASS, 'W', Items.NETHER_WART, 'A', blocks.arboretum); + + for(BlockPlanter planter : getBlocks().getPlanters()){ + RecipeUtil.addRecipe(planter.blockType.getName() + "_manual_managed", planter.get(true), "# ", " ", " ", '#', planter.get(false)); + RecipeUtil.addRecipe(planter.blockType.getName() + "_managed_manual", planter.get(false), "# ", " ", " ", '#', planter.get(true)); + } } } diff --git a/src/main/java/forestry/cultivation/blocks/BlockPlanter.java b/src/main/java/forestry/cultivation/blocks/BlockPlanter.java index 5f56462b9..92cdb1623 100644 --- a/src/main/java/forestry/cultivation/blocks/BlockPlanter.java +++ b/src/main/java/forestry/cultivation/blocks/BlockPlanter.java @@ -1,17 +1,102 @@ package forestry.cultivation.blocks; import net.minecraft.block.material.Material; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.state.BlockStateContainer; +import net.minecraft.block.state.IBlockState; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.client.model.ModelLoader; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import forestry.core.blocks.BlockBase; +import forestry.cultivation.tiles.TilePlanter; public class BlockPlanter extends BlockBase { + public static final PropertyBool MANUAL = PropertyBool.create("manual"); + public BlockPlanter(BlockTypePlanter blockType) { super(blockType, Material.WOOD); + this.setDefaultState(blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(MANUAL, false)); + } + + @Override + protected BlockStateContainer createBlockState() { + return new BlockStateContainer(this, FACING, MANUAL); + } + + @Override + public IBlockState getStateFromMeta(int meta) { + int facing = meta & 7; + return getDefaultState().withProperty(FACING, EnumFacing.fromAngle(facing)).withProperty(MANUAL, (meta & 8) == 8); + } + + @Override + public int getMetaFromState(IBlockState state) { + if(state.getValue(MANUAL)){ + return state.getValue(FACING).ordinal(); + } + return 8 + state.getValue(FACING).ordinal(); + } + + @Override + public TileEntity createTileEntity(World world, IBlockState state) { + TileEntity tile = super.createNewTileEntity(world, 0); + if(tile instanceof TilePlanter){ + TilePlanter planter = (TilePlanter) tile; + planter.setManual(state.getValue(MANUAL)); + } + return tile; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerStateMapper() { + ModelLoader.setCustomStateMapper(this, new PlanterStateMapper()); } @Override public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.CUTOUT; } + + @Override + public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { + ItemStack stack = placer.getHeldItem(hand); + return getDefaultState().withProperty(MANUAL, isManual(stack)); + } + + @Override + public void getSubBlocks(CreativeTabs itemIn, NonNullList items) { + for(byte i = 0;i < 2;i++){ + items.add(get(i == 1)); + } + } + + public static boolean isManual(ItemStack stack){ + NBTTagCompound tagCompound = stack.getTagCompound(); + if(tagCompound != null){ + return tagCompound.getBoolean("Manual"); + } + return false; + } + + public ItemStack get(boolean isManual){ + ItemStack stack = new ItemStack(this); + stack.setTagInfo("Manual", new NBTTagByte((byte) (isManual ? 1 : 0))); + return stack; + } } diff --git a/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java b/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java index 07d8f9516..3302b5d56 100644 --- a/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java +++ b/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java @@ -1,9 +1,14 @@ package forestry.cultivation.blocks; +import java.util.HashSet; +import java.util.Set; + import forestry.core.blocks.BlockRegistry; -import forestry.core.items.ItemBlockForestry; +import forestry.cultivation.items.ItemBlockPlanter; public class BlockRegistryCultivation extends BlockRegistry { + private Set planters = new HashSet<>(); + public final BlockPlanter arboretum; public final BlockPlanter farmCrops; public final BlockPlanter farmMushroom; @@ -14,18 +19,33 @@ public class BlockRegistryCultivation extends BlockRegistry { public BlockRegistryCultivation() { arboretum = new BlockPlanter(BlockTypePlanter.ARBORETUM); - registerBlock(arboretum, new ItemBlockForestry<>(arboretum), "arboretum"); + registerBlock(arboretum, new ItemBlockPlanter(arboretum), "arboretum"); + planters.add(arboretum); + farmCrops = new BlockPlanter(BlockTypePlanter.FARM_CROPS); - registerBlock(farmCrops, new ItemBlockForestry<>(farmCrops), "farm_crops"); + registerBlock(farmCrops, new ItemBlockPlanter(farmCrops), "farm_crops"); + planters.add(farmCrops); + farmMushroom = new BlockPlanter(BlockTypePlanter.FARM_MUSHROOM); - registerBlock(farmMushroom, new ItemBlockForestry<>(farmMushroom), "farm_mushroom"); + registerBlock(farmMushroom, new ItemBlockPlanter(farmMushroom), "farm_mushroom"); + planters.add(farmMushroom); + farmGourd = new BlockPlanter(BlockTypePlanter.FARM_GOURD); - registerBlock(farmGourd, new ItemBlockForestry<>(farmGourd), "farm_gourd"); + registerBlock(farmGourd, new ItemBlockPlanter(farmGourd), "farm_gourd"); + planters.add(farmGourd); + farmNether = new BlockPlanter(BlockTypePlanter.FARM_NETHER); - registerBlock(farmNether, new ItemBlockForestry<>(farmNether), "farm_nether"); + registerBlock(farmNether, new ItemBlockPlanter(farmNether), "farm_nether"); + planters.add(farmNether); + peatBog = new BlockPlanter(BlockTypePlanter.PEAT_POG); - registerBlock(peatBog, new ItemBlockForestry<>(peatBog), "peat_bog"); + registerBlock(peatBog, new ItemBlockPlanter(peatBog), "peat_bog"); + planters.add(peatBog); /* plantation = new BlockPlanter(BlockTypePlanter.PLANTATION); registerBlock(plantation, new ItemBlockForestry<>(plantation), "plantation");*/ } + + public Set getPlanters() { + return planters; + } } diff --git a/src/main/java/forestry/cultivation/blocks/PlanterStateMapper.java b/src/main/java/forestry/cultivation/blocks/PlanterStateMapper.java new file mode 100644 index 000000000..ecaca00b4 --- /dev/null +++ b/src/main/java/forestry/cultivation/blocks/PlanterStateMapper.java @@ -0,0 +1,43 @@ +package forestry.cultivation.blocks; + +import com.google.common.collect.Maps; + +import java.util.LinkedHashMap; +import java.util.Map; + +import net.minecraft.block.Block; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.renderer.block.model.ModelResourceLocation; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + +import forestry.core.blocks.BlockBase; +import forestry.core.render.ForestryStateMapper; + +@SideOnly(Side.CLIENT) +public class PlanterStateMapper extends ForestryStateMapper { + + @Override + public Map putStateModelLocations(Block block) { + for (EnumFacing facing : EnumFacing.values()) { + if (facing == EnumFacing.DOWN || facing == EnumFacing.UP) { + continue; + } + for(boolean manual : new boolean[]{false, true}) { + IBlockState state = block.getDefaultState().withProperty(BlockBase.FACING, facing).withProperty(BlockPlanter.MANUAL, manual); + LinkedHashMap, Comparable> properties = Maps.newLinkedHashMap(state.getProperties()); + properties.remove(BlockPlanter.MANUAL); + ResourceLocation blockLocation = Block.REGISTRY.getNameForObject(block); + String s = String.format("%s:%s", blockLocation.getResourceDomain(), blockLocation.getResourcePath()); + mapStateModelLocations.put(state, new ModelResourceLocation(s, getPropertyString(properties))); + } + } + + return this.mapStateModelLocations; + } + +} diff --git a/src/main/java/forestry/cultivation/items/ItemBlockPlanter.java b/src/main/java/forestry/cultivation/items/ItemBlockPlanter.java new file mode 100644 index 000000000..cc8c396d2 --- /dev/null +++ b/src/main/java/forestry/cultivation/items/ItemBlockPlanter.java @@ -0,0 +1,19 @@ +package forestry.cultivation.items; + +import net.minecraft.item.ItemStack; + +import forestry.core.items.ItemBlockForestry; +import forestry.core.utils.Translator; +import forestry.cultivation.blocks.BlockPlanter; + +public class ItemBlockPlanter extends ItemBlockForestry { + + public ItemBlockPlanter(BlockPlanter block) { + super(block); + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + return Translator.translateToLocalFormatted("tile.for.planter." + (BlockPlanter.isManual(stack) ? "manual" : "managed"), super.getItemStackDisplayName(stack)); + } +} diff --git a/src/main/java/forestry/cultivation/items/package-info.java b/src/main/java/forestry/cultivation/items/package-info.java new file mode 100644 index 000000000..05d9468d4 --- /dev/null +++ b/src/main/java/forestry/cultivation/items/package-info.java @@ -0,0 +1,10 @@ +@ParametersAreNonnullByDefault +@FieldsAreNonnullByDefault +@MethodsReturnNonnullByDefault +package forestry.cultivation.items; + +import javax.annotation.ParametersAreNonnullByDefault; + +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/cultivation/tiles/TilePlantation.java b/src/main/java/forestry/cultivation/tiles/TilePlantation.java index d0dfc9df1..3e7b7619c 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlantation.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlantation.java @@ -2,11 +2,10 @@ package forestry.cultivation.tiles; import net.minecraft.item.ItemStack; -import forestry.api.farming.IFarmLogic; - public class TilePlantation extends TilePlanter { - public TilePlantation(IFarmLogic logic) { - super(logic); + + public TilePlantation() { + super("farmRubber"); } @Override diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index 2bede2c47..a1ebb54d4 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -33,6 +33,7 @@ import forestry.api.farming.IFarmHousing; import forestry.api.farming.IFarmInventory; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmable; +import forestry.core.config.Config; import forestry.core.config.Constants; import forestry.core.errors.EnumErrorCode; import forestry.core.fluids.FilteredTank; @@ -64,12 +65,10 @@ import forestry.farming.multiblock.FarmHydrationManager; public abstract class TilePlanter extends TilePowered implements IFarmHousing, IClimatised, ILiquidTankTile, IOwnedTile, IStreamableGui { - private final static int ALLOWED_EXTENT = 4; - private final Map> targets = new EnumMap<>(FarmDirection.class); private final Stack pendingProduce = new Stack<>(); private final List pendingCrops = new LinkedList<>(); - private final IFarmLogic logic; + private final String identifier; private final FarmHydrationManager hydrationManager; private final FarmFertilizerManager fertilizerManager; @@ -80,19 +79,23 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I private int platformHeight = -1; private Stage stage = Stage.CULTIVATE; + private boolean isManual; + private IFarmLogic logic; @Nullable private Vec3i offset; @Nullable private Vec3i area; - public TilePlanter(String identifier) { - this(FarmRegistry.getInstance().getFarmLogic(identifier)); + public void setManual(boolean manual) { + isManual = manual; + logic = FarmRegistry.getInstance().getFarm(identifier).getLogic(manual); } - protected TilePlanter(IFarmLogic logic) { + protected TilePlanter(String identifier) { super(150, 1500); + this.identifier = identifier; + setManual(false); setInternalInventory(inventory = new InventoryPlanter(this)); - this.logic = logic; this.hydrationManager = new FarmHydrationManager(this); this.fertilizerManager = new FarmFertilizerManager(); @@ -203,6 +206,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I tankManager.writeToNBT(data); fertilizerManager.writeToNBT(data); ownerHandler.writeToNBT(data); + data.setBoolean("isManual", isManual); return data; } @@ -213,6 +217,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I tankManager.readFromNBT(data); fertilizerManager.readFromNBT(data); ownerHandler.readFromNBT(data); + setManual(data.getBoolean("isManual")); } @Override @@ -231,8 +236,20 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I private void setUpFarmlandTargets() { BlockPos targetStart = getCoords(); + BlockPos minPos = pos; + BlockPos maxPos = pos; + int size = 1; + int extend = Config.planterExtend; - FarmHelper.createTargets(world, this, targets, targetStart, ALLOWED_EXTENT, 1, 1, pos, pos); + if(Config.ringFarms){ + int ringSize = Config.ringSize; + minPos = pos.add(-ringSize, 0 , -ringSize); + maxPos = pos.add(ringSize, 0, ringSize); + size = 1 + ringSize * 2; + extend--; + } + + FarmHelper.createTargets(world, this, targets, targetStart, extend, size, size, minPos, maxPos); FarmHelper.setExtents(world, this, targets); } @@ -331,7 +348,11 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I @Override public Vec3i getArea() { if (area == null) { - area = new Vec3i(7 + ALLOWED_EXTENT * 2, 13, 7 + ALLOWED_EXTENT * 2); + int basisArea = 5; + if(Config.ringFarms){ + basisArea = basisArea + 1 + Config.ringSize * 2; + } + area = new Vec3i(basisArea + Config.planterExtend, 13, basisArea + Config.planterExtend); } return area; } @@ -388,6 +409,11 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return true; } + @Override + public boolean canPlantSoil(boolean manual) { + return !isManual; + } + @Override public IFarmInventory getFarmInventory() { return inventory; diff --git a/src/main/java/forestry/farming/DummyFarmRegistry.java b/src/main/java/forestry/farming/DummyFarmRegistry.java index 9dec62bc0..0a036f5a1 100644 --- a/src/main/java/forestry/farming/DummyFarmRegistry.java +++ b/src/main/java/forestry/farming/DummyFarmRegistry.java @@ -1,42 +1,76 @@ package forestry.farming; +import javax.annotation.Nullable; import java.util.Collection; import java.util.Collections; +import java.util.function.BiFunction; import net.minecraft.item.ItemStack; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.IFarmable; import forestry.api.farming.ISimpleFarmLogic; +import forestry.farming.logic.FakeFarmInstance; public class DummyFarmRegistry implements IFarmRegistry { @Override - public void registerFarmLogic(String identifier, IFarmLogic logic) { - + public void registerLogic(String identifier, IFarmLogic logic) { + //Dummy-Implementation } @Override public void registerFarmables(String identifier, IFarmable... farmable) { + //Dummy-Implementation } @Override public Collection getFarmables(String identifier) { + //Dummy-Implementation return Collections.emptyList(); } @Override - public IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic) { + public IFarmInstance registerLogic(IFarmInstance farmInstance) { + //Dummy-Implementation return null; } + @Override + public IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { + //Dummy-Implementation + return null; + } + + @Nullable + @Override + public IFarmLogic createCropLogic(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { + //Dummy-Implementation + return null; + } + + @Override + public IFarmInstance createFakeInstance(IFarmLogic logic) { + return new FakeFarmInstance(logic); + } + @Override public void registerFertilizer(ItemStack itemStack, int value) { + //Dummy-Implementation } @Override public int getFertilizeValue(ItemStack itemStack) { + //Dummy-Implementation return 0; } + + @Nullable + @Override + public IFarmInstance getFarm(String identifier) { + //Dummy-Implementation + return null; + } } diff --git a/src/main/java/forestry/farming/FarmRegistry.java b/src/main/java/forestry/farming/FarmRegistry.java index 36577befc..4c4833212 100644 --- a/src/main/java/forestry/farming/FarmRegistry.java +++ b/src/main/java/forestry/farming/FarmRegistry.java @@ -3,6 +3,7 @@ package forestry.farming; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -14,12 +15,15 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.function.BiFunction; +import java.util.stream.Collectors; import net.minecraft.item.ItemStack; import net.minecraftforge.common.config.Property; import net.minecraftforge.oredict.OreDictionary; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.IFarmable; @@ -28,6 +32,8 @@ import forestry.core.config.LocalizedConfiguration; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.core.utils.Translator; +import forestry.farming.logic.FakeFarmInstance; +import forestry.farming.logic.FarmInstance; import forestry.farming.logic.FarmLogicSimple; public final class FarmRegistry implements IFarmRegistry { @@ -35,18 +41,17 @@ public final class FarmRegistry implements IFarmRegistry { private static final FarmRegistry INSTANCE = new FarmRegistry(); private final Multimap farmables = HashMultimap.create(); private final Map fertilizers = new LinkedHashMap<>(); - private final Map logics = new HashMap(); + private final Map logics = new HashMap<>(); + private final Map farmInstances = new HashMap<>(); public static FarmRegistry getInstance() { return INSTANCE; } - - public void registerFarmLogic(String identifier, IFarmLogic logic) { - logics.put(identifier, logic); - } - public IFarmLogic getFarmLogic(String identifier) { - return logics.get(identifier); + @Override + @Deprecated + public void registerLogic(String identifier, IFarmLogic logic) { + logics.put(identifier, logic); } @Override @@ -60,13 +65,18 @@ public final class FarmRegistry implements IFarmRegistry { } @Override - public IFarmLogic createLogic(ISimpleFarmLogic simpleFarmLogic) { - return new FarmLogicSimple(simpleFarmLogic); + public IFarmLogic createCropLogic(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { + return new FarmLogicSimple(instance, isManual, simpleFarmLogic); + } + + @Override + public IFarmInstance createFakeInstance(IFarmLogic logic) { + return new FakeFarmInstance(logic); } @Override public void registerFertilizer(ItemStack itemStack, int value) { - if(itemStack == null || itemStack.isEmpty()){ + if(itemStack.isEmpty()){ return; } fertilizers.put(itemStack, value); @@ -76,16 +86,36 @@ public final class FarmRegistry implements IFarmRegistry { public int getFertilizeValue(ItemStack itemStack) { for (Entry fertilizer : fertilizers.entrySet()) { ItemStack fertilizerStack = fertilizer.getKey(); - if (itemStack.getItem() == fertilizerStack.getItem() - && (fertilizerStack.getItemDamage() == itemStack.getItemDamage() - || fertilizerStack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) { + if (ItemStackUtil.isIdenticalItem(fertilizerStack, itemStack)) { return fertilizer.getValue(); } } return 0; } - - public void loadConfig(LocalizedConfiguration config) { + + @Override + public IFarmInstance registerLogic(IFarmInstance farmInstance) { + farmInstances.put(farmInstance.getIdentifier(), farmInstance); + return farmInstance; + } + + @Override + public IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { + Set fIdentifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers)); + fIdentifiers.add(identifier); + Collection farmablesSet = fIdentifiers.stream().map(farmables::get).flatMap(Collection::stream).collect(Collectors.toSet()); + IFarmInstance instance = new FarmInstance(identifier, logicFactory, farmablesSet); + farmInstances.put(identifier, instance); + return instance; + } + + @Override + @Nullable + public IFarmInstance getFarm(String identifier) { + return farmInstances.get(identifier); + } + + void loadConfig(LocalizedConfiguration config) { List defaultFertilizers = new ArrayList<>(getItemStrings()); Collections.sort(defaultFertilizers); String[] defaultSortedFertilizers = defaultFertilizers.toArray(new String[defaultFertilizers.size()]); @@ -102,6 +132,9 @@ public final class FarmRegistry implements IFarmRegistry { itemName = "forestry:fertilizer_compound"; } ItemStack fertilizerItem = ItemStackUtil.parseItemStackString(itemName, OreDictionary.WILDCARD_VALUE); + if(fertilizerItem == null){ + continue; + } int fertilizerValue = Integer.parseInt(fertilizers[1]); registerFertilizer(fertilizerItem, fertilizerValue); } catch (Exception e) { diff --git a/src/main/java/forestry/farming/ModuleFarming.java b/src/main/java/forestry/farming/ModuleFarming.java index 352d7c6a5..bdd0470a5 100644 --- a/src/main/java/forestry/farming/ModuleFarming.java +++ b/src/main/java/forestry/farming/ModuleFarming.java @@ -19,6 +19,7 @@ import java.util.List; import net.minecraft.block.BlockBeetroot; import net.minecraft.block.BlockCrops; +import net.minecraft.block.BlockDirt; import net.minecraft.block.BlockNetherWart; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; @@ -42,9 +43,12 @@ import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitLayout; import forestry.api.core.ForestryAPI; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmRegistry; import forestry.api.modules.ForestryModule; import forestry.core.ModuleCore; +import forestry.core.blocks.BlockBogEarth; +import forestry.core.blocks.BlockRegistryCore; import forestry.core.circuits.CircuitLayout; import forestry.core.circuits.Circuits; import forestry.core.config.Config; @@ -181,29 +185,56 @@ public class ModuleFarming extends BlankForestryModule { GameRegistry.registerTileEntity(TileFarmValve.class, "forestry.FarmValve"); GameRegistry.registerTileEntity(TileFarmControl.class, "forestry.FarmControl"); - Circuits.farmArborealManaged = new CircuitFarmLogic("managedArboreal", new FarmLogicArboreal()); - Circuits.farmShroomManaged = new CircuitFarmLogic("managedShroom", new FarmLogicMushroom()); - Circuits.farmPeatManaged = new CircuitFarmLogic("managedPeat", new FarmLogicPeat()); - Circuits.farmCropsManaged = new CircuitFarmLogic("managedCrops", new FarmLogicCrops()); - Circuits.farmInfernalManaged = new CircuitFarmLogic("managedInfernal", new FarmLogicInfernal()); + IFarmRegistry registry = FarmRegistry.getInstance(); + BlockRegistryCore coreBlocks = ModuleCore.getBlocks(); - Circuits.farmPeatManual = new CircuitFarmLogic("manualPeat", new FarmLogicPeat()).setManual(); - Circuits.farmShroomManual = new CircuitFarmLogic("manualShroom", new FarmLogicMushroom()).setManual(); - Circuits.farmCropsManual = new CircuitFarmLogic("manualCrops", new FarmLogicCrops()).setManual(); - Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", new FarmLogicSucculent()).setManual(); - Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", new FarmLogicReeds()).setManual(); - Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", new FarmLogicGourd()).setManual(); - Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", new FarmLogicCocoa()).setManual(); + IFarmInstance arborealFarm = registry.registerLogic("farmArboreal", FarmLogicArboreal::new); + IFarmInstance cropsFarm = registry.registerLogic("farmCrops", FarmLogicCrops::new); + IFarmInstance mushroomFarm = registry.registerLogic("farmShroom", FarmLogicMushroom::new); + IFarmInstance succulentFarm = registry.registerLogic("farmSucculent", FarmLogicSucculent::new); + IFarmInstance peatFarm = registry.registerLogic("farmPeat", FarmLogicPeat::new); + IFarmInstance infernalFarm = registry.registerLogic("farmInfernal", FarmLogicInfernal::new); + IFarmInstance poalesFarm = registry.registerLogic("farmPoales", FarmLogicReeds::new); + IFarmInstance orchardFarm = registry.registerLogic("farmOrchard", FarmLogicOrchard::new); + IFarmInstance gourdFarm = registry.registerLogic("farmGourd", FarmLogicGourd::new); + IFarmInstance cocoaFarm = registry.registerLogic("farmCocoa", FarmLogicCocoa::new); - Circuits.farmOrchardManual = new CircuitFarmLogic("manualOrchard", new FarmLogicOrchard()); + Circuits.farmArborealManaged = new CircuitFarmLogic("managedArboreal", arborealFarm, false); + Circuits.farmArborealManual = new CircuitFarmLogic("manualArboreal", arborealFarm, true); + arborealFarm.registerSoil(new ItemStack(Blocks.DIRT), coreBlocks.humus.getDefaultState()); + arborealFarm.registerSoil(new ItemStack(coreBlocks.humus), coreBlocks.humus.getDefaultState()); - // Make Forestry farming logics accessible to plugins via FarmRegistry - FarmRegistry.getInstance().registerFarmLogic("farmArboreal",((CircuitFarmLogic)Circuits.farmArborealManaged).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmShroom",((CircuitFarmLogic)Circuits.farmShroomManaged).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmCrops",((CircuitFarmLogic)Circuits.farmCropsManaged).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmInfernal",((CircuitFarmLogic)Circuits.farmInfernalManaged).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmGourd", ((CircuitFarmLogic)Circuits.farmGourdManual).getFarmLogic()); - FarmRegistry.getInstance().registerFarmLogic("farmPeat", ((CircuitFarmLogic)Circuits.farmPeatManaged).getFarmLogic()); + Circuits.farmShroomManaged = new CircuitFarmLogic("managedShroom", mushroomFarm, false); + Circuits.farmShroomManual = new CircuitFarmLogic("manualShroom", mushroomFarm, true); + mushroomFarm.registerSoil(new ItemStack(Blocks.MYCELIUM), Blocks.MYCELIUM.getDefaultState()); + mushroomFarm.registerSoil(new ItemStack(Blocks.DIRT, 1, 2), + Blocks.DIRT.getDefaultState().withProperty(BlockDirt.VARIANT, BlockDirt.DirtType.PODZOL), true); + + Circuits.farmPeatManaged = new CircuitFarmLogic("managedPeat", peatFarm, false); + Circuits.farmPeatManual = new CircuitFarmLogic("manualPeat", peatFarm, true); + peatFarm.registerSoil(coreBlocks.bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 1), coreBlocks.bogEarth.getDefaultState()); + + Circuits.farmCropsManaged = new CircuitFarmLogic("managedCrops", cropsFarm, false); + Circuits.farmCropsManual = new CircuitFarmLogic("manualCrops", cropsFarm, true); + cropsFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.FARMLAND.getDefaultState()); + + Circuits.farmInfernalManaged = new CircuitFarmLogic("managedInfernal", infernalFarm, false); + Circuits.farmInfernalManual = new CircuitFarmLogic("manualInfernal", infernalFarm, true); + infernalFarm.registerSoil(new ItemStack(Blocks.SOUL_SAND), Blocks.SOUL_SAND.getDefaultState()); + + Circuits.farmOrchardManaged = new CircuitFarmLogic("managedOrchard", orchardFarm, false); + Circuits.farmOrchardManual = new CircuitFarmLogic("manualOrchard", orchardFarm, true); + + Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", succulentFarm, true); + succulentFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); + + Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", poalesFarm, true).setManual(); + poalesFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); + poalesFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(),false); + + Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", gourdFarm, true).setManual(); + + Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", cocoaFarm, true).setManual(); } @Override @@ -267,6 +298,10 @@ public class ModuleFarming extends BlankForestryModule { ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); + if(layoutManaged == null || layoutManual == null){ + return; + } + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmArborealManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPeatManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCropsManaged); diff --git a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java index 1e434f54e..ce97c19d6 100755 --- a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java +++ b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java @@ -14,6 +14,7 @@ import javax.annotation.Nullable; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; import forestry.core.circuits.Circuit; @@ -22,15 +23,28 @@ public class CircuitFarmLogic extends Circuit { private final IFarmLogic logic; private boolean isManual = false; + public CircuitFarmLogic(String uid, IFarmInstance instance, boolean manual) { + super(uid); + this.logic = instance.getLogic(manual); + } + public CircuitFarmLogic(String uid, IFarmLogic logic) { super(uid); this.logic = logic; } - + + /** + * @deprecated TODO: Remove this method in 1.13 + */ + @Deprecated public IFarmLogic getFarmLogic() { return logic; } + /** + * @deprecated TODO: Remove this method in 1.13 + */ + @Deprecated public CircuitFarmLogic setManual() { isManual = true; return this; diff --git a/src/main/java/forestry/farming/logic/FakeFarmInstance.java b/src/main/java/forestry/farming/logic/FakeFarmInstance.java new file mode 100644 index 000000000..864b7de8c --- /dev/null +++ b/src/main/java/forestry/farming/logic/FakeFarmInstance.java @@ -0,0 +1,54 @@ +package forestry.farming.logic; + +import java.util.Collection; +import java.util.Collections; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmable; +import forestry.api.farming.ISoil; + +public class FakeFarmInstance implements IFarmInstance { + private final IFarmLogic logic; + + public FakeFarmInstance(IFarmLogic logic) { + this.logic = logic; + } + + @Override + public void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { + } + + @Override + public boolean isAcceptedSoil(IBlockState blockState) { + return false; + } + + @Override + public boolean isAcceptedResource(ItemStack itemStack) { + return false; + } + + @Override + public String getIdentifier() { + return "farmFake"; + } + + @Override + public Collection getSoils() { + return Collections.emptySet(); + } + + @Override + public Collection getFarmables() { + return Collections.emptySet(); + } + + @Override + public IFarmLogic getLogic(boolean manuel) { + return logic; + } +} diff --git a/src/main/java/forestry/farming/logic/FarmInstance.java b/src/main/java/forestry/farming/logic/FarmInstance.java new file mode 100644 index 000000000..716862d87 --- /dev/null +++ b/src/main/java/forestry/farming/logic/FarmInstance.java @@ -0,0 +1,80 @@ +package forestry.farming.logic; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.function.BiFunction; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmable; +import forestry.api.farming.ISoil; + +public final class FarmInstance implements IFarmInstance { + private final Set soils = new HashSet<>(); + private final Collection farmables; + private final IFarmLogic manualLogic; + private final IFarmLogic managedLogic; + private final String identifier; + + public FarmInstance(String identifier, BiFunction logicFactory, Collection farmables) { + this.identifier = identifier; + this.farmables = farmables; + this.manualLogic = logicFactory.apply(this, true); + this.managedLogic = logicFactory.apply(this, false); + } + + @Override + public Collection getFarmables() { + return farmables; + } + + @Override + public IFarmLogic getLogic(boolean manuel) { + return manuel ? manualLogic : managedLogic; + } + + @Override + public void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { + soils.add(new Soil(resource, soilState, hasMetaData)); + } + + public boolean isAcceptedSoil(IBlockState ground) { + for (ISoil soil : soils) { + IBlockState soilState = soil.getSoilState(); + Block soilBlock = soilState.getBlock(); + Block block = ground.getBlock(); + if (soilState.getBlock() == ground.getBlock()) { + if (!soil.hasMetaData() || block.getMetaFromState(ground) == soilBlock.getMetaFromState(soilState)) { + return true; + } + } + } + return false; + } + + @Override + public boolean isAcceptedResource(ItemStack itemstack) { + for (ISoil soil : soils) { + ItemStack resource = soil.getResource(); + if (resource.isItemEqual(itemstack)) { + return true; + } + } + return false; + } + + @Override + public Collection getSoils() { + return soils; + } + + @Override + public String getIdentifier() { + return identifier; + } +} diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 23c3c9931..54810fdbb 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -13,48 +13,73 @@ package forestry.farming.logic; import com.google.common.base.Predicate; import javax.annotation.Nullable; +import java.util.Collection; import java.util.List; +import java.util.Stack; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - import forestry.api.farming.FarmDirection; +import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmable; +import forestry.api.farming.ISoil; import forestry.core.utils.VectUtil; public abstract class FarmLogic implements IFarmLogic { private final EntitySelectorFarm entitySelectorFarm = new EntitySelectorFarm(this); - protected boolean isManual; + protected final IFarmInstance instance; + protected final boolean isManual; + + public FarmLogic(IFarmInstance instance, boolean isManual) { + this.instance = instance; + this.isManual = isManual; + } + + protected Collection getFarmables() { + return instance.getFarmables(); + } + + protected Collection getSoils() { + return instance.getSoils(); + } @Override public FarmLogic setManual(boolean flag) { - isManual = flag; return this; } - @SideOnly(Side.CLIENT) @Override - public ResourceLocation getTextureMap() { - return TextureMap.LOCATION_BLOCKS_TEXTURE; + public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { + Stack crops = new Stack<>(); + for (int i = 0; i < extent; i++) { + BlockPos position = translateWithOffset(pos.up(), direction, i); + if (world.isAirBlock(position)) { + continue; + } + IBlockState blockState = world.getBlockState(position); + for (IFarmable seed : getFarmables()) { + ICrop crop = seed.getCropAt(world, position, blockState); + if (crop != null) { + crops.push(crop); + break; + } + } + } + return crops; } - @Override - public abstract ItemStack getIconItemStack(); - public abstract boolean isAcceptedWindfall(ItemStack stack); protected final boolean isWaterSourceBlock(World world, BlockPos position) { @@ -96,6 +121,12 @@ public abstract class FarmLogic implements IFarmLogic { return stacks; } + // for debugging + @Override + public String toString() { + return getName(); + } + private static class EntitySelectorFarm implements Predicate { private final FarmLogic farmLogic; @@ -112,20 +143,9 @@ public abstract class FarmLogic implements IFarmLogic { if (entity.getEntityData().getBoolean("PreventRemoteMovement")) { return false; } - + ItemStack contained = entity.getItem(); return farmLogic.isAcceptedGermling(contained) || farmLogic.isAcceptedWindfall(contained); } } - - @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - // do nothing as soil is not managed by farm - } - - // for debugging - @Override - public String toString() { - return getName(); - } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 29645131e..116511d75 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -11,10 +11,12 @@ package forestry.farming.logic; import javax.annotation.Nullable; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.Stack; @@ -29,17 +31,21 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmable; -import forestry.core.ModuleCore; -import forestry.farming.FarmRegistry; public class FarmLogicArboreal extends FarmLogicHomogeneous { - public FarmLogicArboreal(ItemStack resource, IBlockState ground, Collection germlings) { - super(resource, ground, germlings); + + private List farmables; + + public FarmLogicArboreal(IFarmInstance instance, boolean isManual) { + super(instance, isManual); + this.farmables = new ArrayList<>(instance.getFarmables()); } - public FarmLogicArboreal() { - super(new ItemStack(Blocks.DIRT), ModuleCore.getBlocks().humus.getDefaultState(), FarmRegistry.getInstance().getFarmables("farmArboreal")); + @Override + public List getFarmables() { + return farmables; } @Override @@ -73,7 +79,6 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Override public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - if (!lastExtentsHarvest.containsKey(pos)) { lastExtentsHarvest.put(pos, 0); } @@ -93,7 +98,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { private Collection harvestBlocks(World world, BlockPos position) { // Determine what type we want to harvest. - IFarmable farmable = getFarmableForBlock(world, position, farmables); + IFarmable farmable = getFarmableForBlock(world, position, getFarmables()); if (farmable == null) { return Collections.emptyList(); } @@ -126,6 +131,9 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Nullable private static IFarmable getFarmableForBlock(World world, BlockPos position, Collection farmables) { + if (world.isAirBlock(position)) { + return null; + } IBlockState blockState = world.getBlockState(position); for (IFarmable farmable : farmables) { ICrop crop = farmable.getCropAt(world, position, blockState); @@ -154,7 +162,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { private boolean plantSapling(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction) { Collections.shuffle(farmables); - for (IFarmable candidate : farmables) { + for (IFarmable candidate : getFarmables()) { if (farmHousing.plantGermling(candidate, world, position, direction)) { return true; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 5e816d77f..5f548c8c5 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -34,12 +34,17 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmable; import forestry.farming.logic.farmables.FarmableCocoa; public class FarmLogicCocoa extends FarmLogic { private final IFarmable cocoa = new FarmableCocoa(); + public FarmLogicCocoa(IFarmInstance instance, boolean isManual) { + super(instance, isManual); + } + @Override public ItemStack getIconItemStack() { return new ItemStack(Items.DYE, 1, 3); diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index bf0678a9c..a76cf61fa 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -10,11 +10,7 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -22,33 +18,20 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; -import forestry.farming.FarmRegistry; public class FarmLogicCrops extends FarmLogicWatered { - private final Iterable seeds; - public FarmLogicCrops() { - this(FarmRegistry.getInstance().getFarmables("farmCrops")); - } - - protected FarmLogicCrops(Iterable seeds) { - super(new ItemStack(Blocks.DIRT), Blocks.FARMLAND.getDefaultState()); - - this.seeds = seeds; - } - - @Override - public boolean isAcceptedGround(IBlockState blockState) { - return super.isAcceptedGround(blockState) || blockState.getBlock() == Blocks.FARMLAND; + public FarmLogicCrops(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override public boolean isAcceptedGermling(ItemStack itemstack) { - for (IFarmable germling : seeds) { + for (IFarmable germling : getFarmables()) { if (germling.isGermling(itemstack)) { return true; } @@ -58,7 +41,7 @@ public class FarmLogicCrops extends FarmLogicWatered { @Override public boolean isAcceptedWindfall(ItemStack itemstack) { - for (IFarmable germling : seeds) { + for (IFarmable germling : getFarmables()) { if (germling.isWindfall(itemstack)) { return true; } @@ -83,7 +66,7 @@ public class FarmLogicCrops extends FarmLogicWatered { } IBlockState groundState = world.getBlockState(position.down()); - if (isAcceptedGround(groundState)) { + if (isAcceptedSoil(groundState)) { return trySetCrop(world, farmHousing, position, direction); } } @@ -92,7 +75,7 @@ public class FarmLogicCrops extends FarmLogicWatered { } private boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction) { - for (IFarmable candidate : seeds) { + for (IFarmable candidate : getFarmables()) { if (farmHousing.plantGermling(candidate, world, position, direction)) { return true; } @@ -101,23 +84,6 @@ public class FarmLogicCrops extends FarmLogicWatered { return false; } - @Override - public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - Stack crops = new Stack<>(); - for (int i = 0; i < extent; i++) { - BlockPos position = translateWithOffset(pos.up(), direction, i); - IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : seeds) { - ICrop crop = seed.getCropAt(world, position, blockState); - if (crop != null) { - crops.push(crop); - break; - } - } - } - return crops; - } - @Override public ItemStack getIconItemStack() { return new ItemStack(Items.WHEAT); diff --git a/src/main/java/forestry/farming/logic/FarmLogicExU.java b/src/main/java/forestry/farming/logic/FarmLogicExU.java index 84b0fd1bd..636b911aa 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicExU.java +++ b/src/main/java/forestry/farming/logic/FarmLogicExU.java @@ -10,12 +10,7 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -23,22 +18,17 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmInstance; import forestry.core.utils.BlockUtil; -import forestry.farming.FarmRegistry; public class FarmLogicExU extends FarmLogicHomogeneous { private final String name; private final Item iconItem; - public FarmLogicExU(String name, Item iconItem, Block soil, String farmablesKey) { - super(new ItemStack(soil), soil.getDefaultState(), FarmRegistry.getInstance().getFarmables(farmablesKey)); - if (soil.equals(Blocks.REDSTONE_ORE)) { - super.addSoil(new ItemStack(Blocks.LIT_REDSTONE_ORE), Blocks.LIT_REDSTONE_ORE.getDefaultState(), false); - } + public FarmLogicExU(IFarmInstance instance, boolean isManual, String name, Item iconItem) { + super(instance, isManual); this.name = name; this.iconItem = iconItem; } @@ -68,25 +58,6 @@ public class FarmLogicExU extends FarmLogicHomogeneous { return NonNullList.create(); } - @Override - public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - Stack crops = new Stack<>(); - for (int i = 0; i < extent; i++) { - BlockPos position = translateWithOffset(pos.up(), direction, i); - IBlockState blockState = world.getBlockState(position); - for (IFarmable farmable : farmables) { - ICrop crop = farmable.getCropAt(world, position, blockState); - if (crop != null) { - crops.push(crop); - break; - } - } - - } - return crops; - - } - @Override protected boolean maintainGermlings(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { for (int i = 0; i < extent; i++) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index ede28bc10..d651aeb43 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.block.state.IBlockState; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -21,18 +17,13 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.farming.FarmRegistry; +import forestry.api.farming.IFarmInstance; public class FarmLogicGourd extends FarmLogic { - private final IFarmable[] seeds; - - public FarmLogicGourd() { - Collection farmables = FarmRegistry.getInstance().getFarmables("farmGourd"); - seeds = farmables.toArray(new IFarmable[farmables.size()]); + public FarmLogicGourd(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override @@ -79,21 +70,4 @@ public class FarmLogicGourd extends FarmLogic { public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { return false; } - - @Override - public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - Stack crops = new Stack<>(); - for (int i = 0; i < extent; i++) { - BlockPos position = translateWithOffset(pos.up(), direction, i); - IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : seeds) { - ICrop crop = seed.getCropAt(world, position, blockState); - if (crop != null) { - crops.push(crop); - break; - } - } - } - return crops; - } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index f719d1690..d511fede6 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -23,47 +18,21 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmable; +import forestry.api.farming.ISoil; import forestry.core.utils.BlockUtil; public abstract class FarmLogicHomogeneous extends FarmLogicSoil { - protected final List farmables; - protected NonNullList produce = NonNullList.create(); - protected FarmLogicHomogeneous(ItemStack resource, IBlockState soilState, Collection farmables) { - addSoil(resource, soilState, false); - this.farmables = new ArrayList<>(farmables); - } - - protected boolean isAcceptedSoil(IBlockState blockState) { - for(Soil soil : soils){ - IBlockState soilState = soil.getSoilState(); - Block soilBlock = soilState.getBlock(); - Block block = blockState.getBlock(); - if(soilState.getBlock() == blockState.getBlock()){ - if(!soil.hasMetaData() || block.getMetaFromState(blockState) == soilBlock.getMetaFromState(soilState)){ - return true; - } - } - } - return false; - } - - @Override - public boolean isAcceptedResource(ItemStack itemstack) { - for(Soil soil : soils){ - ItemStack resource = soil.getResource(); - if(resource.isItemEqual(itemstack)){ - return true; - } - } - return false; + public FarmLogicHomogeneous(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override public boolean isAcceptedGermling(ItemStack itemstack) { - for (IFarmable germling : farmables) { + for (IFarmable germling : getFarmables()) { if (germling.isGermling(itemstack)) { return true; } @@ -73,7 +42,7 @@ public abstract class FarmLogicHomogeneous extends FarmLogicSoil { @Override public boolean isAcceptedWindfall(ItemStack itemstack) { - for (IFarmable germling : farmables) { + for (IFarmable germling : getFarmables()) { if (germling.isWindfall(itemstack)) { return true; } @@ -81,18 +50,8 @@ public abstract class FarmLogicHomogeneous extends FarmLogicSoil { return false; } - protected boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction, boolean shuffle) { - for (IFarmable candidate : farmables) { - if (farmHousing.plantGermling(candidate, world, position, direction)) { - return true; - } - } - - return false; - } - protected boolean trySetCrop(World world, IFarmHousing farmHousing, BlockPos position, FarmDirection direction) { - for (IFarmable candidate : farmables) { + for (IFarmable candidate : getFarmables()) { if (farmHousing.plantGermling(candidate, world, position, direction)) { return true; } @@ -103,37 +62,43 @@ public abstract class FarmLogicHomogeneous extends FarmLogicSoil { @Override public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - return maintainSoil(world, farmHousing, pos, direction, extent) || - maintainGermlings(world, farmHousing, pos.up(), direction, extent); + if(isManual){ + + } + return maintainSoil(world, farmHousing, pos, direction, extent) || maintainGermlings(world, farmHousing, pos.up(), direction, extent); } private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - for(Soil soil : soils){ + if(!farmHousing.canPlantSoil(isManual)){ + return false; + } + + for (ISoil soil : getSoils()) { NonNullList resources = NonNullList.create(); resources.add(soil.getResource()); if (!farmHousing.getFarmInventory().hasResources(resources)) { continue; } - + for (int i = 0; i < extent; i++) { BlockPos position = translateWithOffset(pos, direction, i); IBlockState soilState = world.getBlockState(position); - + if (farmHousing.isValidPlatform(world, pos)) { break; } - + if (isAcceptedSoil(soilState)) { continue; } - + BlockPos platformPosition = position.down(); if (!farmHousing.isValidPlatform(world, platformPosition)) { break; } - + produce.addAll(BlockUtil.getBlockDrops(world, position)); - + BlockUtil.setBlockWithPlaceSound(world, position, soil.getSoilState()); farmHousing.getFarmInventory().removeResources(resources); return true; diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index c84476578..97611715e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.Stack; import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -24,14 +23,14 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; -import forestry.farming.FarmRegistry; public class FarmLogicInfernal extends FarmLogicHomogeneous { - public FarmLogicInfernal() { - super(new ItemStack(Blocks.SOUL_SAND), Blocks.SOUL_SAND.getDefaultState(), FarmRegistry.getInstance().getFarmables("farmInfernal")); + public FarmLogicInfernal(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override @@ -64,8 +63,11 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { BlockPos position = translateWithOffset(pos.up(), direction, i); + if (world.isAirBlock(pos)) { + continue; + } IBlockState blockState = world.getBlockState(position); - for (IFarmable farmable : farmables) { + for (IFarmable farmable : getFarmables()) { ICrop crop = farmable.getCropAt(world, position, blockState); if (crop != null) { crops.push(crop); diff --git a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java index 93705fc16..537df6970 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java +++ b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java @@ -15,14 +15,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; -import forestry.api.core.ForestryAPI; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; public class FarmLogicMushroom extends FarmLogicArboreal { - public FarmLogicMushroom() { - super(new ItemStack(Blocks.MYCELIUM), Blocks.MYCELIUM.getDefaultState(), ForestryAPI.farmRegistry.getFarmables("farmShroom")); - addSoil(new ItemStack(Blocks.DIRT, 1, 2), Blocks.DIRT.getStateFromMeta(2), true); + public FarmLogicMushroom(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index cb8501bb1..ad46f954a 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -28,10 +28,10 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import forestry.api.core.ForestryAPI; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmable; import forestry.api.genetics.IFruitBearer; import forestry.core.ModuleCore; @@ -40,12 +40,11 @@ import forestry.farming.logic.crops.CropFruit; public class FarmLogicOrchard extends FarmLogic { - private final Collection farmables; private final HashMap lastExtents = new HashMap<>(); private final ImmutableList traversalBlocks; - public FarmLogicOrchard() { - this.farmables = ForestryAPI.farmRegistry.getFarmables("farmOrchard"); + public FarmLogicOrchard(IFarmInstance instance, boolean isManual) { + super(instance, isManual); ImmutableList.Builder traversalBlocksBuilder = ImmutableList.builder(); // if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.AGRICRAFT) || ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.INDUSTRIALCRAFT)) { @@ -64,8 +63,6 @@ public class FarmLogicOrchard extends FarmLogic { // traversalBlocksBuilder.add(grapeVine); // } // } - - traversalBlocksBuilder.build(); this.traversalBlocks = traversalBlocksBuilder.build(); } @@ -209,7 +206,7 @@ public class FarmLogicOrchard extends FarmLogic { return true; } - for (IFarmable farmable : farmables) { + for (IFarmable farmable : getFarmables()) { if (farmable.isSaplingAt(world, position)) { return true; } @@ -238,7 +235,7 @@ public class FarmLogicOrchard extends FarmLogic { } } else { IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : farmables) { + for (IFarmable seed : getFarmables()) { ICrop crop = seed.getCropAt(world, position, blockState); if (crop != null) { return crop; diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 85c4bef7a..bfff9ab0f 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -21,24 +21,14 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmInstance; import forestry.core.ModuleCore; import forestry.core.blocks.BlockBogEarth; import forestry.farming.logic.crops.CropPeat; public class FarmLogicPeat extends FarmLogicWatered { - private static final ItemStack bogEarth = ModuleCore.getBlocks().bogEarth.get(BlockBogEarth.SoilType.BOG_EARTH, 1); - - public FarmLogicPeat() { - super(bogEarth, ModuleCore.getBlocks().bogEarth.getDefaultState()); - } - - @Override - public boolean isAcceptedGround(IBlockState blockState) { - if (super.isAcceptedGround(blockState)) { - return true; - } - - return blockState.getBlock() == ModuleCore.getBlocks().bogEarth; + public FarmLogicPeat(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicReeds.java b/src/main/java/forestry/farming/logic/FarmLogicReeds.java index cc32c662b..847c12c52 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicReeds.java +++ b/src/main/java/forestry/farming/logic/FarmLogicReeds.java @@ -10,11 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; @@ -22,18 +17,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; -import forestry.farming.FarmRegistry; +import forestry.api.farming.IFarmInstance; public class FarmLogicReeds extends FarmLogicSoil { - private final Collection germlings = FarmRegistry.getInstance().getFarmables("farmPoales"); - - - public FarmLogicReeds() { - addSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); - addSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(),false); + public FarmLogicReeds(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override @@ -61,18 +50,12 @@ public class FarmLogicReeds extends FarmLogicSoil { } @Override - public boolean isAcceptedResource(ItemStack itemstack) { + public boolean isAcceptedResource(ItemStack itemStack) { if (isManual) { return false; } - for(Soil soil : soils){ - ItemStack resource = soil.getResource(); - if(resource.isItemEqual(itemstack)){ - return true; - } - } - return false; + return super.isAcceptedResource(itemStack); } @@ -100,21 +83,4 @@ public class FarmLogicReeds extends FarmLogicSoil { return false; } - @Override - public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - Stack crops = new Stack<>(); - for (int i = 0; i < extent; i++) { - BlockPos position = translateWithOffset(pos.up(), direction, i); - IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : germlings) { - ICrop crop = seed.getCropAt(world, position, blockState); - if (crop != null) { - crops.push(crop); - break; - } - } - } - return crops; - } - } diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 66da5f732..4e971c7c0 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -25,6 +25,7 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.farming.logic.crops.CropRubber; @@ -34,7 +35,8 @@ public class FarmLogicRubber extends FarmLogic { private boolean active = true; - public FarmLogicRubber() { + public FarmLogicRubber(IFarmInstance instance, boolean isManual) { + super(instance, isManual); if (PluginIC2.rubberWood == null || PluginIC2.resin == null) { Log.warning("Failed to init a farm logic {} since IC2 rubber wood or resin were not found", getClass().getName()); active = false; @@ -131,5 +133,5 @@ public class FarmLogicRubber extends FarmLogic { return crops; } - + } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSimple.java b/src/main/java/forestry/farming/logic/FarmLogicSimple.java index feb2f3a5b..786ab8755 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicSimple.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSimple.java @@ -1,14 +1,16 @@ package forestry.farming.logic; -import forestry.api.farming.ISimpleFarmLogic; import net.minecraft.item.ItemStack; +import forestry.api.farming.IFarmInstance; +import forestry.api.farming.ISimpleFarmLogic; + public class FarmLogicSimple extends FarmLogicCrops { - protected final ISimpleFarmLogic simpleLogic; - - public FarmLogicSimple(ISimpleFarmLogic simpleLogic) { - super(simpleLogic.getSeeds()); + private final ISimpleFarmLogic simpleLogic; + + public FarmLogicSimple(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleLogic) { + super(instance, isManual); this.simpleLogic = simpleLogic; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSoil.java b/src/main/java/forestry/farming/logic/FarmLogicSoil.java index d58e1f53c..cf3e20ab8 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicSoil.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSoil.java @@ -1,20 +1,23 @@ package forestry.farming.logic; -import java.util.HashSet; -import java.util.Set; - import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; -public abstract class FarmLogicSoil extends FarmLogic { - protected final Set soils = new HashSet<>(); +import forestry.api.farming.IFarmInstance; - public FarmLogicSoil() { +public abstract class FarmLogicSoil extends FarmLogic { + + public FarmLogicSoil(IFarmInstance instance, boolean isManual) { + super(instance, isManual); + } + + protected boolean isAcceptedSoil(IBlockState blockState) { + return instance.isAcceptedSoil(blockState); } @Override - public void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - soils.add(new Soil(resource,soilState,hasMetaData)); + public boolean isAcceptedResource(ItemStack itemStack) { + return instance.isAcceptedResource(itemStack); } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index 560162033..201651e10 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -10,10 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import java.util.Collection; -import java.util.Stack; - -import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -22,19 +18,15 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import forestry.api.farming.FarmDirection; -import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmable; +import forestry.api.farming.IFarmInstance; import forestry.core.utils.ItemStackUtil; -import forestry.farming.FarmRegistry; public class FarmLogicSucculent extends FarmLogicSoil { - private final Collection germlings = FarmRegistry.getInstance().getFarmables("farmSucculentes"); - - public FarmLogicSucculent() { - addSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); + public FarmLogicSucculent(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } - + @Override public ItemStack getIconItemStack() { return new ItemStack(Items.DYE, 1, 2); @@ -48,7 +40,7 @@ public class FarmLogicSucculent extends FarmLogicSoil { return "Managed Succulent Farm"; } } - + @Override public int getFertilizerConsumption() { return 10; @@ -58,20 +50,14 @@ public class FarmLogicSucculent extends FarmLogicSoil { public int getWaterConsumption(float hydrationModifier) { return 1; } - + @Override - public boolean isAcceptedResource(ItemStack itemstack) { + public boolean isAcceptedResource(ItemStack itemStack) { if (isManual) { return false; } - for(Soil soil : soils){ - ItemStack resource = soil.getResource(); - if(resource.isItemEqual(itemstack)) { - return true; - } - } - return false; + return super.isAcceptedResource(itemStack); } @Override @@ -98,21 +84,4 @@ public class FarmLogicSucculent extends FarmLogicSoil { return false; } - @Override - public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { - Stack crops = new Stack<>(); - for (int i = 0; i < extent; i++) { - BlockPos position = translateWithOffset(pos.up(), direction, i); - IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : germlings) { - ICrop crop = seed.getCropAt(world, position, blockState); - if (crop != null) { - crops.push(crop); - break; - } - } - } - return crops; - } - } diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index e7143f186..14cbe29b9 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -10,7 +10,6 @@ ******************************************************************************/ package forestry.farming.logic; -import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -24,6 +23,8 @@ import net.minecraftforge.fluids.FluidStack; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; +import forestry.api.farming.ISoil; import forestry.core.utils.BlockUtil; public abstract class FarmLogicWatered extends FarmLogicSoil { @@ -31,8 +32,8 @@ public abstract class FarmLogicWatered extends FarmLogicSoil { protected NonNullList produce = NonNullList.create(); - protected FarmLogicWatered(ItemStack resource, IBlockState ground) { - addSoil(resource,ground,false); + public FarmLogicWatered(IFarmInstance instance, boolean isManual) { + super(instance, isManual); } @Override @@ -45,31 +46,6 @@ public abstract class FarmLogicWatered extends FarmLogicSoil { return (int) (20 * hydrationModifier); } - protected boolean isAcceptedGround(IBlockState ground) { - for(Soil soil : soils){ - IBlockState soilState = soil.getSoilState(); - Block soilBlock = soilState.getBlock(); - Block block = ground.getBlock(); - if(soilState.getBlock() == ground.getBlock()){ - if(!soil.hasMetaData() || block.getMetaFromState(ground) == soilBlock.getMetaFromState(soilState)){ - return true; - } - } - } - return false; - } - - @Override - public boolean isAcceptedResource(ItemStack itemstack) { - for(Soil soil : soils){ - ItemStack resource = soil.getResource(); - if(resource.isItemEqual(itemstack)){ - return true; - } - } - return false; - } - @Override public NonNullList collect(World world, IFarmHousing farmHousing) { NonNullList products = produce; @@ -79,7 +55,6 @@ public abstract class FarmLogicWatered extends FarmLogicSoil { @Override public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - if (maintainSoil(world, farmHousing, pos, direction, extent)) { return true; } @@ -93,33 +68,37 @@ public abstract class FarmLogicWatered extends FarmLogicSoil { } private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - for (Soil soil : soils) { + if(!farmHousing.canPlantSoil(isManual)){ + return false; + } + + for (ISoil soil : getSoils()) { NonNullList resources = NonNullList.create(); resources.add(soil.getResource()); for (int i = 0; i < extent; i++) { BlockPos position = translateWithOffset(pos, direction, i); IBlockState state = world.getBlockState(position); - if (isAcceptedGround(state) || isWaterSourceBlock(world, position) || !farmHousing.getFarmInventory().hasResources(resources)) { + if (isAcceptedSoil(state) || isWaterSourceBlock(world, position) || !farmHousing.getFarmInventory().hasResources(resources)) { continue; } - + BlockPos platformPosition = position.down(); if (!farmHousing.isValidPlatform(world, platformPosition)) { break; } - + if (!BlockUtil.isReplaceableBlock(state, world, position)) { produce.addAll(BlockUtil.getBlockDrops(world, position)); world.setBlockToAir(position); return trySetSoil(world, farmHousing, position, soil.getResource(), soil.getSoilState()); } - + if (!isManual) { if (trySetWater(world, farmHousing, position)) { return true; } - + return trySetSoil(world, farmHousing, position, soil.getResource(), soil.getSoilState()); } } diff --git a/src/main/java/forestry/farming/logic/Soil.java b/src/main/java/forestry/farming/logic/Soil.java index 19fe7a77d..cb5334e16 100644 --- a/src/main/java/forestry/farming/logic/Soil.java +++ b/src/main/java/forestry/farming/logic/Soil.java @@ -1,28 +1,30 @@ -package forestry.farming.logic; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; - -class Soil { - private final ItemStack resource; - private final IBlockState soilState; - private final boolean hasMetaData; - - public Soil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { - this.resource = resource; - this.soilState = soilState; - this.hasMetaData = hasMetaData; - } - - public ItemStack getResource() { - return resource; - } - - public IBlockState getSoilState() { - return soilState; - } - - public boolean hasMetaData() { - return this.hasMetaData; - } +package forestry.farming.logic; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; + +import forestry.api.farming.ISoil; + +class Soil implements ISoil { + private final ItemStack resource; + private final IBlockState soilState; + private final boolean hasMetaData; + + public Soil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { + this.resource = resource; + this.soilState = soilState; + this.hasMetaData = hasMetaData; + } + + public ItemStack getResource() { + return resource; + } + + public IBlockState getSoilState() { + return soilState; + } + + public boolean hasMetaData() { + return this.hasMetaData; + } } \ No newline at end of file diff --git a/src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java b/src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java index ba5444119..6fcbec840 100644 --- a/src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java +++ b/src/main/java/forestry/farming/logic/crops/CropBasicIC2Crop.java @@ -34,6 +34,7 @@ public class CropBasicIC2Crop extends Crop { /** * Check if there is an instance of ICropTile. + * * @param tileEntity tile entity to be checked. * @return true if there is an IC2 crop and false otherwise. */ @@ -44,6 +45,7 @@ public class CropBasicIC2Crop extends Crop { /** * Check if an IC2 crop is ready to be harvested. + * * @param tileEntity tile entity to be checked. * @return true if crop size is optimal for harvest and false otherwise. */ @@ -64,6 +66,7 @@ public class CropBasicIC2Crop extends Crop { /** * This function takes care of everything related to the harvesting of the * crop meaning it will calculate the drops and also do setSizeAfterHarvest(). + * * @param tileEntity tile entity to be checked. * @return list containing the drops. */ diff --git a/src/main/java/forestry/farming/logic/crops/CropDestroy.java b/src/main/java/forestry/farming/logic/crops/CropDestroy.java index bd9d68263..458eb9da4 100644 --- a/src/main/java/forestry/farming/logic/crops/CropDestroy.java +++ b/src/main/java/forestry/farming/logic/crops/CropDestroy.java @@ -11,6 +11,7 @@ package forestry.farming.logic.crops; import javax.annotation.Nullable; +import java.util.Iterator; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -19,8 +20,11 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.event.ForgeEventFactory; + import forestry.core.config.Constants; import forestry.core.network.packets.PacketFXSignal; +import forestry.core.utils.ItemStackUtil; import forestry.core.utils.NetworkUtil; public class CropDestroy extends Crop { @@ -29,10 +33,17 @@ public class CropDestroy extends Crop { @Nullable protected final IBlockState replantState; + protected final ItemStack germling; + public CropDestroy(World world, IBlockState blockState, BlockPos position, @Nullable IBlockState replantState) { + this(world, blockState, position, replantState, ItemStack.EMPTY); + } + + public CropDestroy(World world, IBlockState blockState, BlockPos position, @Nullable IBlockState replantState, ItemStack germling) { super(world, position); this.blockState = blockState; this.replantState = replantState; + this.germling = germling; } @Override @@ -45,6 +56,22 @@ public class CropDestroy extends Crop { Block block = blockState.getBlock(); NonNullList harvested = NonNullList.create(); harvested.addAll(block.getDrops(world, pos, blockState, 0)); + float chance = ForgeEventFactory.fireBlockHarvesting(harvested, world, pos, blockState, 0, 1.0F, false, null); + + boolean removedSeed = germling.isEmpty(); + Iterator dropIterator = harvested.iterator(); + while (dropIterator.hasNext()) { + ItemStack next = dropIterator.next(); + if (world.rand.nextFloat() <= chance) { + if (!removedSeed && ItemStackUtil.isIdenticalItem(next, germling)) { + next.shrink(1); + if (next.isEmpty()) { + dropIterator.remove(); + } + removedSeed = true; + } + } + } PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, blockState); NetworkUtil.sendNetworkPacket(packet, pos, world); diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java index 53f539291..a9f0b9c72 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java @@ -62,7 +62,7 @@ public class FarmableAgingCrop implements IFarmable { } IBlockState replantState = getReplantState(blockState); - return new CropDestroy(world, blockState, pos, replantState); + return new CropDestroy(world, blockState, pos, replantState, germling); } @Nullable diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java index 95df1a937..7d1b0111c 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java @@ -29,66 +29,66 @@ import forestry.core.utils.NetworkUtil; import forestry.farming.logic.crops.CropDestroy; public class FarmableSapling implements IFarmable { - protected final ItemStack germling; - protected final boolean ignoreMetadata; - protected final Block saplingBlock; - protected final ItemStack[] windfall; + protected final ItemStack germling; + protected final boolean ignoreMetadata; + protected final Block saplingBlock; + protected final ItemStack[] windfall; - public FarmableSapling(final ItemStack germling, final ItemStack[] windfall) { - this(germling, windfall, true); - } + public FarmableSapling(final ItemStack germling, final ItemStack[] windfall) { + this(germling, windfall, true); + } - public FarmableSapling(final ItemStack germling, final ItemStack[] windfall, boolean addSubItems) { - this.germling = germling; - this.windfall = windfall; - this.saplingBlock = ItemStackUtil.getBlock(germling); - this.ignoreMetadata = addSubItems; - } + public FarmableSapling(final ItemStack germling, final ItemStack[] windfall, boolean addSubItems) { + this.germling = germling; + this.windfall = windfall; + this.saplingBlock = ItemStackUtil.getBlock(germling); + this.ignoreMetadata = addSubItems; + } - @Override - public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - ItemStack copy = germling.copy(); - player.setHeldItem(EnumHand.MAIN_HAND, copy); - EnumActionResult actionResult = copy.onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); - player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); - if (actionResult == EnumActionResult.SUCCESS) { - PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState()); - NetworkUtil.sendNetworkPacket(packet, pos, world); - return true; - } - return false; - } + @Override + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { + ItemStack copy = germling.copy(); + player.setHeldItem(EnumHand.MAIN_HAND, copy); + EnumActionResult actionResult = copy.onItemUse(player, world, pos.down(), EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0); + player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); + if (actionResult == EnumActionResult.SUCCESS) { + PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.SoundFXType.BLOCK_PLACE, pos, Blocks.SAPLING.getDefaultState()); + NetworkUtil.sendNetworkPacket(packet, pos, world); + return true; + } + return false; + } - @Override - public boolean isSaplingAt(World world, BlockPos pos) { - return world.getBlockState(pos).getBlock() == this.saplingBlock; - } + @Override + public boolean isSaplingAt(World world, BlockPos pos) { + return world.getBlockState(pos).getBlock() == this.saplingBlock; + } - @Override - public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) { - Block block = blockState.getBlock(); - if (!block.isWood(world, pos)) { - return null; - } + @Override + public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) { + Block block = blockState.getBlock(); + if (!block.isWood(world, pos)) { + return null; + } - return new CropDestroy(world, blockState, pos, null); - } + return new CropDestroy(world, blockState, pos, null); + } - @Override - public boolean isGermling(ItemStack itemstack) { - if (ignoreMetadata) { - return ItemStack.areItemsEqual(germling, new ItemStack((itemstack.getItem()))); - } - return ItemStack.areItemsEqual(germling, itemstack); - } + @Override + public boolean isGermling(ItemStack itemstack) { + if (ignoreMetadata) { + return ItemStack.areItemsEqual(germling, new ItemStack((itemstack.getItem()))); + } + return ItemStack.areItemsEqual(germling, itemstack); + } - @Override - public boolean isWindfall(ItemStack itemstack) { - for (ItemStack drop : windfall) { - if (drop.isItemEqual(itemstack)) { - return true; - } - } - return false; - } + @Override + public boolean isWindfall(ItemStack itemstack) { + for (ItemStack drop : windfall) { + if (drop.isItemEqual(itemstack)) { + return true; + } + } + return false; + } } diff --git a/src/main/java/forestry/farming/logic/package-info.java b/src/main/java/forestry/farming/logic/package-info.java index 4f11ab53c..8f32cf8d6 100644 --- a/src/main/java/forestry/farming/logic/package-info.java +++ b/src/main/java/forestry/farming/logic/package-info.java @@ -5,5 +5,6 @@ package forestry.farming.logic; import javax.annotation.ParametersAreNonnullByDefault; -import forestry.core.utils.FieldsAreNonnullByDefault; -import mcp.MethodsReturnNonnullByDefault; \ No newline at end of file +import mcp.MethodsReturnNonnullByDefault; + +import forestry.core.utils.FieldsAreNonnullByDefault; \ No newline at end of file diff --git a/src/main/java/forestry/farming/multiblock/FakeFarmController.java b/src/main/java/forestry/farming/multiblock/FakeFarmController.java index db497891c..9090f13a1 100644 --- a/src/main/java/forestry/farming/multiblock/FakeFarmController.java +++ b/src/main/java/forestry/farming/multiblock/FakeFarmController.java @@ -30,8 +30,8 @@ import forestry.core.fluids.ITankManager; import forestry.core.inventory.FakeInventoryAdapter; import forestry.core.inventory.IInventoryAdapter; import forestry.core.multiblock.FakeMultiblockController; +import forestry.farming.FarmRegistry; import forestry.farming.gui.IFarmLedgerDelegate; -import forestry.farming.logic.FarmLogicArboreal; public class FakeFarmController extends FakeMultiblockController implements IFarmControllerInternal { public static final FakeFarmController instance = new FakeFarmController(); @@ -87,7 +87,7 @@ public class FakeFarmController extends FakeMultiblockController implements IFar @Override public IFarmLogic getFarmLogic(FarmDirection direction) { - return new FarmLogicArboreal(); + return FarmRegistry.getInstance().getFarm("farmArboreal").getLogic(false); } @Override diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index 27dd0941d..57094a766 100755 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -74,9 +74,9 @@ import forestry.core.utils.Translator; import forestry.farming.FarmHelper; import forestry.farming.FarmHelper.FarmWorkStatus; import forestry.farming.FarmHelper.Stage; +import forestry.farming.FarmRegistry; import forestry.farming.FarmTarget; import forestry.farming.gui.IFarmLedgerDelegate; -import forestry.farming.logic.FarmLogicArboreal; import forestry.farming.tiles.TileFarmGearbox; import forestry.farming.tiles.TileFarmPlain; @@ -630,7 +630,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen @Override public void resetFarmLogic(FarmDirection direction) { - setFarmLogic(direction, new FarmLogicArboreal()); + setFarmLogic(direction, FarmRegistry.getInstance().getFarm("farmArboreal").getLogic(false)); } @Override diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java index 625b3c745..9f5ba2029 100644 --- a/src/main/java/forestry/plugins/PluginExtraUtilities.java +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -16,6 +16,7 @@ import java.util.function.Consumer; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -26,6 +27,8 @@ import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitLayout; import forestry.api.core.ForestryAPI; +import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmRegistry; import forestry.api.modules.ForestryModule; import forestry.core.ModuleCore; import forestry.core.circuits.Circuits; @@ -61,17 +64,19 @@ public class PluginExtraUtilities extends BlankForestryModule { @Override public void doInit() { if (Config.isExUtilRedOrchidEnabled()) { - registerExPlant("Orchid", "redorchid", "Red Orchid", Blocks.REDSTONE_ORE, circuit -> Circuits.farmOrchidManaged = circuit); + registerExPlant("Orchid", "redorchid", "Red Orchid", circuit -> Circuits.farmOrchidManaged = circuit, Blocks.REDSTONE_ORE, Blocks.LIT_REDSTONE_ORE); } if (Config.isExUtilEnderLilyEnabled()) { - registerExPlant("Ender", "enderlilly", "Ender Lily", Blocks.END_STONE, circuit -> Circuits.farmEnderManaged = circuit); + registerExPlant("Ender", "enderlilly", "Ender Lily", circuit -> Circuits.farmEnderManaged = circuit, Blocks.END_STONE); } } @Override public void registerRecipes() { - if (!ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING))) return; + if (!ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING))) { + return; + } if(Circuits.farmEnderManaged != null) { ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); ChipsetManager.solderManager.addRecipe(layoutManaged, ModuleCore.getItems().tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManaged); @@ -82,22 +87,28 @@ public class PluginExtraUtilities extends BlankForestryModule { } } - private void registerExPlant(String id, String itemResourceName, String itemName, Block soil, Consumer assignTo) { + private void registerExPlant(String id, String itemResourceName, String itemName, Consumer assignTo, Block... soils) { Block plantBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ExU, itemResourceName)); Item plantItem = Item.getItemFromBlock(plantBlock); if(plantBlock == Blocks.AIR) { Log.error("Could not find {} block.", itemName); - } else if (plantItem == null) { + } else if (plantItem == Items.AIR) { Log.error("Could not find {} item.", itemName); } else { IProperty growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class); if (growthProperty == null) { Log.error("Could not find the growth property of {}.", itemName); } else { + IFarmRegistry registry = FarmRegistry.getInstance(); int harvestAge = Collections.max(growthProperty.getAllowedValues()); int replantAge = plantBlock.getDefaultState().getValue(growthProperty); - FarmRegistry.getInstance().registerFarmables(itemName, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); - assignTo.accept(new CircuitFarmLogic("managed" + id, new FarmLogicExU("Managed " + itemName + " Farm", plantItem, soil, itemName))); + registry.registerFarmables(itemName, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); + + IFarmInstance instance = registry.registerLogic("farm" + id, (i, m) -> new FarmLogicExU(i, m, (m ? "Manual " : "Managed ") + itemName + " Farm", plantItem), itemName); + for(Block soil : soils) { + instance.registerSoil(new ItemStack(soil), soil.getDefaultState()); + } + assignTo.accept(new CircuitFarmLogic("managed" + id, instance, false)); } } } diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 687a629f2..0c16ae550 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -31,6 +31,7 @@ import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitLayout; import forestry.api.core.ForestryAPI; +import forestry.api.farming.IFarmInstance; import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.FuelManager; import forestry.api.modules.ForestryModule; @@ -116,7 +117,9 @@ public class PluginIC2 extends BlankForestryModule { rubber = IC2Items.getItem("crafting", "rubber"); fertilizer = IC2Items.getItem("crop_res","fertilizer"); - Circuits.farmRubberManual = new CircuitFarmLogic("manualRubber", new FarmLogicRubber()); + IFarmInstance rubberFarm = FarmRegistry.getInstance().registerLogic("farmRubber", FarmLogicRubber::new); + + Circuits.farmRubberManual = new CircuitFarmLogic("manualRubber", rubberFarm, true); ICircuitLayout layoutEngineTin = new CircuitLayout("engine.tin", CircuitSocketType.ELECTRIC_ENGINE); ChipsetManager.circuitRegistry.registerLayout(layoutEngineTin); diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index ef1befabc..89c11d2c0 100644 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -33,7 +33,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; import forestry.api.core.ForestryAPI; -import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmInstance; import forestry.api.fuels.FuelManager; import forestry.api.fuels.MoistenerFuel; import forestry.api.modules.ForestryModule; @@ -266,8 +266,10 @@ public class PluginNatura extends BlankForestryModule { */ @Override public void postInit() { - IFarmLogic farmArboreal = FarmRegistry.getInstance().getFarmLogic("farmArboreal"); - farmArboreal.addSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState(), false); + IFarmInstance farmArboreal = FarmRegistry.getInstance().getFarm("managedArboreal"); + if(farmArboreal != null) { + farmArboreal.registerSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState(), false); + } } From 287cb8cb87291e18afe3df0c244c5d567f0eac01 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Sat, 20 Jan 2018 18:05:31 +0100 Subject: [PATCH 04/12] Rebalance electron tubes and add ender farm --- .../forestry/api/farming/IFarmInstance.java | 2 + .../java/forestry/api/farming/IFarmable.java | 13 +- .../java/forestry/core/circuits/Circuits.java | 3 +- .../forestry/core/render/ParticleRender.java | 21 +++ .../cultivation/ModuleCultivation.java | 53 +++--- .../cultivation/blocks/BlockPlanter.java | 30 ++-- .../blocks/BlockRegistryCultivation.java | 5 + .../cultivation/blocks/BlockTypePlanter.java | 9 +- .../cultivation/blocks/PlanterProperties.java | 27 +++ .../cultivation/tiles/TileFarmEnder.java | 41 +++++ .../java/forestry/farming/FarmRegistry.java | 6 +- .../java/forestry/farming/ModuleFarming.java | 43 +++-- .../farming/logic/FakeFarmInstance.java | 4 + .../forestry/farming/logic/FarmInstance.java | 20 ++- .../forestry/farming/logic/FarmLogic.java | 28 ++-- .../farming/logic/FarmLogicArboreal.java | 5 +- .../farming/logic/FarmLogicEnder.java | 154 ++++++++++++++++++ .../farming/logic/FarmLogicOrchard.java | 20 +-- .../farming/logic/crops/CropChorusFlower.java | 42 +++++ .../farming/logic/crops/CropDestroy.java | 2 + .../logic/farmables/FarmableAgingCrop.java | 3 +- .../farming/logic/farmables/FarmableBase.java | 3 +- .../logic/farmables/FarmableChorus.java | 80 +++++++++ .../logic/farmables/FarmableDoubleCrop.java | 3 +- .../farming/logic/farmables/FarmableGE.java | 10 +- .../logic/farmables/FarmableGourd.java | 3 +- .../logic/farmables/FarmableRusticGrape.java | 3 +- .../farmables/FarmableRusticSapling.java | 4 +- .../logic/farmables/FarmableSapling.java | 4 +- .../logic/farmables/FarmableStacked.java | 3 +- .../plugins/PluginExtraUtilities.java | 20 +-- .../forestry/blockstates/farm_ender.json | 8 + .../forestry/models/block/farm_ender.json | 57 +++++++ .../forestry/models/item/farm_ender.json | 3 + .../forestry/textures/blocks/farm_ender.png | Bin 0 -> 1780 bytes .../textures/blocks/farm_ender_particle.png | Bin 0 -> 417 bytes 36 files changed, 617 insertions(+), 115 deletions(-) create mode 100644 src/main/java/forestry/cultivation/blocks/PlanterProperties.java create mode 100644 src/main/java/forestry/cultivation/tiles/TileFarmEnder.java create mode 100644 src/main/java/forestry/farming/logic/FarmLogicEnder.java create mode 100644 src/main/java/forestry/farming/logic/crops/CropChorusFlower.java create mode 100644 src/main/java/forestry/farming/logic/farmables/FarmableChorus.java create mode 100644 src/main/resources/assets/forestry/blockstates/farm_ender.json create mode 100644 src/main/resources/assets/forestry/models/block/farm_ender.json create mode 100644 src/main/resources/assets/forestry/models/item/farm_ender.json create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_ender.png create mode 100644 src/main/resources/assets/forestry/textures/blocks/farm_ender_particle.png diff --git a/src/main/java/forestry/api/farming/IFarmInstance.java b/src/main/java/forestry/api/farming/IFarmInstance.java index 6903e2711..8cd89c5e9 100644 --- a/src/main/java/forestry/api/farming/IFarmInstance.java +++ b/src/main/java/forestry/api/farming/IFarmInstance.java @@ -14,6 +14,8 @@ public interface IFarmInstance { registerSoil(resource, soilState, false); } + void registerFarmables(String identifier); + void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData); boolean isAcceptedSoil(IBlockState blockState); diff --git a/src/main/java/forestry/api/farming/IFarmable.java b/src/main/java/forestry/api/farming/IFarmable.java index b51eb8ba6..d13f09b47 100644 --- a/src/main/java/forestry/api/farming/IFarmable.java +++ b/src/main/java/forestry/api/farming/IFarmable.java @@ -20,8 +20,19 @@ public interface IFarmable { /** * @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop. + * @deprecated Since Forestry 5.8. Use the version below. TODO Remove this method in 1.13 */ - boolean isSaplingAt(World world, BlockPos pos); + @Deprecated + default boolean isSaplingAt(World world, BlockPos pos){ + return false; + } + + /** + * @return true if the block at the given location is a "sapling" for this type, i.e. a non-harvestable immature version of the crop. + */ + default boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState){ + return isSaplingAt(world, pos); + } /** * @return {@link ICrop} if the block at the given location is a harvestable and mature crop, null otherwise. diff --git a/src/main/java/forestry/core/circuits/Circuits.java b/src/main/java/forestry/core/circuits/Circuits.java index aeee7dd36..81eb7f390 100644 --- a/src/main/java/forestry/core/circuits/Circuits.java +++ b/src/main/java/forestry/core/circuits/Circuits.java @@ -15,11 +15,12 @@ public class Circuits { public static ICircuit farmCropsManaged; public static ICircuit farmPeatManaged; public static ICircuit farmSucculentManaged; - public static ICircuit farmPoaleManaged; + public static ICircuit farmPoalesManaged; public static ICircuit farmInfernalManaged; public static ICircuit farmEnderManaged; public static ICircuit farmOrchidManaged; public static ICircuit farmGourdManaged; + public static ICircuit farmCocoaManaged; public static ICircuit farmArborealManual; diff --git a/src/main/java/forestry/core/render/ParticleRender.java b/src/main/java/forestry/core/render/ParticleRender.java index b79312fd6..05a92a862 100755 --- a/src/main/java/forestry/core/render/ParticleRender.java +++ b/src/main/java/forestry/core/render/ParticleRender.java @@ -1,6 +1,7 @@ package forestry.core.render; import java.util.List; +import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.Particle; @@ -157,6 +158,26 @@ public class ParticleRender { effectRenderer.addEffect(particle); } } + + public static void addPortalFx(World world, BlockPos pos, Random rand){ + if (!shouldSpawnParticle(world)) { + return; + } + + int j = rand.nextInt(2) * 2 - 1; + int k = rand.nextInt(2) * 2 - 1; + double xPos = (double)pos.getX() + 0.5D + 0.25D * (double)j; + double yPos = (double)((float)pos.getY() + rand.nextFloat()); + double zPos = (double)pos.getZ() + 0.5D + 0.25D * (double)k; + double xSpeed = (double)(rand.nextFloat() * (float)j); + double ySpeed = ((double)rand.nextFloat() - 0.5D) * 0.125D; + double zSpeed = (double)(rand.nextFloat() * (float)k); + ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; + Particle particle = effectRenderer.spawnEffectParticle(EnumParticleTypes.PORTAL.getParticleID(), xPos, yPos, zPos, xSpeed, ySpeed, zSpeed); + if(particle != null){ + effectRenderer.addEffect(particle); + } + } public static void addEntityBiodustFX(World world, double x, double y, double z){ if (!shouldSpawnParticle(world)) { diff --git a/src/main/java/forestry/cultivation/ModuleCultivation.java b/src/main/java/forestry/cultivation/ModuleCultivation.java index 3e33df0c8..a5e8d73f0 100644 --- a/src/main/java/forestry/cultivation/ModuleCultivation.java +++ b/src/main/java/forestry/cultivation/ModuleCultivation.java @@ -6,8 +6,6 @@ import com.google.common.collect.ImmutableSet; import javax.annotation.Nullable; import java.util.Set; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.util.ResourceLocation; import forestry.api.modules.ForestryModule; @@ -53,6 +51,7 @@ public class ModuleCultivation extends BlankForestryModule { blocks.farmMushroom.init(); blocks.farmNether.init(); blocks.farmGourd.init(); + blocks.farmEnder.init(); //blocks.plantation.init(); blocks.peatBog.init(); } @@ -85,39 +84,49 @@ public class ModuleCultivation extends BlankForestryModule { "TCT", "GBG", 'G', OreDictUtil.BLOCK_GLASS, - 'T', coreItems.tubes.get(EnumElectronTube.COPPER, 1), + 'T', coreItems.tubes.get(EnumElectronTube.OBSIDIAN, 1), 'C', coreItems.sturdyCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_mushroom", blocks.farmMushroom, - "BGR", - "GAG", - "RGB", + "GTG", + "TCT", + "GBG", 'G', OreDictUtil.BLOCK_GLASS, - 'B', Blocks.BROWN_MUSHROOM, - 'R', Blocks.RED_MUSHROOM, - 'A', blocks.arboretum); + 'T', coreItems.tubes.get(EnumElectronTube.APATITE, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_gourd", blocks.farmGourd, - "MGP", - "GAG", - "PGM", + "GTG", + "TCT", + "GBG", 'G', OreDictUtil.BLOCK_GLASS, - 'M', Blocks.MELON_BLOCK, - 'P', Blocks.PUMPKIN, - 'A', blocks.arboretum); + 'T', coreItems.tubes.get(EnumElectronTube.LAPIS, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_nether", blocks.farmNether, - "WGW", - "GAG", - "WGW", + "GTG", + "TCT", + "GBG", 'G', OreDictUtil.BLOCK_GLASS, - 'W', Items.NETHER_WART, - 'A', blocks.arboretum); + 'T', coreItems.tubes.get(EnumElectronTube.BLAZE, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); + + RecipeUtil.addRecipe("farm_ender", blocks.farmEnder, + "GTG", + "TCT", + "GBG", + 'G', OreDictUtil.BLOCK_GLASS, + 'T', coreItems.tubes.get(EnumElectronTube.ENDER, 1), + 'C', coreItems.sturdyCasing, + 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); for(BlockPlanter planter : getBlocks().getPlanters()){ - RecipeUtil.addRecipe(planter.blockType.getName() + "_manual_managed", planter.get(true), "# ", " ", " ", '#', planter.get(false)); - RecipeUtil.addRecipe(planter.blockType.getName() + "_managed_manual", planter.get(false), "# ", " ", " ", '#', planter.get(true)); + RecipeUtil.addShapelessRecipe(planter.blockType.getName() + "_manual_managed", planter.get(true), planter.get(false)); + RecipeUtil.addShapelessRecipe(planter.blockType.getName() + "_managed_manual", planter.get(false), planter.get(true)); } } } diff --git a/src/main/java/forestry/cultivation/blocks/BlockPlanter.java b/src/main/java/forestry/cultivation/blocks/BlockPlanter.java index 92cdb1623..d596653ae 100644 --- a/src/main/java/forestry/cultivation/blocks/BlockPlanter.java +++ b/src/main/java/forestry/cultivation/blocks/BlockPlanter.java @@ -1,5 +1,7 @@ package forestry.cultivation.blocks; +import java.util.Random; + import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.BlockStateContainer; @@ -7,8 +9,6 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagByte; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; @@ -23,6 +23,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import forestry.core.blocks.BlockBase; +import forestry.core.render.ParticleRender; import forestry.cultivation.tiles.TilePlanter; public class BlockPlanter extends BlockBase { @@ -38,6 +39,16 @@ public class BlockPlanter extends BlockBase { return new BlockStateContainer(this, FACING, MANUAL); } + @SideOnly(Side.CLIENT) + @Override + public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) { + if(blockType == BlockTypePlanter.FARM_ENDER){ + for (int i = 0; i < 3; ++i) { + ParticleRender.addPortalFx(worldIn, pos, rand); + } + } + } + @Override public IBlockState getStateFromMeta(int meta) { int facing = meta & 7; @@ -62,6 +73,11 @@ public class BlockPlanter extends BlockBase { return tile; } + @Override + public int damageDropped(IBlockState state) { + return state.getValue(MANUAL) ? 1 : 0; + } + @Override @SideOnly(Side.CLIENT) public void registerStateMapper() { @@ -87,16 +103,10 @@ public class BlockPlanter extends BlockBase { } public static boolean isManual(ItemStack stack){ - NBTTagCompound tagCompound = stack.getTagCompound(); - if(tagCompound != null){ - return tagCompound.getBoolean("Manual"); - } - return false; + return stack.getMetadata() == 1; } public ItemStack get(boolean isManual){ - ItemStack stack = new ItemStack(this); - stack.setTagInfo("Manual", new NBTTagByte((byte) (isManual ? 1 : 0))); - return stack; + return new ItemStack(this, 1, isManual ? 1 : 0); } } diff --git a/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java b/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java index 3302b5d56..b67c3c048 100644 --- a/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java +++ b/src/main/java/forestry/cultivation/blocks/BlockRegistryCultivation.java @@ -14,6 +14,7 @@ public class BlockRegistryCultivation extends BlockRegistry { public final BlockPlanter farmMushroom; public final BlockPlanter farmGourd; public final BlockPlanter farmNether; + public final BlockPlanter farmEnder; public final BlockPlanter peatBog; /*public final BlockPlanter plantation;*/ @@ -38,6 +39,10 @@ public class BlockRegistryCultivation extends BlockRegistry { registerBlock(farmNether, new ItemBlockPlanter(farmNether), "farm_nether"); planters.add(farmNether); + farmEnder = new BlockPlanter(BlockTypePlanter.FARM_ENDER); + registerBlock(farmEnder, new ItemBlockPlanter(farmEnder), "farm_ender"); + planters.add(farmEnder); + peatBog = new BlockPlanter(BlockTypePlanter.PEAT_POG); registerBlock(peatBog, new ItemBlockPlanter(peatBog), "peat_bog"); planters.add(peatBog); diff --git a/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java b/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java index a2871d288..f8542dbf3 100644 --- a/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java +++ b/src/main/java/forestry/cultivation/blocks/BlockTypePlanter.java @@ -2,14 +2,14 @@ package forestry.cultivation.blocks; import forestry.core.blocks.IBlockTypeCustom; import forestry.core.blocks.IMachineProperties; -import forestry.core.blocks.MachineProperties; -import forestry.core.tiles.TileForestry; import forestry.cultivation.tiles.TileArboretum; import forestry.cultivation.tiles.TileBog; import forestry.cultivation.tiles.TileFarmCrops; +import forestry.cultivation.tiles.TileFarmEnder; import forestry.cultivation.tiles.TileFarmGourd; import forestry.cultivation.tiles.TileFarmMushroom; import forestry.cultivation.tiles.TileFarmNether; +import forestry.cultivation.tiles.TilePlanter; public enum BlockTypePlanter implements IBlockTypeCustom { ARBORETUM(TileArboretum.class, "arboretum"), @@ -17,6 +17,7 @@ public enum BlockTypePlanter implements IBlockTypeCustom { FARM_MUSHROOM(TileFarmMushroom.class, "farm_mushroom"), FARM_GOURD(TileFarmGourd.class, "farm_gourd"), FARM_NETHER(TileFarmNether.class, "farm_nether"), + FARM_ENDER(TileFarmEnder.class, "farm_ender"), PEAT_POG(TileBog.class, "peat_bog"), //TODO Add ic2 integration @@ -24,8 +25,8 @@ public enum BlockTypePlanter implements IBlockTypeCustom { private final IMachineProperties machineProperties; - BlockTypePlanter(Class teClass, String name) { - this.machineProperties = new MachineProperties<>(teClass, name); + BlockTypePlanter(Class teClass, String name) { + this.machineProperties = new PlanterProperties<>(teClass, name); } @Override diff --git a/src/main/java/forestry/cultivation/blocks/PlanterProperties.java b/src/main/java/forestry/cultivation/blocks/PlanterProperties.java new file mode 100644 index 000000000..4a334f702 --- /dev/null +++ b/src/main/java/forestry/cultivation/blocks/PlanterProperties.java @@ -0,0 +1,27 @@ +package forestry.cultivation.blocks; + +import com.google.common.base.Preconditions; + +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; + +import forestry.api.core.IModelManager; +import forestry.core.blocks.MachineProperties; +import forestry.core.utils.ItemStackUtil; +import forestry.cultivation.tiles.TilePlanter; + +public class PlanterProperties extends MachineProperties { + + PlanterProperties(Class teClass, String name) { + super(teClass, name); + } + + @Override + public void registerModel(Item item, IModelManager manager) { + ResourceLocation itemNameFromRegistry = ItemStackUtil.getItemNameFromRegistry(item); + Preconditions.checkNotNull(itemNameFromRegistry, "No registry name for item"); + String identifier = itemNameFromRegistry.getResourcePath(); + manager.registerItemModel(item, 0, identifier); + manager.registerItemModel(item, 1, identifier); + } +} diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java b/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java new file mode 100644 index 000000000..60b65f636 --- /dev/null +++ b/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java @@ -0,0 +1,41 @@ +package forestry.cultivation.tiles; + +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; + +public class TileFarmEnder extends TilePlanter { + public TileFarmEnder() { + super("farmEnder"); + } + + @Override + public ItemStack[] createGermlingStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.CHORUS_FLOWER), + new ItemStack(Blocks.CHORUS_FLOWER), + new ItemStack(Blocks.CHORUS_FLOWER), + new ItemStack(Blocks.CHORUS_FLOWER) + }; + } + + @Override + public ItemStack[] createResourceStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.END_STONE), + new ItemStack(Blocks.END_STONE), + new ItemStack(Blocks.END_STONE), + new ItemStack(Blocks.END_STONE) + }; + } + + @Override + public ItemStack[] createProductionStacks() { + return new ItemStack[]{ + new ItemStack(Blocks.CHORUS_FLOWER), + new ItemStack(Items.CHORUS_FRUIT), + new ItemStack(Items.CHORUS_FRUIT), + new ItemStack(Blocks.CHORUS_FLOWER) + }; + } +} diff --git a/src/main/java/forestry/farming/FarmRegistry.java b/src/main/java/forestry/farming/FarmRegistry.java index 4c4833212..2de995b58 100644 --- a/src/main/java/forestry/farming/FarmRegistry.java +++ b/src/main/java/forestry/farming/FarmRegistry.java @@ -16,7 +16,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.function.BiFunction; -import java.util.stream.Collectors; import net.minecraft.item.ItemStack; @@ -41,7 +40,6 @@ public final class FarmRegistry implements IFarmRegistry { private static final FarmRegistry INSTANCE = new FarmRegistry(); private final Multimap farmables = HashMultimap.create(); private final Map fertilizers = new LinkedHashMap<>(); - private final Map logics = new HashMap<>(); private final Map farmInstances = new HashMap<>(); public static FarmRegistry getInstance() { @@ -51,7 +49,6 @@ public final class FarmRegistry implements IFarmRegistry { @Override @Deprecated public void registerLogic(String identifier, IFarmLogic logic) { - logics.put(identifier, logic); } @Override @@ -103,8 +100,7 @@ public final class FarmRegistry implements IFarmRegistry { public IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { Set fIdentifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers)); fIdentifiers.add(identifier); - Collection farmablesSet = fIdentifiers.stream().map(farmables::get).flatMap(Collection::stream).collect(Collectors.toSet()); - IFarmInstance instance = new FarmInstance(identifier, logicFactory, farmablesSet); + IFarmInstance instance = new FarmInstance(identifier, logicFactory, fIdentifiers); farmInstances.put(identifier, instance); return instance; } diff --git a/src/main/java/forestry/farming/ModuleFarming.java b/src/main/java/forestry/farming/ModuleFarming.java index bdd0470a5..fe153ff05 100644 --- a/src/main/java/forestry/farming/ModuleFarming.java +++ b/src/main/java/forestry/farming/ModuleFarming.java @@ -65,6 +65,7 @@ import forestry.farming.circuits.CircuitFarmLogic; import forestry.farming.logic.FarmLogicArboreal; import forestry.farming.logic.FarmLogicCocoa; import forestry.farming.logic.FarmLogicCrops; +import forestry.farming.logic.FarmLogicEnder; import forestry.farming.logic.FarmLogicGourd; import forestry.farming.logic.FarmLogicInfernal; import forestry.farming.logic.FarmLogicMushroom; @@ -73,6 +74,7 @@ import forestry.farming.logic.FarmLogicPeat; import forestry.farming.logic.FarmLogicReeds; import forestry.farming.logic.FarmLogicSucculent; import forestry.farming.logic.farmables.FarmableAgingCrop; +import forestry.farming.logic.farmables.FarmableChorus; import forestry.farming.logic.farmables.FarmableGE; import forestry.farming.logic.farmables.FarmableGourd; import forestry.farming.logic.farmables.FarmableStacked; @@ -153,6 +155,8 @@ public class ModuleFarming extends BlankForestryModule { registry.registerFarmables("farmSucculentes", new FarmableStacked(new ItemStack(Blocks.CACTUS), Blocks.CACTUS, 3)); + registry.registerFarmables("farmEnder", FarmableChorus.INSTANCE); + //Forestry fertilizer registry.registerFertilizer(new ItemStack(coreItems.fertilizerCompound, 1, OreDictionary.WILDCARD_VALUE), 500); @@ -198,6 +202,7 @@ public class ModuleFarming extends BlankForestryModule { IFarmInstance orchardFarm = registry.registerLogic("farmOrchard", FarmLogicOrchard::new); IFarmInstance gourdFarm = registry.registerLogic("farmGourd", FarmLogicGourd::new); IFarmInstance cocoaFarm = registry.registerLogic("farmCocoa", FarmLogicCocoa::new); + IFarmInstance enderFarm = registry.registerLogic("farmEnder", FarmLogicEnder::new); Circuits.farmArborealManaged = new CircuitFarmLogic("managedArboreal", arborealFarm, false); Circuits.farmArborealManual = new CircuitFarmLogic("manualArboreal", arborealFarm, true); @@ -225,16 +230,24 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmOrchardManaged = new CircuitFarmLogic("managedOrchard", orchardFarm, false); Circuits.farmOrchardManual = new CircuitFarmLogic("manualOrchard", orchardFarm, true); + Circuits.farmSucculentManaged = new CircuitFarmLogic("managedSucculent", succulentFarm, false); Circuits.farmSucculentManual = new CircuitFarmLogic("manualSucculent", succulentFarm, true); succulentFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); - Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", poalesFarm, true).setManual(); + Circuits.farmPoalesManaged = new CircuitFarmLogic("managedPoales", poalesFarm, false); + Circuits.farmPoalesManual = new CircuitFarmLogic("manualPoales", poalesFarm, true); poalesFarm.registerSoil(new ItemStack(Blocks.SAND), Blocks.SAND.getDefaultState(),true); poalesFarm.registerSoil(new ItemStack(Blocks.DIRT), Blocks.DIRT.getDefaultState(),false); - Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", gourdFarm, true).setManual(); + Circuits.farmGourdManaged = new CircuitFarmLogic("managedGourd", gourdFarm, false); + Circuits.farmGourdManual = new CircuitFarmLogic("manualGourd", gourdFarm, true); - Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", cocoaFarm, true).setManual(); + Circuits.farmCocoaManaged = new CircuitFarmLogic("managedCocoa", cocoaFarm, false); + Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", cocoaFarm, true); + + Circuits.farmEnderManaged = new CircuitFarmLogic("managedEnder", enderFarm, false); + Circuits.farmEnderManual = new CircuitFarmLogic("manualEnder", enderFarm, false); + enderFarm.registerSoil(new ItemStack(Blocks.END_STONE), Blocks.END_STONE.getDefaultState()); } @Override @@ -302,20 +315,28 @@ public class ModuleFarming extends BlankForestryModule { return; } - ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmArborealManaged); - ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPeatManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.GOLD, 1), Circuits.farmArborealManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmSucculentManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.OBSIDIAN, 1), Circuits.farmPeatManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCropsManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.BLAZE, 1), Circuits.farmInfernalManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPoalesManual); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.LAPIS, 1), Circuits.farmGourdManaged); ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.APATITE, 1), Circuits.farmShroomManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.DIAMOND, 1), Circuits.farmCocoaManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.EMERALD, 1), Circuits.farmOrchardManaged); + ChipsetManager.solderManager.addRecipe(layoutManaged, coreItems.tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManaged); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmOrchardManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPeatManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.GOLD, 1), Circuits.farmArborealManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.COPPER, 1), Circuits.farmSucculentManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.OBSIDIAN, 1), Circuits.farmPeatManual); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.BRONZE, 1), Circuits.farmCropsManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.GOLD, 1), Circuits.farmSucculentManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.DIAMOND, 1), Circuits.farmPoalesManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.OBSIDIAN, 1), Circuits.farmGourdManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.TIN, 1), Circuits.farmPoalesManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.LAPIS, 1), Circuits.farmGourdManual); ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.APATITE, 1), Circuits.farmShroomManual); - ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.LAPIS, 1), Circuits.farmCocoaManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.DIAMOND, 1), Circuits.farmCocoaManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.EMERALD, 1), Circuits.farmOrchardManual); + ChipsetManager.solderManager.addRecipe(layoutManual, coreItems.tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FakeFarmInstance.java b/src/main/java/forestry/farming/logic/FakeFarmInstance.java index 864b7de8c..11a7a6bf3 100644 --- a/src/main/java/forestry/farming/logic/FakeFarmInstance.java +++ b/src/main/java/forestry/farming/logic/FakeFarmInstance.java @@ -18,6 +18,10 @@ public class FakeFarmInstance implements IFarmInstance { this.logic = logic; } + @Override + public void registerFarmables(String identifier) { + } + @Override public void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData) { } diff --git a/src/main/java/forestry/farming/logic/FarmInstance.java b/src/main/java/forestry/farming/logic/FarmInstance.java index 716862d87..5edf0f916 100644 --- a/src/main/java/forestry/farming/logic/FarmInstance.java +++ b/src/main/java/forestry/farming/logic/FarmInstance.java @@ -1,9 +1,11 @@ package forestry.farming.logic; +import javax.annotation.Nullable; import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.function.BiFunction; +import java.util.stream.Collectors; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; @@ -13,23 +15,35 @@ import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmable; import forestry.api.farming.ISoil; +import forestry.farming.FarmRegistry; public final class FarmInstance implements IFarmInstance { private final Set soils = new HashSet<>(); - private final Collection farmables; + private final Set farmablesIdentifiers; private final IFarmLogic manualLogic; private final IFarmLogic managedLogic; private final String identifier; - public FarmInstance(String identifier, BiFunction logicFactory, Collection farmables) { + @Nullable + private Collection farmables; + + public FarmInstance(String identifier, BiFunction logicFactory, Set farmablesIdentifiers) { this.identifier = identifier; - this.farmables = farmables; + this.farmablesIdentifiers = farmablesIdentifiers; this.manualLogic = logicFactory.apply(this, true); this.managedLogic = logicFactory.apply(this, false); } + @Override + public void registerFarmables(String identifier) { + farmablesIdentifiers.add(identifier); + } + @Override public Collection getFarmables() { + if(farmables == null){ + farmables = farmablesIdentifiers.stream().map(FarmRegistry.getInstance()::getFarmables).flatMap(Collection::stream).collect(Collectors.toSet()); + } return farmables; } diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 54810fdbb..6b062f8c1 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -65,21 +65,29 @@ public abstract class FarmLogic implements IFarmLogic { Stack crops = new Stack<>(); for (int i = 0; i < extent; i++) { BlockPos position = translateWithOffset(pos.up(), direction, i); - if (world.isAirBlock(position)) { - continue; - } - IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : getFarmables()) { - ICrop crop = seed.getCropAt(world, position, blockState); - if (crop != null) { - crops.push(crop); - break; - } + ICrop crop = getCrop(world, position); + if(crop != null){ + crops.push(crop); } } return crops; } + @Nullable + protected ICrop getCrop(World world, BlockPos position){ + if (world.isAirBlock(position)) { + return null; + } + IBlockState blockState = world.getBlockState(position); + for (IFarmable seed : getFarmables()) { + ICrop crop = seed.getCropAt(world, position, blockState); + if (crop != null) { + return crop; + } + } + return null; + } + public abstract boolean isAcceptedWindfall(ItemStack stack); protected final boolean isWaterSourceBlock(World world, BlockPos position) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 116511d75..952528793 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -36,15 +36,18 @@ import forestry.api.farming.IFarmable; public class FarmLogicArboreal extends FarmLogicHomogeneous { + @Nullable private List farmables; public FarmLogicArboreal(IFarmInstance instance, boolean isManual) { super(instance, isManual); - this.farmables = new ArrayList<>(instance.getFarmables()); } @Override public List getFarmables() { + if(farmables == null){ + this.farmables = new ArrayList<>(instance.getFarmables()); + } return farmables; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java new file mode 100644 index 000000000..742bcf395 --- /dev/null +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -0,0 +1,154 @@ +package forestry.farming.logic; + +import com.google.common.collect.ImmutableSet; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.Stack; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import forestry.api.farming.FarmDirection; +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmHousing; +import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; +import forestry.farming.logic.crops.CropDestroy; +import forestry.farming.logic.farmables.FarmableChorus; + +public class FarmLogicEnder extends FarmLogicHomogeneous { + private static final Set VALID_DIRECTIONS = ImmutableSet.of(EnumFacing.UP, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST); + private final IFarmable chorusFarmable; + + public FarmLogicEnder(IFarmInstance instance, boolean isManual) { + super(instance, isManual); + chorusFarmable = FarmableChorus.INSTANCE; + } + + @Override + public String getName() { + return "Manual Ender Farm"; + } + + @Override + public ItemStack getIconItemStack() { + return new ItemStack(Items.ENDER_EYE); + } + + @Override + public int getFertilizerConsumption() { + return 20; + } + + @Override + public int getWaterConsumption(float hydrationModifier) { + return 0; + } + + @Override + public NonNullList collect(World world, IFarmHousing farmHousing) { + NonNullList products = produce; + produce = collectEntityItems(world, farmHousing, true); + return products; + } + + private final Map lastExtentsHarvest = new HashMap<>(); + + @Override + public Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent) { + if (!lastExtentsHarvest.containsKey(pos)) { + lastExtentsHarvest.put(pos, 0); + } + + int lastExtent = lastExtentsHarvest.get(pos); + if (lastExtent > extent) { + lastExtent = 0; + } + + BlockPos position = translateWithOffset(pos.up(), direction, lastExtent); + Collection crops = harvestBlocks(world, position); + lastExtent++; + lastExtentsHarvest.put(pos, lastExtent); + + return crops; + } + + private Collection harvestBlocks(World world, BlockPos position) { + if(world.isAirBlock(position)){ + return Collections.emptySet(); + } + + ICrop crop = getCrop(world, position); + if(crop != null){ + return Collections.singleton(crop); + } + + Stack crops = new Stack<>(); + Stack plants = new Stack<>(); + harvestBlock(world, position, EnumFacing.DOWN, plants, crops); + //Remove all flowers before remove all plants + if(!crops.isEmpty()) { + return crops; + } + return plants; + } + + private boolean harvestBlock(World world, BlockPos pos, EnumFacing from, Stack plants, Stack flowers){ + IBlockState blockState = world.getBlockState(pos); + if(blockState.getBlock() == Blocks.CHORUS_FLOWER){ + ICrop crop = chorusFarmable.getCropAt(world, pos, blockState); + if(crop != null){ + flowers.push(crop); + return false; + } + return false; + }else if(blockState.getBlock() == Blocks.CHORUS_PLANT){ + boolean canHarvest = true; + for(EnumFacing facing : VALID_DIRECTIONS) { + if(facing == from){ + continue; + } + canHarvest &= harvestBlock(world, pos.offset(facing), facing.getOpposite(), plants, flowers); + } + if(canHarvest){ + plants.push(new CropDestroy(world, Blocks.CHORUS_PLANT.getDefaultState(), pos, null)); + } + return canHarvest; + } + return true; + } + + @Override + protected boolean maintainGermlings(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { + for (int i = 0; i < extent; i++) { + BlockPos position = translateWithOffset(pos, direction, i); + IBlockState state = world.getBlockState(position); + if (!world.isAirBlock(position) && !BlockUtil.isReplaceableBlock(state, world, position)) { + continue; + } + + BlockPos soilPos = position.down(); + IBlockState blockState = world.getBlockState(soilPos); + if (!isAcceptedSoil(blockState)) { + continue; + } + + if(trySetCrop(world, farmHousing, position, direction)){ + return true; + } + } + + return false; + } +} diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index ad46f954a..22a133c46 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -137,7 +137,7 @@ public class FarmLogicOrchard extends FarmLogic { // Determine what type we want to harvest. IBlockState blockState = world.getBlockState(position); Block block = blockState.getBlock(); - if (!block.isWood(world, position) && !isBlockTraversable(blockState, traversalBlocks) && !isFruitBearer(world, position)) { + if (!block.isWood(world, position) && !isBlockTraversable(blockState, traversalBlocks) && !isFruitBearer(world, position, blockState)) { return crops; } @@ -184,11 +184,11 @@ public class FarmLogicOrchard extends FarmLogic { candidates.add(candidate); seen.add(candidate); } - if (isFruitBearer(world, candidate)) { + if (isFruitBearer(world, candidate, blockState)) { candidates.add(candidate); seen.add(candidate); - ICrop crop = getCrop(world, candidate); + ICrop crop = getCropAt(world, candidate); if (crop != null) { crops.push(crop); } @@ -200,14 +200,14 @@ public class FarmLogicOrchard extends FarmLogic { return candidates; } - private boolean isFruitBearer(World world, BlockPos position) { + private boolean isFruitBearer(World world, BlockPos position, IBlockState blockState) { IFruitBearer tile = TileUtil.getTile(world, position, IFruitBearer.class); if (tile != null) { return true; } for (IFarmable farmable : getFarmables()) { - if (farmable.isSaplingAt(world, position)) { + if (farmable.isSaplingAt(world, position, blockState)) { return true; } } @@ -226,7 +226,7 @@ public class FarmLogicOrchard extends FarmLogic { } @Nullable - private ICrop getCrop(World world, BlockPos position) { + private ICrop getCropAt(World world, BlockPos position) { IFruitBearer fruitBearer = TileUtil.getTile(world, position, IFruitBearer.class); if (fruitBearer != null) { @@ -234,13 +234,7 @@ public class FarmLogicOrchard extends FarmLogic { return new CropFruit(world, position); } } else { - IBlockState blockState = world.getBlockState(position); - for (IFarmable seed : getFarmables()) { - ICrop crop = seed.getCropAt(world, position, blockState); - if (crop != null) { - return crop; - } - } + return getCrop(world, position); } return null; } diff --git a/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java b/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java new file mode 100644 index 000000000..11d807393 --- /dev/null +++ b/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java @@ -0,0 +1,42 @@ +package forestry.farming.logic.crops; + +import net.minecraft.block.state.IBlockState; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.event.ForgeEventFactory; + +import forestry.core.network.packets.PacketFXSignal; +import forestry.core.utils.NetworkUtil; + +public class CropChorusFlower extends Crop { + private static final IBlockState BLOCK_STATE = Blocks.CHORUS_FLOWER.getDefaultState(); + + public CropChorusFlower(World world, BlockPos position) { + super(world, position); + } + + @Override + protected boolean isCrop(World world, BlockPos pos) { + return world.getBlockState(pos).getBlock() == Blocks.CHORUS_FLOWER; + } + + @Override + protected NonNullList harvestBlock(World world, BlockPos pos) { + NonNullList harvested = NonNullList.create(); + harvested.add(new ItemStack(Blocks.CHORUS_FLOWER)); + float chance = ForgeEventFactory.fireBlockHarvesting(harvested, world, pos, BLOCK_STATE, 0, 1.0F, false, null); + + harvested.removeIf(next -> world.rand.nextFloat() > chance); + + PacketFXSignal packet = new PacketFXSignal(PacketFXSignal.VisualFXType.BLOCK_BREAK, PacketFXSignal.SoundFXType.BLOCK_BREAK, pos, BLOCK_STATE); + NetworkUtil.sendNetworkPacket(packet, pos, world); + + world.setBlockToAir(pos); + + return harvested; + } +} diff --git a/src/main/java/forestry/farming/logic/crops/CropDestroy.java b/src/main/java/forestry/farming/logic/crops/CropDestroy.java index 458eb9da4..6ad61af75 100644 --- a/src/main/java/forestry/farming/logic/crops/CropDestroy.java +++ b/src/main/java/forestry/farming/logic/crops/CropDestroy.java @@ -70,6 +70,8 @@ public class CropDestroy extends Crop { } removedSeed = true; } + }else{ + dropIterator.remove(); } } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java index a9f0b9c72..ab1af6c98 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableAgingCrop.java @@ -45,8 +45,7 @@ public class FarmableAgingCrop implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - IBlockState blockState = world.getBlockState(pos); + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { return blockState.getBlock() == cropBlock && blockState.getValue(ageProperty) <= minHarvestAge; } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableBase.java b/src/main/java/forestry/farming/logic/farmables/FarmableBase.java index 5a83ffadd..857a34ac5 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableBase.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableBase.java @@ -25,8 +25,7 @@ public abstract class FarmableBase implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - IBlockState blockState = world.getBlockState(pos); + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { return blockState.getBlock() == plantedState.getBlock() && blockState != matureState; } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java b/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java new file mode 100644 index 000000000..5821d7838 --- /dev/null +++ b/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java @@ -0,0 +1,80 @@ +package forestry.farming.logic.farmables; + +import javax.annotation.Nullable; + +import net.minecraft.block.BlockChorusFlower; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import forestry.api.farming.ICrop; +import forestry.api.farming.IFarmable; +import forestry.core.utils.BlockUtil; +import forestry.farming.logic.crops.CropChorusFlower; + +public class FarmableChorus implements IFarmable { + public static final IFarmable INSTANCE = new FarmableChorus(); + + private final ItemStack germling; + private final ItemStack fruit; + + private FarmableChorus() { + this.germling = new ItemStack(Blocks.CHORUS_FLOWER); + this.fruit = new ItemStack(Items.CHORUS_FRUIT); + } + + @Override + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { + return blockState.getBlock() == Blocks.CHORUS_FLOWER; + } + + @Nullable + @Override + public ICrop getCropAt(World world, BlockPos pos, IBlockState blockState) { + if (blockState.getBlock() != Blocks.CHORUS_FLOWER) { + return null; + } + + if (blockState.getValue(BlockChorusFlower.AGE) < 5) { + return null; + } + + return new CropChorusFlower(world, pos); + } + + @Override + public boolean isGermling(ItemStack itemstack) { + return ItemStack.areItemsEqual(germling, itemstack); + } + + @Override + public boolean isWindfall(ItemStack itemstack) { + return ItemStack.areItemsEqual(fruit, itemstack); + } + + @Override + public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { + if(!canPlace(world, pos)){ + return false; + } + return BlockUtil.setBlockWithPlaceSound(world, pos, Blocks.CHORUS_FLOWER.getDefaultState()); + } + + private boolean canPlace(World world, BlockPos position) { + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + BlockPos offsetPosition = position.add(x, 0, z); + IBlockState state = world.getBlockState(offsetPosition); + if (state.getBlock() == Blocks.CHORUS_FLOWER || state.getBlock() == Blocks.CHORUS_PLANT) { + return false; + } + } + } + + return true; + } +} diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java b/src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java index 5e3b62a2e..392070eb5 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableDoubleCrop.java @@ -17,8 +17,7 @@ public class FarmableDoubleCrop extends FarmableBase { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - IBlockState blockState = world.getBlockState(pos); + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { return blockState.getBlock() == plantedState.getBlock() && blockState != topMatureState; } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableGE.java b/src/main/java/forestry/farming/logic/farmables/FarmableGE.java index 0ccbf303c..5005beb19 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableGE.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableGE.java @@ -28,14 +28,8 @@ import forestry.farming.logic.crops.CropDestroy; public class FarmableGE implements IFarmable { @Override - public boolean isSaplingAt(World world, BlockPos pos) { - - if (world.isAirBlock(pos)) { - return false; - } - - Block block = world.getBlockState(pos).getBlock(); - return ModuleArboriculture.getBlocks().saplingGE == block; + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { + return ModuleArboriculture.getBlocks().saplingGE == blockState.getBlock(); } @Override diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java b/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java index 6cd382579..c77d7a7c9 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableGourd.java @@ -35,8 +35,7 @@ public class FarmableGourd implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - IBlockState blockState = world.getBlockState(pos); + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { return blockState.getBlock() == stem; } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java b/src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java index 4fbde5151..35d6dff14 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableRusticGrape.java @@ -28,8 +28,7 @@ public class FarmableRusticGrape implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - IBlockState blockState = world.getBlockState(pos); + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { return blockState.getBlock() == cropBlock; } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java index 79e321e88..53e3ab2a1 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableRusticSapling.java @@ -37,8 +37,8 @@ public class FarmableRusticSapling implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - return world.getBlockState(pos).getBlock() == germlingBlock; + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { + return blockState.getBlock() == germlingBlock; } @Override diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java index 7d1b0111c..fed60f725 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableSapling.java @@ -60,8 +60,8 @@ public class FarmableSapling implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - return world.getBlockState(pos).getBlock() == this.saplingBlock; + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { + return blockState.getBlock() == this.saplingBlock; } @Override diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java b/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java index adc3f3e8d..6b0e6d8f6 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableStacked.java @@ -34,8 +34,7 @@ public class FarmableStacked implements IFarmable { } @Override - public boolean isSaplingAt(World world, BlockPos pos) { - IBlockState blockState = world.getBlockState(pos); + public boolean isSaplingAt(World world, BlockPos pos, IBlockState blockState) { return blockState.getBlock() == cropBlock; } diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java index 9f5ba2029..af98cd641 100644 --- a/src/main/java/forestry/plugins/PluginExtraUtilities.java +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -68,7 +68,7 @@ public class PluginExtraUtilities extends BlankForestryModule { } if (Config.isExUtilEnderLilyEnabled()) { - registerExPlant("Ender", "enderlilly", "Ender Lily", circuit -> Circuits.farmEnderManaged = circuit, Blocks.END_STONE); + registerExPlant("Ender", "enderlilly", "Ender Lily", circuit -> Circuits.farmEnderManaged = circuit); } } @@ -77,10 +77,6 @@ public class PluginExtraUtilities extends BlankForestryModule { if (!ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING))) { return; } - if(Circuits.farmEnderManaged != null) { - ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); - ChipsetManager.solderManager.addRecipe(layoutManaged, ModuleCore.getItems().tubes.get(EnumElectronTube.ENDER, 1), Circuits.farmEnderManaged); - } if(Circuits.farmOrchidManaged != null) { ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); ChipsetManager.solderManager.addRecipe(layoutManaged, ModuleCore.items.tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManaged); @@ -99,16 +95,20 @@ public class PluginExtraUtilities extends BlankForestryModule { if (growthProperty == null) { Log.error("Could not find the growth property of {}.", itemName); } else { + String identifier = "farm" + id; IFarmRegistry registry = FarmRegistry.getInstance(); int harvestAge = Collections.max(growthProperty.getAllowedValues()); int replantAge = plantBlock.getDefaultState().getValue(growthProperty); - registry.registerFarmables(itemName, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); + registry.registerFarmables(identifier, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); - IFarmInstance instance = registry.registerLogic("farm" + id, (i, m) -> new FarmLogicExU(i, m, (m ? "Manual " : "Managed ") + itemName + " Farm", plantItem), itemName); - for(Block soil : soils) { - instance.registerSoil(new ItemStack(soil), soil.getDefaultState()); + IFarmInstance instance = registry.getFarm(identifier); + if(instance == null) { + instance = registry.registerLogic(identifier, (i, m) -> new FarmLogicExU(i, m, (m ? "Manual " : "Managed ") + itemName + " Farm", plantItem), itemName); + for (Block soil : soils) { + instance.registerSoil(new ItemStack(soil), soil.getDefaultState()); + } + assignTo.accept(new CircuitFarmLogic("managed" + id, instance, false)); } - assignTo.accept(new CircuitFarmLogic("managed" + id, instance, false)); } } } diff --git a/src/main/resources/assets/forestry/blockstates/farm_ender.json b/src/main/resources/assets/forestry/blockstates/farm_ender.json new file mode 100644 index 000000000..17ac8dddc --- /dev/null +++ b/src/main/resources/assets/forestry/blockstates/farm_ender.json @@ -0,0 +1,8 @@ +{ + "variants": { + "facing=north": { "model": "forestry:farm_ender" }, + "facing=east": { "model": "forestry:farm_ender", "y": 90 }, + "facing=south": { "model": "forestry:farm_ender", "y": 180 }, + "facing=west": { "model": "forestry:farm_ender", "y": -90 } + } +} diff --git a/src/main/resources/assets/forestry/models/block/farm_ender.json b/src/main/resources/assets/forestry/models/block/farm_ender.json new file mode 100644 index 000000000..6b2fd1f90 --- /dev/null +++ b/src/main/resources/assets/forestry/models/block/farm_ender.json @@ -0,0 +1,57 @@ +{ + "parent": "block/block", + "textures": { + "particle": "forestry:blocks/farm_ender_particle", + "texture": "forestry:blocks/farm_ender" + }, + "elements": [ + { + "__comment": "base", + "from": [ 0, 0, 0 ], + "to": [ 16, 4, 16 ], + "faces": { + "down": { "uv": [ 4, 4, 8, 8 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 4, 4, 8 ], "texture": "#texture" }, + "north": { "uv": [ 8, 4, 12, 5 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 6, 12, 7 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 7, 12, 8 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 5, 12, 6 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "ceiling", + "from": [ 0, 12, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "uv": [ 4, 0, 8, 4 ], "texture": "#texture" }, + "up": { "uv": [ 0, 0, 4, 4 ], "texture": "#texture", "cullface": "up" }, + "north": { "uv": [ 8, 0, 12, 1 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 8, 2, 12, 3 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 8, 3, 12, 4 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 8, 1, 12, 2 ], "texture": "#texture", "cullface": "east" } + } + }, + { + "__comment": "terrarium", + "from": [ 2, 4, 2 ], + "to": [ 14, 12, 14 ], + "faces": { + "north": { "uv": [ 0, 13.5, 3, 15.5 ], "texture": "#texture" }, + "south": { "uv": [ 6, 13.5, 9, 15.5 ], "texture": "#texture" }, + "west": { "uv": [ 9, 13.5, 12, 15.5 ], "texture": "#texture" }, + "east": { "uv": [ 3, 13.5, 6, 15.5 ], "texture": "#texture" } + } + }, + { + "__comment": "showcase", + "from": [ 4, 4, 4 ], + "to": [ 12, 12, 12 ], + "faces": { + "north": { "uv": [ 6, 10, 8, 12 ], "texture": "#texture" }, + "south": { "uv": [ 10, 10, 12, 12 ], "texture": "#texture" }, + "west": { "uv": [ 12, 10, 14, 12 ], "texture": "#texture" }, + "east": { "uv": [ 8, 10, 10, 12 ], "texture": "#texture" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/forestry/models/item/farm_ender.json b/src/main/resources/assets/forestry/models/item/farm_ender.json new file mode 100644 index 000000000..fd3d60792 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/farm_ender.json @@ -0,0 +1,3 @@ +{ + "parent": "forestry:block/farm_ender" +} diff --git a/src/main/resources/assets/forestry/textures/blocks/farm_ender.png b/src/main/resources/assets/forestry/textures/blocks/farm_ender.png new file mode 100644 index 0000000000000000000000000000000000000000..f54084ada283a44e6339e3547021df451eb587e8 GIT binary patch literal 1780 zcmVn=b27yUL zK~#9!?O07u8&?!PZ$69%jLpQ@1P~tqD@{XXsH%!|(?zrCI@@;B?z-w9=)V7;KcMQS zn{?A4Pn2jcgC<254l)k+u zNv>-_N#f1MHh7mrJ0<{N?8+?5tgNQd(d%cj?fk7jFTwT&fSF*mo2I<0|%;OifMbNQ2mZ2gKNNJ6%fyAa??2 z%YbRL0RWSqe{x|Z9NyW0X|%1f?k?Igu(G!1dT=Ut3A*+gi-lEC+Q9baCQD4Ue8l`a zjV6p^Jv0XlBmpELLsrwQ66|Ey!JF+4vjKptrXf#^1N*P6>xprct1qGLme_+AR|}Y# zT0pf^#{Sk57Q9^%PXA$YfMAnSN3XLCpUILk;<9!0I*h8$>_%0`MEVj7Qk_vz)sApN zb%=yuakapLClW>TO~d8ij|2Mc`N%kcIKFzn)oz?ZkVID*5=Z$FS;Cv+*H~Fw10fa% zP};!Wvqz{^8c?TIQLrh549>1KyTyYuA zn$CD(Y&M5hO~*$ce+J#uT>eAn01$HK>)QL?1$JVH;{ZkosA(lUw@p^s@1t-p z2aJv-AtXc`n>A!|SBBB72ka4nm5KPP@ zWDrqcd-MBW{tE3sOf5i$Er$U>98HGefKI&${qY_d2nP&n4V?r2p9geHk5|w0&J%_{ z4+yL0dFKhSnFoZ`^StwfSeyfR^*rx9Vdz?bSI_g#6JntS!s>b6c|vToKv+G`J5Pv> z7U0qIyz_)u%mcXeJnuXq4jd3x&-2a`V#5Jp^*rx9AvPSqqvv_&39*<5@aTEodBXqm zfML!9cpt#K#+I&AWn>ZnFtwBi0F-vh0D#)jp(VGo=h*eb0ky#)E<3mzx7IP4Bbdw) z+_<&QY+m;FJ^}WZ{o$)`QOHlDaa6|KyurS(a1)KcEl&fNu4g?TEBBz%*OFp>Zf1>dA~y#3f0$CUJETz0ORV0G&sUoV*{UZu2S z`o^bM3e+?3oiebLho-f$P+YZynbt<7A~3S^wDW8MuP>P@%(Ec;e03+@?<(z-vA-un z$>yPC^Vr{$UBP+T2g(7N;#KMl#;Z*R#rH0|)!n^)4~H7Xp+<4{_C03vvJXrP*ugl< z+fVRb__3wy^xQr^fB?Lnf3owC_^N>3VEpibA3SfLkNTXz5^zy4&N2^!=k4=Ro)aWL zq!y$ydhxw|900!j=2NJu33OjFO8cw(0Z6cy!M#W=2%fjkM|Dn+E_!*d;QinS(&r;Q zCrEx7-+3bRi?^{>AHM=6Yn5#OJ|CU^!gus@T60ZyPh0G7FCA~5wm{7kyxL%tcCR)_ zQiXZSGm!8~gn8ORKdsTv|2%Az1ChQh?xKAkq+-%51sde}nc`I% zd}JIDHG2=cI|%<}0zAV3LCP?0_|ORmqVL1JOqlsW7<||jNDe#2O;mC?$h!wfNa_((ed0000sIUl literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/forestry/textures/blocks/farm_ender_particle.png b/src/main/resources/assets/forestry/textures/blocks/farm_ender_particle.png new file mode 100644 index 0000000000000000000000000000000000000000..f99ed652d6944c3b27c3180b0951f0d4be4f1b78 GIT binary patch literal 417 zcmV;S0bc%zP)Cc~DZ5)tjBM4f9lyqsF5>f!79GR>9>q zT}BF`u6;0@k4Elxw-5+w>2d5+&{xwjF+^iKL~%{SM1<(D*Ii>YYJ}+bAigqH Date: Sat, 20 Jan 2018 21:00:21 +0100 Subject: [PATCH 05/12] Improve fertilizer config and Clean Up --- .../java/forestry/api/farming/IFarmLogic.java | 8 +- ...FarmInstance.java => IFarmProperties.java} | 2 +- .../forestry/api/farming/IFarmRegistry.java | 16 +-- .../gui/widgets/GhostItemStackWidget.java | 2 +- .../forestry/farming/DummyFarmRegistry.java | 16 +-- .../java/forestry/farming/FarmRegistry.java | 128 ++++++++++++------ .../java/forestry/farming/ModuleFarming.java | 24 ++-- .../farming/circuits/CircuitFarmLogic.java | 4 +- ...mInstance.java => FakeFarmProperties.java} | 6 +- .../forestry/farming/logic/FarmLogic.java | 16 +-- .../farming/logic/FarmLogicArboreal.java | 10 +- .../farming/logic/FarmLogicCocoa.java | 6 +- .../farming/logic/FarmLogicCrops.java | 6 +- .../farming/logic/FarmLogicEnder.java | 28 ++-- .../farming/logic/FarmLogicGourd.java | 6 +- .../farming/logic/FarmLogicHomogeneous.java | 11 +- .../farming/logic/FarmLogicInfernal.java | 6 +- .../farming/logic/FarmLogicMushroom.java | 6 +- .../farming/logic/FarmLogicOrchard.java | 6 +- .../forestry/farming/logic/FarmLogicPeat.java | 6 +- ...mLogicExU.java => FarmLogicRedOrchid.java} | 23 ++-- .../farming/logic/FarmLogicReeds.java | 6 +- .../farming/logic/FarmLogicRubber.java | 6 +- .../farming/logic/FarmLogicSimple.java | 4 +- .../forestry/farming/logic/FarmLogicSoil.java | 10 +- .../farming/logic/FarmLogicSucculent.java | 6 +- .../farming/logic/FarmLogicWatered.java | 8 +- ...{FarmInstance.java => FarmProperties.java} | 8 +- .../farming/logic/crops/CropChorusFlower.java | 2 +- .../farming/logic/crops/CropDestroy.java | 2 +- .../logic/farmables/FarmableChorus.java | 2 +- .../plugins/PluginExtraUtilities.java | 101 ++++++-------- src/main/java/forestry/plugins/PluginIC2.java | 4 +- .../java/forestry/plugins/PluginNatura.java | 4 +- 34 files changed, 263 insertions(+), 236 deletions(-) rename src/main/java/forestry/api/farming/{IFarmInstance.java => IFarmProperties.java} (95%) rename src/main/java/forestry/farming/logic/{FakeFarmInstance.java => FakeFarmProperties.java} (87%) rename src/main/java/forestry/farming/logic/{FarmLogicExU.java => FarmLogicRedOrchid.java} (82%) rename src/main/java/forestry/farming/logic/{FarmInstance.java => FarmProperties.java} (89%) diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index 640e53661..1e3912fe1 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -45,7 +45,7 @@ public interface IFarmLogic { Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent); /** - * @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmInstance} and + * @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmProperties} and * have a immutable manual state. TODO Remove this method in 1.13 */ @Deprecated @@ -56,16 +56,16 @@ public interface IFarmLogic { /** * @since Forestry 5.8 * - * @return Returns the {@link IFarmInstance} that created this logic. Returns a fake instance from + * @return Returns the {@link IFarmProperties} that created this logic. Returns a fake instance from * {@link IFarmRegistry#createFakeInstance(IFarmLogic)} if the logic is older that Forestry 5.8. */ - default IFarmInstance getInstance(){ + default IFarmProperties getInstance(){ return ForestryAPI.farmRegistry.createFakeInstance(this); } /** * Use {@link IFarmRegistry#getFarm(String)} to get the soil container for the farm logic and register the soil - * with {@link IFarmInstance#registerSoil(ItemStack, IBlockState, boolean)}. + * with {@link IFarmProperties#registerSoil(ItemStack, IBlockState, boolean)}. */ @Deprecated default void addSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData){ diff --git a/src/main/java/forestry/api/farming/IFarmInstance.java b/src/main/java/forestry/api/farming/IFarmProperties.java similarity index 95% rename from src/main/java/forestry/api/farming/IFarmInstance.java rename to src/main/java/forestry/api/farming/IFarmProperties.java index 8cd89c5e9..729544653 100644 --- a/src/main/java/forestry/api/farming/IFarmInstance.java +++ b/src/main/java/forestry/api/farming/IFarmProperties.java @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack; /** * @since Forestry 5.8 */ -public interface IFarmInstance { +public interface IFarmProperties { default void registerSoil(ItemStack resource, IBlockState soilState){ registerSoil(resource, soilState, false); diff --git a/src/main/java/forestry/api/farming/IFarmRegistry.java b/src/main/java/forestry/api/farming/IFarmRegistry.java index 760c6ce08..4f143e7a0 100644 --- a/src/main/java/forestry/api/farming/IFarmRegistry.java +++ b/src/main/java/forestry/api/farming/IFarmRegistry.java @@ -19,7 +19,7 @@ public interface IFarmRegistry { * @param logic corresponding instance of logic * * @deprecated Since Forestry 5.8. Use {@link #registerLogic(String, BiFunction, String...)} or - * {@link #registerLogic(IFarmInstance)}. + * {@link #registerLogic(IFarmProperties)}. */ @Deprecated void registerLogic(String identifier, IFarmLogic logic); @@ -28,7 +28,7 @@ public interface IFarmRegistry { * Registers farming logic in registry * @since Forestry 5.8 */ - IFarmInstance registerLogic(IFarmInstance farmInstance); + IFarmProperties registerLogic(IFarmProperties farmInstance); /** * Registers farming logic in registry under given identifier @@ -38,7 +38,7 @@ public interface IFarmRegistry { * @param farmablesIdentifiers Identifiers: farmArboreal farmCrops farmGourd farmInfernal farmPoales farmSucculentes farmShroom * @since Forestry 5.8 */ - IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers); + IFarmProperties registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers); /** * Can be used to add IFarmables to some of the vanilla farm logics. @@ -54,7 +54,7 @@ public interface IFarmRegistry { * * @return Null if the farming plugin is not active. * - * @deprecated Since Forestry 5.8. Use {@link #createCropLogic(IFarmInstance, boolean, ISimpleFarmLogic)} instead. + * @deprecated Since Forestry 5.8. Use {@link #createCropLogic(IFarmProperties, boolean, ISimpleFarmLogic)} instead. */ @Nullable @Deprecated @@ -74,13 +74,13 @@ public interface IFarmRegistry { int getFertilizeValue(ItemStack itemStack); /** - * Returns a fake {@link IFarmInstance} that returns the given logic at {@link IFarmInstance#getLogic(boolean)}. + * Returns a fake {@link IFarmProperties} that returns the given logic at {@link IFarmProperties#getLogic(boolean)}. * * @since Forestry 5.8 * @deprecated Only for backwards comparability. */ @Deprecated - IFarmInstance createFakeInstance(IFarmLogic logic); + IFarmProperties createFakeInstance(IFarmLogic logic); /** * Can be used to create a simple version of a farm logic, like the vanilla vegetable or wheat farm logic. @@ -88,7 +88,7 @@ public interface IFarmRegistry { * @return Null if the farming plugin is not active. */ @Nullable - IFarmLogic createCropLogic(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic); + IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic); /** * @@ -98,6 +98,6 @@ public interface IFarmRegistry { * @since Forestry 5.8 */ @Nullable - IFarmInstance getFarm(String identifier); + IFarmProperties getFarm(String identifier); } diff --git a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java index 0a4ef4641..9902a00bc 100644 --- a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java +++ b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java @@ -40,7 +40,7 @@ public class GhostItemStackWidget extends ItemStackWidget { fontRenderer.drawStringWithShadow(getDirectionString(), xPos + startX + 5, yPos + startY + 4, ColourProperties.INSTANCE.get("gui.screen")); } - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.85F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); textureManager.bindTexture(manager.gui.textureFile); diff --git a/src/main/java/forestry/farming/DummyFarmRegistry.java b/src/main/java/forestry/farming/DummyFarmRegistry.java index 0a036f5a1..7a53acdbf 100644 --- a/src/main/java/forestry/farming/DummyFarmRegistry.java +++ b/src/main/java/forestry/farming/DummyFarmRegistry.java @@ -7,12 +7,12 @@ import java.util.function.BiFunction; import net.minecraft.item.ItemStack; -import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.IFarmable; import forestry.api.farming.ISimpleFarmLogic; -import forestry.farming.logic.FakeFarmInstance; +import forestry.farming.logic.FakeFarmProperties; public class DummyFarmRegistry implements IFarmRegistry { @@ -33,27 +33,27 @@ public class DummyFarmRegistry implements IFarmRegistry { } @Override - public IFarmInstance registerLogic(IFarmInstance farmInstance) { + public IFarmProperties registerLogic(IFarmProperties farmInstance) { //Dummy-Implementation return null; } @Override - public IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { + public IFarmProperties registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { //Dummy-Implementation return null; } @Nullable @Override - public IFarmLogic createCropLogic(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { + public IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { //Dummy-Implementation return null; } @Override - public IFarmInstance createFakeInstance(IFarmLogic logic) { - return new FakeFarmInstance(logic); + public IFarmProperties createFakeInstance(IFarmLogic logic) { + return new FakeFarmProperties(logic); } @Override @@ -69,7 +69,7 @@ public class DummyFarmRegistry implements IFarmRegistry { @Nullable @Override - public IFarmInstance getFarm(String identifier) { + public IFarmProperties getFarm(String identifier) { //Dummy-Implementation return null; } diff --git a/src/main/java/forestry/farming/FarmRegistry.java b/src/main/java/forestry/farming/FarmRegistry.java index 2de995b58..6b08a7d30 100644 --- a/src/main/java/forestry/farming/FarmRegistry.java +++ b/src/main/java/forestry/farming/FarmRegistry.java @@ -1,6 +1,7 @@ package forestry.farming; import com.google.common.collect.HashMultimap; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Multimap; import javax.annotation.Nullable; @@ -22,8 +23,8 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.config.Property; import net.minecraftforge.oredict.OreDictionary; -import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.farming.IFarmable; import forestry.api.farming.ISimpleFarmLogic; @@ -31,16 +32,18 @@ import forestry.core.config.LocalizedConfiguration; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.core.utils.Translator; -import forestry.farming.logic.FakeFarmInstance; -import forestry.farming.logic.FarmInstance; +import forestry.farming.logic.FakeFarmProperties; import forestry.farming.logic.FarmLogicSimple; +import forestry.farming.logic.FarmProperties; public final class FarmRegistry implements IFarmRegistry { private static final FarmRegistry INSTANCE = new FarmRegistry(); + private final Multimap farmables = HashMultimap.create(); private final Map fertilizers = new LinkedHashMap<>(); - private final Map farmInstances = new HashMap<>(); + private final Map farmInstances = new HashMap<>(); + private FertilizerConfig fertilizer = FertilizerConfig.DUMMY; public static FarmRegistry getInstance() { return INSTANCE; @@ -62,13 +65,13 @@ public final class FarmRegistry implements IFarmRegistry { } @Override - public IFarmLogic createCropLogic(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { + public IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic) { return new FarmLogicSimple(instance, isManual, simpleFarmLogic); } @Override - public IFarmInstance createFakeInstance(IFarmLogic logic) { - return new FakeFarmInstance(logic); + public IFarmProperties createFakeInstance(IFarmLogic logic) { + return new FakeFarmProperties(logic); } @Override @@ -81,72 +84,113 @@ public final class FarmRegistry implements IFarmRegistry { @Override public int getFertilizeValue(ItemStack itemStack) { - for (Entry fertilizer : fertilizers.entrySet()) { - ItemStack fertilizerStack = fertilizer.getKey(); - if (ItemStackUtil.isIdenticalItem(fertilizerStack, itemStack)) { - return fertilizer.getValue(); - } - } - return 0; + return fertilizer.getFertilizeValue(itemStack); } @Override - public IFarmInstance registerLogic(IFarmInstance farmInstance) { + public IFarmProperties registerLogic(IFarmProperties farmInstance) { farmInstances.put(farmInstance.getIdentifier(), farmInstance); return farmInstance; } @Override - public IFarmInstance registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { + public IFarmProperties registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { Set fIdentifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers)); fIdentifiers.add(identifier); - IFarmInstance instance = new FarmInstance(identifier, logicFactory, fIdentifiers); + IFarmProperties instance = new FarmProperties(identifier, logicFactory, fIdentifiers); farmInstances.put(identifier, instance); return instance; } @Override @Nullable - public IFarmInstance getFarm(String identifier) { + public IFarmProperties getFarm(String identifier) { return farmInstances.get(identifier); } void loadConfig(LocalizedConfiguration config) { - List defaultFertilizers = new ArrayList<>(getItemStrings()); + Map defaultEntries = getItemStrings(); + List defaultFertilizers = new ArrayList<>(defaultEntries.values()); Collections.sort(defaultFertilizers); String[] defaultSortedFertilizers = defaultFertilizers.toArray(new String[defaultFertilizers.size()]); - Property fertilizerConf = config.get("fertilizers", "items", defaultSortedFertilizers, Translator.translateToLocal("for.config.farm.fertilizers.items")); + Property property = config.get("fertilizers", "items", defaultSortedFertilizers, Translator.translateToLocal("for.config.farm.fertilizers.items")); - fertilizers.clear(); - String[] fertilizerList = fertilizerConf.getStringList(); - for (int i = 0; i < fertilizerList.length; i++) { - try { - String fertilizer = fertilizerList[i]; - String[] fertilizers = fertilizer.split(";"); - String itemName = fertilizers[0]; - if(itemName.equals("forestry:fertilizerCompound")){ - itemName = "forestry:fertilizer_compound"; - } - ItemStack fertilizerItem = ItemStackUtil.parseItemStackString(itemName, OreDictionary.WILDCARD_VALUE); - if(fertilizerItem == null){ - continue; - } - int fertilizerValue = Integer.parseInt(fertilizers[1]); - registerFertilizer(fertilizerItem, fertilizerValue); - } catch (Exception e) { - Log.error("Forestry failed to parse a fertilizer entry at the farm config, at the position " + i + ".", e); + ImmutableMap fertilizerMap = checkConfig(property, defaultEntries); + fertilizer = new FertilizerConfig(fertilizerMap); + } + + private ImmutableMap checkConfig(Property property, Map defaultEntries){ + String[] fertilizerList = property.getStringList(); + ImmutableMap.Builder fertilizerMap = new ImmutableMap.Builder<>(); + Map configEntries = parseConfig(fertilizerList, fertilizerMap); + + List newEntries = new ArrayList<>(Arrays.asList(fertilizerList)); + for(Entry defaultEntry : defaultEntries.entrySet()){ + if(!configEntries.containsKey(defaultEntry.getKey())){ + newEntries.add(defaultEntry.getValue()); } } + + if(newEntries.size() > fertilizerList.length){ + Collections.sort(newEntries); + property.set(newEntries.toArray(new String[newEntries.size()])); + return checkConfig(property, defaultEntries); + } + + return fertilizerMap.build(); + } + + private Map parseConfig(String[] fertilizerList, ImmutableMap.Builder fertilizerMap){ + Map configEntries = new HashMap<>(); + for(String entry : fertilizerList){ + String[] spited = entry.split(";"); + if(spited.length < 2){ + Log.error("Foretsry failed to parse a entry of the fertilizer config."); + continue; + } + String itemName = spited[0]; + ItemStack fertilizerItem = ItemStackUtil.parseItemStackString(itemName, OreDictionary.WILDCARD_VALUE); + if(fertilizerItem == null || fertilizerItem.isEmpty()){ + Log.error("Foretsry failed to parse a entry of the fertilizer config, because the item doesn't exists."); + continue; + } + String value = spited[1]; + int fertilizerValue = Integer.parseInt(value); + if(fertilizerValue > 0) { + fertilizerMap.put(fertilizerItem, fertilizerValue); + } + configEntries.put(itemName, value); + } + return configEntries; } - private Set getItemStrings() { - Set itemStrings = new HashSet<>(fertilizers.size()); + private Map getItemStrings() { + Map itemStrings = new HashMap<>(fertilizers.size()); for (Entry itemStack : fertilizers.entrySet()) { String itemString = ItemStackUtil.getStringForItemStack(itemStack.getKey()); - itemString += ";" + itemStack.getValue(); - itemStrings.add(itemString); + itemStrings.put(itemString, itemString + ";" + itemStack.getValue()); } return itemStrings; } + + private static class FertilizerConfig{ + private static final FertilizerConfig DUMMY = new FertilizerConfig(Collections.emptyMap()); + + private final Map fertilizers; + + private FertilizerConfig(Map fertilizers) { + this.fertilizers = fertilizers; + } + + private int getFertilizeValue(ItemStack itemStack) { + for (Entry fertilizer : fertilizers.entrySet()) { + ItemStack fertilizerStack = fertilizer.getKey(); + if (ItemStackUtil.isIdenticalItem(fertilizerStack, itemStack)) { + return fertilizer.getValue(); + } + } + return 0; + } + } } diff --git a/src/main/java/forestry/farming/ModuleFarming.java b/src/main/java/forestry/farming/ModuleFarming.java index fe153ff05..66e661017 100644 --- a/src/main/java/forestry/farming/ModuleFarming.java +++ b/src/main/java/forestry/farming/ModuleFarming.java @@ -43,7 +43,7 @@ import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitLayout; import forestry.api.core.ForestryAPI; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.modules.ForestryModule; import forestry.core.ModuleCore; @@ -192,17 +192,17 @@ public class ModuleFarming extends BlankForestryModule { IFarmRegistry registry = FarmRegistry.getInstance(); BlockRegistryCore coreBlocks = ModuleCore.getBlocks(); - IFarmInstance arborealFarm = registry.registerLogic("farmArboreal", FarmLogicArboreal::new); - IFarmInstance cropsFarm = registry.registerLogic("farmCrops", FarmLogicCrops::new); - IFarmInstance mushroomFarm = registry.registerLogic("farmShroom", FarmLogicMushroom::new); - IFarmInstance succulentFarm = registry.registerLogic("farmSucculent", FarmLogicSucculent::new); - IFarmInstance peatFarm = registry.registerLogic("farmPeat", FarmLogicPeat::new); - IFarmInstance infernalFarm = registry.registerLogic("farmInfernal", FarmLogicInfernal::new); - IFarmInstance poalesFarm = registry.registerLogic("farmPoales", FarmLogicReeds::new); - IFarmInstance orchardFarm = registry.registerLogic("farmOrchard", FarmLogicOrchard::new); - IFarmInstance gourdFarm = registry.registerLogic("farmGourd", FarmLogicGourd::new); - IFarmInstance cocoaFarm = registry.registerLogic("farmCocoa", FarmLogicCocoa::new); - IFarmInstance enderFarm = registry.registerLogic("farmEnder", FarmLogicEnder::new); + IFarmProperties arborealFarm = registry.registerLogic("farmArboreal", FarmLogicArboreal::new); + IFarmProperties cropsFarm = registry.registerLogic("farmCrops", FarmLogicCrops::new); + IFarmProperties mushroomFarm = registry.registerLogic("farmShroom", FarmLogicMushroom::new); + IFarmProperties succulentFarm = registry.registerLogic("farmSucculent", FarmLogicSucculent::new); + IFarmProperties peatFarm = registry.registerLogic("farmPeat", FarmLogicPeat::new); + IFarmProperties infernalFarm = registry.registerLogic("farmInfernal", FarmLogicInfernal::new); + IFarmProperties poalesFarm = registry.registerLogic("farmPoales", FarmLogicReeds::new); + IFarmProperties orchardFarm = registry.registerLogic("farmOrchard", FarmLogicOrchard::new); + IFarmProperties gourdFarm = registry.registerLogic("farmGourd", FarmLogicGourd::new); + IFarmProperties cocoaFarm = registry.registerLogic("farmCocoa", FarmLogicCocoa::new); + IFarmProperties enderFarm = registry.registerLogic("farmEnder", FarmLogicEnder::new); Circuits.farmArborealManaged = new CircuitFarmLogic("managedArboreal", arborealFarm, false); Circuits.farmArborealManual = new CircuitFarmLogic("manualArboreal", arborealFarm, true); diff --git a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java index ce97c19d6..b27f090c1 100755 --- a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java +++ b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java @@ -14,8 +14,8 @@ import javax.annotation.Nullable; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; import forestry.core.circuits.Circuit; public class CircuitFarmLogic extends Circuit { @@ -23,7 +23,7 @@ public class CircuitFarmLogic extends Circuit { private final IFarmLogic logic; private boolean isManual = false; - public CircuitFarmLogic(String uid, IFarmInstance instance, boolean manual) { + public CircuitFarmLogic(String uid, IFarmProperties instance, boolean manual) { super(uid); this.logic = instance.getLogic(manual); } diff --git a/src/main/java/forestry/farming/logic/FakeFarmInstance.java b/src/main/java/forestry/farming/logic/FakeFarmProperties.java similarity index 87% rename from src/main/java/forestry/farming/logic/FakeFarmInstance.java rename to src/main/java/forestry/farming/logic/FakeFarmProperties.java index 11a7a6bf3..056982fbd 100644 --- a/src/main/java/forestry/farming/logic/FakeFarmInstance.java +++ b/src/main/java/forestry/farming/logic/FakeFarmProperties.java @@ -6,15 +6,15 @@ import java.util.Collections; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; -import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.api.farming.ISoil; -public class FakeFarmInstance implements IFarmInstance { +public class FakeFarmProperties implements IFarmProperties { private final IFarmLogic logic; - public FakeFarmInstance(IFarmLogic logic) { + public FakeFarmProperties(IFarmLogic logic) { this.logic = logic; } diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 6b062f8c1..62a4b4581 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -31,28 +31,28 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.api.farming.ISoil; import forestry.core.utils.VectUtil; public abstract class FarmLogic implements IFarmLogic { private final EntitySelectorFarm entitySelectorFarm = new EntitySelectorFarm(this); - protected final IFarmInstance instance; + protected final IFarmProperties properties; protected final boolean isManual; - public FarmLogic(IFarmInstance instance, boolean isManual) { - this.instance = instance; + public FarmLogic(IFarmProperties properties, boolean isManual) { + this.properties = properties; this.isManual = isManual; } protected Collection getFarmables() { - return instance.getFarmables(); + return properties.getFarmables(); } protected Collection getSoils() { - return instance.getSoils(); + return properties.getSoils(); } @Override @@ -66,7 +66,7 @@ public abstract class FarmLogic implements IFarmLogic { for (int i = 0; i < extent; i++) { BlockPos position = translateWithOffset(pos.up(), direction, i); ICrop crop = getCrop(world, position); - if(crop != null){ + if (crop != null) { crops.push(crop); } } @@ -74,7 +74,7 @@ public abstract class FarmLogic implements IFarmLogic { } @Nullable - protected ICrop getCrop(World world, BlockPos position){ + protected ICrop getCrop(World world, BlockPos position) { if (world.isAirBlock(position)) { return null; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 952528793..0e363786c 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -31,7 +31,7 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; public class FarmLogicArboreal extends FarmLogicHomogeneous { @@ -39,14 +39,14 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { @Nullable private List farmables; - public FarmLogicArboreal(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicArboreal(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override public List getFarmables() { - if(farmables == null){ - this.farmables = new ArrayList<>(instance.getFarmables()); + if (farmables == null) { + this.farmables = new ArrayList<>(properties.getFarmables()); } return farmables; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index 5f548c8c5..ccb549774 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -34,15 +34,15 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.farming.logic.farmables.FarmableCocoa; public class FarmLogicCocoa extends FarmLogic { private final IFarmable cocoa = new FarmableCocoa(); - public FarmLogicCocoa(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicCocoa(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index a76cf61fa..9160a142e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -19,14 +19,14 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; public class FarmLogicCrops extends FarmLogicWatered { - public FarmLogicCrops(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicCrops(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java index 742bcf395..e590c7c15 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicEnder.java +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -21,7 +21,7 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; import forestry.farming.logic.crops.CropDestroy; @@ -31,8 +31,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { private static final Set VALID_DIRECTIONS = ImmutableSet.of(EnumFacing.UP, EnumFacing.NORTH, EnumFacing.SOUTH, EnumFacing.WEST, EnumFacing.EAST); private final IFarmable chorusFarmable; - public FarmLogicEnder(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicEnder(IFarmProperties properties, boolean isManual) { + super(properties, isManual); chorusFarmable = FarmableChorus.INSTANCE; } @@ -85,12 +85,12 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { } private Collection harvestBlocks(World world, BlockPos position) { - if(world.isAirBlock(position)){ + if (world.isAirBlock(position)) { return Collections.emptySet(); } ICrop crop = getCrop(world, position); - if(crop != null){ + if (crop != null) { return Collections.singleton(crop); } @@ -98,30 +98,30 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { Stack plants = new Stack<>(); harvestBlock(world, position, EnumFacing.DOWN, plants, crops); //Remove all flowers before remove all plants - if(!crops.isEmpty()) { + if (!crops.isEmpty()) { return crops; } return plants; } - private boolean harvestBlock(World world, BlockPos pos, EnumFacing from, Stack plants, Stack flowers){ + private boolean harvestBlock(World world, BlockPos pos, EnumFacing from, Stack plants, Stack flowers) { IBlockState blockState = world.getBlockState(pos); - if(blockState.getBlock() == Blocks.CHORUS_FLOWER){ + if (blockState.getBlock() == Blocks.CHORUS_FLOWER) { ICrop crop = chorusFarmable.getCropAt(world, pos, blockState); - if(crop != null){ + if (crop != null) { flowers.push(crop); return false; } return false; - }else if(blockState.getBlock() == Blocks.CHORUS_PLANT){ + } else if (blockState.getBlock() == Blocks.CHORUS_PLANT) { boolean canHarvest = true; - for(EnumFacing facing : VALID_DIRECTIONS) { - if(facing == from){ + for (EnumFacing facing : VALID_DIRECTIONS) { + if (facing == from) { continue; } canHarvest &= harvestBlock(world, pos.offset(facing), facing.getOpposite(), plants, flowers); } - if(canHarvest){ + if (canHarvest) { plants.push(new CropDestroy(world, Blocks.CHORUS_PLANT.getDefaultState(), pos, null)); } return canHarvest; @@ -144,7 +144,7 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { continue; } - if(trySetCrop(world, farmHousing, position, direction)){ + if (trySetCrop(world, farmHousing, position, direction)) { return true; } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index d651aeb43..3f5638630 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -18,12 +18,12 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; public class FarmLogicGourd extends FarmLogic { - public FarmLogicGourd(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicGourd(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java index d511fede6..9cf2a8040 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java +++ b/src/main/java/forestry/farming/logic/FarmLogicHomogeneous.java @@ -18,7 +18,7 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.api.farming.ISoil; import forestry.core.utils.BlockUtil; @@ -26,8 +26,8 @@ import forestry.core.utils.BlockUtil; public abstract class FarmLogicHomogeneous extends FarmLogicSoil { protected NonNullList produce = NonNullList.create(); - public FarmLogicHomogeneous(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicHomogeneous(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override @@ -62,14 +62,11 @@ public abstract class FarmLogicHomogeneous extends FarmLogicSoil { @Override public boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - if(isManual){ - - } return maintainSoil(world, farmHousing, pos, direction, extent) || maintainGermlings(world, farmHousing, pos.up(), direction, extent); } private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - if(!farmHousing.canPlantSoil(isManual)){ + if (!farmHousing.canPlantSoil(isManual)) { return false; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 97611715e..6228fd024 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -23,14 +23,14 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.core.utils.BlockUtil; public class FarmLogicInfernal extends FarmLogicHomogeneous { - public FarmLogicInfernal(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicInfernal(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java index 537df6970..6945b21ec 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java +++ b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java @@ -16,12 +16,12 @@ import net.minecraft.util.NonNullList; import net.minecraft.world.World; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; public class FarmLogicMushroom extends FarmLogicArboreal { - public FarmLogicMushroom(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicMushroom(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 22a133c46..6303fbbd6 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -31,7 +31,7 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.api.genetics.IFruitBearer; import forestry.core.ModuleCore; @@ -43,8 +43,8 @@ public class FarmLogicOrchard extends FarmLogic { private final HashMap lastExtents = new HashMap<>(); private final ImmutableList traversalBlocks; - public FarmLogicOrchard(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicOrchard(IFarmProperties properties, boolean isManual) { + super(properties, isManual); ImmutableList.Builder traversalBlocksBuilder = ImmutableList.builder(); // if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.AGRICRAFT) || ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.INDUSTRIALCRAFT)) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index bfff9ab0f..19565518f 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -21,14 +21,14 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.core.ModuleCore; import forestry.core.blocks.BlockBogEarth; import forestry.farming.logic.crops.CropPeat; public class FarmLogicPeat extends FarmLogicWatered { - public FarmLogicPeat(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicPeat(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicExU.java b/src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java similarity index 82% rename from src/main/java/forestry/farming/logic/FarmLogicExU.java rename to src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java index 636b911aa..3d83cb94b 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicExU.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java @@ -11,7 +11,6 @@ package forestry.farming.logic; import net.minecraft.block.state.IBlockState; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; @@ -19,28 +18,27 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.core.utils.BlockUtil; +import forestry.plugins.PluginExtraUtilities; -public class FarmLogicExU extends FarmLogicHomogeneous { +public class FarmLogicRedOrchid extends FarmLogicHomogeneous { - private final String name; - private final Item iconItem; - - public FarmLogicExU(IFarmInstance instance, boolean isManual, String name, Item iconItem) { - super(instance, isManual); - this.name = name; - this.iconItem = iconItem; + public FarmLogicRedOrchid(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override public String getName() { - return name; + if (isManual) { + return "Manual Orchid Farm"; + } + return "Managed Orchid Farm"; } @Override public ItemStack getIconItemStack() { - return new ItemStack(iconItem); + return PluginExtraUtilities.orchidStack; } @Override @@ -78,5 +76,4 @@ public class FarmLogicExU extends FarmLogicHomogeneous { return false; } - } diff --git a/src/main/java/forestry/farming/logic/FarmLogicReeds.java b/src/main/java/forestry/farming/logic/FarmLogicReeds.java index 847c12c52..4ddd5e6c3 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicReeds.java +++ b/src/main/java/forestry/farming/logic/FarmLogicReeds.java @@ -18,11 +18,11 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; public class FarmLogicReeds extends FarmLogicSoil { - public FarmLogicReeds(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicReeds(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 4e971c7c0..6a220ffd2 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -25,7 +25,7 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.ICrop; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.core.utils.ItemStackUtil; import forestry.core.utils.Log; import forestry.farming.logic.crops.CropRubber; @@ -35,8 +35,8 @@ public class FarmLogicRubber extends FarmLogic { private boolean active = true; - public FarmLogicRubber(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicRubber(IFarmProperties properties, boolean isManual) { + super(properties, isManual); if (PluginIC2.rubberWood == null || PluginIC2.resin == null) { Log.warning("Failed to init a farm logic {} since IC2 rubber wood or resin were not found", getClass().getName()); active = false; diff --git a/src/main/java/forestry/farming/logic/FarmLogicSimple.java b/src/main/java/forestry/farming/logic/FarmLogicSimple.java index 786ab8755..44d2d0a99 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicSimple.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSimple.java @@ -2,14 +2,14 @@ package forestry.farming.logic; import net.minecraft.item.ItemStack; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.ISimpleFarmLogic; public class FarmLogicSimple extends FarmLogicCrops { private final ISimpleFarmLogic simpleLogic; - public FarmLogicSimple(IFarmInstance instance, boolean isManual, ISimpleFarmLogic simpleLogic) { + public FarmLogicSimple(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleLogic) { super(instance, isManual); this.simpleLogic = simpleLogic; } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSoil.java b/src/main/java/forestry/farming/logic/FarmLogicSoil.java index cf3e20ab8..5df2eed90 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicSoil.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSoil.java @@ -3,21 +3,21 @@ package forestry.farming.logic; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; public abstract class FarmLogicSoil extends FarmLogic { - public FarmLogicSoil(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicSoil(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } protected boolean isAcceptedSoil(IBlockState blockState) { - return instance.isAcceptedSoil(blockState); + return properties.isAcceptedSoil(blockState); } @Override public boolean isAcceptedResource(ItemStack itemStack) { - return instance.isAcceptedResource(itemStack); + return properties.isAcceptedResource(itemStack); } } diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index 201651e10..c865ddaf4 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -19,12 +19,12 @@ import net.minecraft.world.World; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.core.utils.ItemStackUtil; public class FarmLogicSucculent extends FarmLogicSoil { - public FarmLogicSucculent(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicSucculent(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicWatered.java b/src/main/java/forestry/farming/logic/FarmLogicWatered.java index 14cbe29b9..645e0ff9e 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicWatered.java +++ b/src/main/java/forestry/farming/logic/FarmLogicWatered.java @@ -23,7 +23,7 @@ import net.minecraftforge.fluids.FluidStack; import forestry.api.farming.FarmDirection; import forestry.api.farming.IFarmHousing; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.ISoil; import forestry.core.utils.BlockUtil; @@ -32,8 +32,8 @@ public abstract class FarmLogicWatered extends FarmLogicSoil { protected NonNullList produce = NonNullList.create(); - public FarmLogicWatered(IFarmInstance instance, boolean isManual) { - super(instance, isManual); + public FarmLogicWatered(IFarmProperties properties, boolean isManual) { + super(properties, isManual); } @Override @@ -68,7 +68,7 @@ public abstract class FarmLogicWatered extends FarmLogicSoil { } private boolean maintainSoil(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent) { - if(!farmHousing.canPlantSoil(isManual)){ + if (!farmHousing.canPlantSoil(isManual)) { return false; } diff --git a/src/main/java/forestry/farming/logic/FarmInstance.java b/src/main/java/forestry/farming/logic/FarmProperties.java similarity index 89% rename from src/main/java/forestry/farming/logic/FarmInstance.java rename to src/main/java/forestry/farming/logic/FarmProperties.java index 5edf0f916..0c445faa3 100644 --- a/src/main/java/forestry/farming/logic/FarmInstance.java +++ b/src/main/java/forestry/farming/logic/FarmProperties.java @@ -11,13 +11,13 @@ import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; -import forestry.api.farming.IFarmInstance; import forestry.api.farming.IFarmLogic; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.api.farming.ISoil; import forestry.farming.FarmRegistry; -public final class FarmInstance implements IFarmInstance { +public final class FarmProperties implements IFarmProperties { private final Set soils = new HashSet<>(); private final Set farmablesIdentifiers; private final IFarmLogic manualLogic; @@ -27,7 +27,7 @@ public final class FarmInstance implements IFarmInstance { @Nullable private Collection farmables; - public FarmInstance(String identifier, BiFunction logicFactory, Set farmablesIdentifiers) { + public FarmProperties(String identifier, BiFunction logicFactory, Set farmablesIdentifiers) { this.identifier = identifier; this.farmablesIdentifiers = farmablesIdentifiers; this.manualLogic = logicFactory.apply(this, true); @@ -41,7 +41,7 @@ public final class FarmInstance implements IFarmInstance { @Override public Collection getFarmables() { - if(farmables == null){ + if (farmables == null) { farmables = farmablesIdentifiers.stream().map(FarmRegistry.getInstance()::getFarmables).flatMap(Collection::stream).collect(Collectors.toSet()); } return farmables; diff --git a/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java b/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java index 11d807393..ff105a7b0 100644 --- a/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java +++ b/src/main/java/forestry/farming/logic/crops/CropChorusFlower.java @@ -14,7 +14,7 @@ import forestry.core.utils.NetworkUtil; public class CropChorusFlower extends Crop { private static final IBlockState BLOCK_STATE = Blocks.CHORUS_FLOWER.getDefaultState(); - + public CropChorusFlower(World world, BlockPos position) { super(world, position); } diff --git a/src/main/java/forestry/farming/logic/crops/CropDestroy.java b/src/main/java/forestry/farming/logic/crops/CropDestroy.java index 6ad61af75..c717f13d0 100644 --- a/src/main/java/forestry/farming/logic/crops/CropDestroy.java +++ b/src/main/java/forestry/farming/logic/crops/CropDestroy.java @@ -70,7 +70,7 @@ public class CropDestroy extends Crop { } removedSeed = true; } - }else{ + } else { dropIterator.remove(); } } diff --git a/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java b/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java index 5821d7838..b68b874f4 100644 --- a/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java +++ b/src/main/java/forestry/farming/logic/farmables/FarmableChorus.java @@ -58,7 +58,7 @@ public class FarmableChorus implements IFarmable { @Override public boolean plantSaplingAt(EntityPlayer player, ItemStack germling, World world, BlockPos pos) { - if(!canPlace(world, pos)){ + if (!canPlace(world, pos)) { return false; } return BlockUtil.setBlockWithPlaceSound(world, pos, Blocks.CHORUS_FLOWER.getDefaultState()); diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java index af98cd641..83405f1d5 100644 --- a/src/main/java/forestry/plugins/PluginExtraUtilities.java +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -10,24 +10,21 @@ ******************************************************************************/ package forestry.plugins; +import com.google.common.collect.ImmutableSet; + import java.util.Collections; -import java.util.function.Consumer; +import java.util.Set; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.init.Blocks; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.fml.common.registry.ForgeRegistries; - import forestry.api.circuits.ChipsetManager; -import forestry.api.circuits.ICircuit; import forestry.api.circuits.ICircuitLayout; -import forestry.api.core.ForestryAPI; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmRegistry; import forestry.api.modules.ForestryModule; import forestry.core.ModuleCore; @@ -37,79 +34,71 @@ import forestry.core.config.Constants; import forestry.core.items.EnumElectronTube; import forestry.core.utils.BlockUtil; import forestry.core.utils.Log; -import forestry.core.utils.ModUtil; import forestry.farming.FarmRegistry; import forestry.farming.circuits.CircuitFarmLogic; -import forestry.farming.logic.FarmLogicExU; +import forestry.farming.logic.FarmLogicRedOrchid; import forestry.farming.logic.farmables.FarmableAgingCrop; -import forestry.modules.BlankForestryModule; import forestry.modules.ForestryModuleUids; -@SuppressWarnings("unused") -@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.EXTRA_UTILITIES, name = "ExtraUtilities", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.module.extrautilities.description") -public class PluginExtraUtilities extends BlankForestryModule { +@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.EXTRA_UTILITIES, name = "Extra Utilities", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.module.extrautilities.description") +public class PluginExtraUtilities extends CompatPlugin { - private static final String ExU = "extrautils2"; + public static ItemStack orchidStack = ItemStack.EMPTY; - @Override - public boolean isAvailable() { - return ModUtil.isModLoaded(ExU); - } - - @Override - public String getFailMessage() { - return "ExtraUtilities not found"; + public PluginExtraUtilities() { + super("Extra Utilities", "extrautils2"); } @Override public void doInit() { - if (Config.isExUtilRedOrchidEnabled()) { - registerExPlant("Orchid", "redorchid", "Red Orchid", circuit -> Circuits.farmOrchidManaged = circuit, Blocks.REDSTONE_ORE, Blocks.LIT_REDSTONE_ORE); + Block redOrchid = getBlock("redorchid"); + Block enderLilly = getBlock("enderlilly"); + + if (Config.isExUtilRedOrchidEnabled() && redOrchid != null) { + Item item = Item.getItemFromBlock(redOrchid); + + registerFarmable(redOrchid, item, "farmOrchid"); + + IFarmProperties orchidFarm = FarmRegistry.getInstance().registerLogic("farmOrchid", FarmLogicRedOrchid::new); + orchidFarm.registerSoil(new ItemStack(Blocks.REDSTONE_ORE), Blocks.REDSTONE_ORE.getDefaultState()); + orchidFarm.registerSoil(new ItemStack(Blocks.LIT_REDSTONE_ORE), Blocks.LIT_REDSTONE_ORE.getDefaultState()); + + Circuits.farmOrchidManaged = new CircuitFarmLogic("managedOrchid", orchidFarm, false); + + orchidStack = new ItemStack(item); } - if (Config.isExUtilEnderLilyEnabled()) { - registerExPlant("Ender", "enderlilly", "Ender Lily", circuit -> Circuits.farmEnderManaged = circuit); + if (Config.isExUtilEnderLilyEnabled() && enderLilly != null) { + Item item = Item.getItemFromBlock(enderLilly); + registerFarmable(enderLilly, item, "farmEnder"); } } + @Override + public Set getDependencyUids() { + return ImmutableSet.of(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING)); + } + @Override public void registerRecipes() { - if (!ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.FARMING))) { - return; - } if(Circuits.farmOrchidManaged != null) { ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); - ChipsetManager.solderManager.addRecipe(layoutManaged, ModuleCore.items.tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManaged); + if(layoutManaged == null){ + return; + } + ChipsetManager.solderManager.addRecipe(layoutManaged, ModuleCore.getItems().tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManaged); } } - private void registerExPlant(String id, String itemResourceName, String itemName, Consumer assignTo, Block... soils) { - Block plantBlock = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(ExU, itemResourceName)); - Item plantItem = Item.getItemFromBlock(plantBlock); - if(plantBlock == Blocks.AIR) { - Log.error("Could not find {} block.", itemName); - } else if (plantItem == Items.AIR) { - Log.error("Could not find {} item.", itemName); + private void registerFarmable(Block plantBlock, Item plantItem, String identifier){ + IProperty growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class); + if (growthProperty == null) { + Log.error("Could not find the growth property of {}.", plantBlock.getLocalizedName()); } else { - IProperty growthProperty = BlockUtil.getProperty(plantBlock, "growth", Integer.class); - if (growthProperty == null) { - Log.error("Could not find the growth property of {}.", itemName); - } else { - String identifier = "farm" + id; - IFarmRegistry registry = FarmRegistry.getInstance(); - int harvestAge = Collections.max(growthProperty.getAllowedValues()); - int replantAge = plantBlock.getDefaultState().getValue(growthProperty); - registry.registerFarmables(identifier, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); - - IFarmInstance instance = registry.getFarm(identifier); - if(instance == null) { - instance = registry.registerLogic(identifier, (i, m) -> new FarmLogicExU(i, m, (m ? "Manual " : "Managed ") + itemName + " Farm", plantItem), itemName); - for (Block soil : soils) { - instance.registerSoil(new ItemStack(soil), soil.getDefaultState()); - } - assignTo.accept(new CircuitFarmLogic("managed" + id, instance, false)); - } - } + IFarmRegistry registry = FarmRegistry.getInstance(); + int harvestAge = Collections.max(growthProperty.getAllowedValues()); + int replantAge = plantBlock.getDefaultState().getValue(growthProperty); + registry.registerFarmables(identifier, new FarmableAgingCrop(new ItemStack(plantItem), plantBlock, growthProperty, harvestAge, replantAge)); } } } diff --git a/src/main/java/forestry/plugins/PluginIC2.java b/src/main/java/forestry/plugins/PluginIC2.java index 0c16ae550..0c328be5a 100644 --- a/src/main/java/forestry/plugins/PluginIC2.java +++ b/src/main/java/forestry/plugins/PluginIC2.java @@ -31,7 +31,7 @@ import forestry.api.circuits.ChipsetManager; import forestry.api.circuits.CircuitSocketType; import forestry.api.circuits.ICircuitLayout; import forestry.api.core.ForestryAPI; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.fuels.EngineBronzeFuel; import forestry.api.fuels.FuelManager; import forestry.api.modules.ForestryModule; @@ -117,7 +117,7 @@ public class PluginIC2 extends BlankForestryModule { rubber = IC2Items.getItem("crafting", "rubber"); fertilizer = IC2Items.getItem("crop_res","fertilizer"); - IFarmInstance rubberFarm = FarmRegistry.getInstance().registerLogic("farmRubber", FarmLogicRubber::new); + IFarmProperties rubberFarm = FarmRegistry.getInstance().registerLogic("farmRubber", FarmLogicRubber::new); Circuits.farmRubberManual = new CircuitFarmLogic("manualRubber", rubberFarm, true); diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index 89c11d2c0..c8847dbf7 100644 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -33,7 +33,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.registry.ForgeRegistries; import forestry.api.core.ForestryAPI; -import forestry.api.farming.IFarmInstance; +import forestry.api.farming.IFarmProperties; import forestry.api.fuels.FuelManager; import forestry.api.fuels.MoistenerFuel; import forestry.api.modules.ForestryModule; @@ -266,7 +266,7 @@ public class PluginNatura extends BlankForestryModule { */ @Override public void postInit() { - IFarmInstance farmArboreal = FarmRegistry.getInstance().getFarm("managedArboreal"); + IFarmProperties farmArboreal = FarmRegistry.getInstance().getFarm("managedArboreal"); if(farmArboreal != null) { farmArboreal.registerSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState(), false); } From 533c9d0b2a4ba9faf0a2832a5a537fcaf4f775c3 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Sat, 20 Jan 2018 21:29:07 +0100 Subject: [PATCH 06/12] Clean Up API --- .../java/forestry/api/farming/IFarmLogic.java | 3 +-- .../forestry/api/farming/IFarmProperties.java | 24 +++++++++++++++---- .../forestry/api/farming/IFarmRegistry.java | 10 +++----- .../cultivation/tiles/TilePlanter.java | 2 +- .../forestry/farming/DummyFarmRegistry.java | 5 ++-- .../java/forestry/farming/FarmRegistry.java | 12 +++++----- .../farming/logic/FakeFarmProperties.java | 5 ---- .../farming/logic/FarmProperties.java | 9 +------ .../multiblock/FakeFarmController.java | 2 +- .../farming/multiblock/FarmController.java | 2 +- .../java/forestry/plugins/PluginNatura.java | 2 +- 11 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index 1e3912fe1..d499034ad 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -64,7 +64,7 @@ public interface IFarmLogic { } /** - * Use {@link IFarmRegistry#getFarm(String)} to get the soil container for the farm logic and register the soil + * Use {@link IFarmRegistry#getProperties(String)} to get the {@link IFarmProperties} for the farm logic and register the soil * with {@link IFarmProperties#registerSoil(ItemStack, IBlockState, boolean)}. */ @Deprecated @@ -78,7 +78,6 @@ public interface IFarmLogic { String getName(); /* GUI ONLY */ - /** * @deprecated No longer needed because mc always uses the same map for blocks and items. * TODO remove this method in 1.13 diff --git a/src/main/java/forestry/api/farming/IFarmProperties.java b/src/main/java/forestry/api/farming/IFarmProperties.java index 729544653..25c751f06 100644 --- a/src/main/java/forestry/api/farming/IFarmProperties.java +++ b/src/main/java/forestry/api/farming/IFarmProperties.java @@ -10,23 +10,39 @@ import net.minecraft.item.ItemStack; */ public interface IFarmProperties { + /** + * Can be used to register a {@link IBlockState} as a valid soil. + */ default void registerSoil(ItemStack resource, IBlockState soilState){ registerSoil(resource, soilState, false); } - void registerFarmables(String identifier); - + /** + * Can be used to register a {@link IBlockState} as a valid soil. + */ void registerSoil(ItemStack resource, IBlockState soilState, boolean hasMetaData); + /** + * Adds the {@link IFarmable}s that where registered with the given identifier. + */ + void registerFarmables(String identifier); + + /** + * @return true if the given block state is a valid soil state. + */ boolean isAcceptedSoil(IBlockState blockState); + /** + * @return true if the given stack is the {@link ItemStack} of a soil. + */ boolean isAcceptedResource(ItemStack itemStack); - String getIdentifier(); - Collection getSoils(); Collection getFarmables(); + /** + * Returns the instance of the manual or managed {@link IFarmLogic}. + */ IFarmLogic getLogic(boolean manuel); } diff --git a/src/main/java/forestry/api/farming/IFarmRegistry.java b/src/main/java/forestry/api/farming/IFarmRegistry.java index 4f143e7a0..d580b5133 100644 --- a/src/main/java/forestry/api/farming/IFarmRegistry.java +++ b/src/main/java/forestry/api/farming/IFarmRegistry.java @@ -19,7 +19,7 @@ public interface IFarmRegistry { * @param logic corresponding instance of logic * * @deprecated Since Forestry 5.8. Use {@link #registerLogic(String, BiFunction, String...)} or - * {@link #registerLogic(IFarmProperties)}. + * {@link #registerLogic(String, IFarmProperties)}. */ @Deprecated void registerLogic(String identifier, IFarmLogic logic); @@ -28,7 +28,7 @@ public interface IFarmRegistry { * Registers farming logic in registry * @since Forestry 5.8 */ - IFarmProperties registerLogic(IFarmProperties farmInstance); + IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance); /** * Registers farming logic in registry under given identifier @@ -91,13 +91,9 @@ public interface IFarmRegistry { IFarmLogic createCropLogic(IFarmProperties instance, boolean isManual, ISimpleFarmLogic simpleFarmLogic); /** - * - * @param identifier - * @return - * * @since Forestry 5.8 */ @Nullable - IFarmProperties getFarm(String identifier); + IFarmProperties getProperties(String identifier); } diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index a1ebb54d4..2680c0b60 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -88,7 +88,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I public void setManual(boolean manual) { isManual = manual; - logic = FarmRegistry.getInstance().getFarm(identifier).getLogic(manual); + logic = FarmRegistry.getInstance().getProperties(identifier).getLogic(manual); } protected TilePlanter(String identifier) { diff --git a/src/main/java/forestry/farming/DummyFarmRegistry.java b/src/main/java/forestry/farming/DummyFarmRegistry.java index 7a53acdbf..faf1f6532 100644 --- a/src/main/java/forestry/farming/DummyFarmRegistry.java +++ b/src/main/java/forestry/farming/DummyFarmRegistry.java @@ -33,8 +33,7 @@ public class DummyFarmRegistry implements IFarmRegistry { } @Override - public IFarmProperties registerLogic(IFarmProperties farmInstance) { - //Dummy-Implementation + public IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance) { return null; } @@ -69,7 +68,7 @@ public class DummyFarmRegistry implements IFarmRegistry { @Nullable @Override - public IFarmProperties getFarm(String identifier) { + public IFarmProperties getProperties(String identifier) { //Dummy-Implementation return null; } diff --git a/src/main/java/forestry/farming/FarmRegistry.java b/src/main/java/forestry/farming/FarmRegistry.java index 6b08a7d30..e028d7477 100644 --- a/src/main/java/forestry/farming/FarmRegistry.java +++ b/src/main/java/forestry/farming/FarmRegistry.java @@ -88,23 +88,23 @@ public final class FarmRegistry implements IFarmRegistry { } @Override - public IFarmProperties registerLogic(IFarmProperties farmInstance) { - farmInstances.put(farmInstance.getIdentifier(), farmInstance); + public IFarmProperties registerLogic(String identifier, IFarmProperties farmInstance) { + farmInstances.put(identifier, farmInstance); return farmInstance; } @Override public IFarmProperties registerLogic(String identifier, BiFunction logicFactory, String... farmablesIdentifiers) { - Set fIdentifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers)); - fIdentifiers.add(identifier); - IFarmProperties instance = new FarmProperties(identifier, logicFactory, fIdentifiers); + Set identifiers = new HashSet<>(Arrays.asList(farmablesIdentifiers)); + identifiers.add(identifier); + IFarmProperties instance = new FarmProperties(logicFactory, identifiers); farmInstances.put(identifier, instance); return instance; } @Override @Nullable - public IFarmProperties getFarm(String identifier) { + public IFarmProperties getProperties(String identifier) { return farmInstances.get(identifier); } diff --git a/src/main/java/forestry/farming/logic/FakeFarmProperties.java b/src/main/java/forestry/farming/logic/FakeFarmProperties.java index 056982fbd..6cf8aa652 100644 --- a/src/main/java/forestry/farming/logic/FakeFarmProperties.java +++ b/src/main/java/forestry/farming/logic/FakeFarmProperties.java @@ -36,11 +36,6 @@ public class FakeFarmProperties implements IFarmProperties { return false; } - @Override - public String getIdentifier() { - return "farmFake"; - } - @Override public Collection getSoils() { return Collections.emptySet(); diff --git a/src/main/java/forestry/farming/logic/FarmProperties.java b/src/main/java/forestry/farming/logic/FarmProperties.java index 0c445faa3..71393ed3e 100644 --- a/src/main/java/forestry/farming/logic/FarmProperties.java +++ b/src/main/java/forestry/farming/logic/FarmProperties.java @@ -22,13 +22,11 @@ public final class FarmProperties implements IFarmProperties { private final Set farmablesIdentifiers; private final IFarmLogic manualLogic; private final IFarmLogic managedLogic; - private final String identifier; @Nullable private Collection farmables; - public FarmProperties(String identifier, BiFunction logicFactory, Set farmablesIdentifiers) { - this.identifier = identifier; + public FarmProperties(BiFunction logicFactory, Set farmablesIdentifiers) { this.farmablesIdentifiers = farmablesIdentifiers; this.manualLogic = logicFactory.apply(this, true); this.managedLogic = logicFactory.apply(this, false); @@ -86,9 +84,4 @@ public final class FarmProperties implements IFarmProperties { public Collection getSoils() { return soils; } - - @Override - public String getIdentifier() { - return identifier; - } } diff --git a/src/main/java/forestry/farming/multiblock/FakeFarmController.java b/src/main/java/forestry/farming/multiblock/FakeFarmController.java index 9090f13a1..34fc79620 100644 --- a/src/main/java/forestry/farming/multiblock/FakeFarmController.java +++ b/src/main/java/forestry/farming/multiblock/FakeFarmController.java @@ -87,7 +87,7 @@ public class FakeFarmController extends FakeMultiblockController implements IFar @Override public IFarmLogic getFarmLogic(FarmDirection direction) { - return FarmRegistry.getInstance().getFarm("farmArboreal").getLogic(false); + return FarmRegistry.getInstance().getProperties("farmArboreal").getLogic(false); } @Override diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index 57094a766..9ac70d73a 100755 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -630,7 +630,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen @Override public void resetFarmLogic(FarmDirection direction) { - setFarmLogic(direction, FarmRegistry.getInstance().getFarm("farmArboreal").getLogic(false)); + setFarmLogic(direction, FarmRegistry.getInstance().getProperties("farmArboreal").getLogic(false)); } @Override diff --git a/src/main/java/forestry/plugins/PluginNatura.java b/src/main/java/forestry/plugins/PluginNatura.java index c8847dbf7..f6bd9fc53 100644 --- a/src/main/java/forestry/plugins/PluginNatura.java +++ b/src/main/java/forestry/plugins/PluginNatura.java @@ -266,7 +266,7 @@ public class PluginNatura extends BlankForestryModule { */ @Override public void postInit() { - IFarmProperties farmArboreal = FarmRegistry.getInstance().getFarm("managedArboreal"); + IFarmProperties farmArboreal = FarmRegistry.getInstance().getProperties("managedArboreal"); if(farmArboreal != null) { farmArboreal.registerSoil(new ItemStack(Blocks.NETHERRACK), Blocks.NETHERRACK.getDefaultState(), false); } From cd7250604e133b3deb1847445e29e62464218b31 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Mon, 22 Jan 2018 18:56:25 +0100 Subject: [PATCH 07/12] Add missing farm logic localisation --- .../java/forestry/api/circuits/ICircuit.java | 6 ++ .../java/forestry/api/farming/Farmables.java | 8 ++- .../java/forestry/api/farming/IFarmLogic.java | 72 ++++++++++++++++--- .../forestry/api/farming/package-info.java | 3 +- .../java/forestry/core/circuits/Circuit.java | 2 +- .../core/circuits/GuiSolderingIron.java | 2 +- .../java/forestry/core/config/Config.java | 2 +- .../forestry/cultivation/gui/GuiPlanter.java | 19 ++--- .../gui/widgets/GhostItemStackWidget.java | 18 ++--- .../cultivation/tiles/TileArboretum.java | 19 ++--- .../forestry/cultivation/tiles/TileBog.java | 17 ++--- .../cultivation/tiles/TileFarmCrops.java | 19 ++--- .../cultivation/tiles/TileFarmEnder.java | 19 ++--- .../cultivation/tiles/TileFarmGourd.java | 15 ++-- .../cultivation/tiles/TileFarmMushroom.java | 19 ++--- .../cultivation/tiles/TileFarmNether.java | 19 ++--- .../cultivation/tiles/TilePlantation.java | 13 ++-- .../cultivation/tiles/TilePlanter.java | 10 ++- .../java/forestry/farming/FarmRegistry.java | 4 +- .../java/forestry/farming/ModuleFarming.java | 2 +- .../farming/circuits/CircuitFarmLogic.java | 10 +++ .../forestry/farming/logic/FarmLogic.java | 7 ++ .../farming/logic/FarmLogicArboreal.java | 4 +- .../farming/logic/FarmLogicCocoa.java | 4 +- .../farming/logic/FarmLogicCrops.java | 9 +-- .../farming/logic/FarmLogicEnder.java | 4 +- .../farming/logic/FarmLogicGourd.java | 4 +- .../farming/logic/FarmLogicInfernal.java | 4 +- .../farming/logic/FarmLogicMushroom.java | 9 +-- .../farming/logic/FarmLogicOrchard.java | 4 +- .../forestry/farming/logic/FarmLogicPeat.java | 8 +-- .../farming/logic/FarmLogicRedOrchid.java | 7 +- .../farming/logic/FarmLogicReeds.java | 8 +-- .../farming/logic/FarmLogicRubber.java | 4 +- .../farming/logic/FarmLogicSucculent.java | 8 +-- .../farming/logic/FarmProperties.java | 6 +- .../plugins/PluginExtraUtilities.java | 5 +- 37 files changed, 233 insertions(+), 160 deletions(-) diff --git a/src/main/java/forestry/api/circuits/ICircuit.java b/src/main/java/forestry/api/circuits/ICircuit.java index 900ab84ef..f3e74fac8 100644 --- a/src/main/java/forestry/api/circuits/ICircuit.java +++ b/src/main/java/forestry/api/circuits/ICircuit.java @@ -7,11 +7,17 @@ package forestry.api.circuits; import java.util.List; +import net.minecraft.util.text.translation.I18n; + public interface ICircuit { String getUID(); String getUnlocalizedName(); + default String getLocalizedName(){ + return I18n.translateToLocal(getUnlocalizedName()); + } + boolean isCircuitable(Object tile); void onInsertion(int slot, Object tile); diff --git a/src/main/java/forestry/api/farming/Farmables.java b/src/main/java/forestry/api/farming/Farmables.java index 3595d5061..4cce3f8f7 100644 --- a/src/main/java/forestry/api/farming/Farmables.java +++ b/src/main/java/forestry/api/farming/Farmables.java @@ -5,14 +5,16 @@ ******************************************************************************/ package forestry.api.farming; -import java.util.LinkedHashMap; -import java.util.Map; - import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; +import java.util.LinkedHashMap; +import java.util.Map; + import net.minecraft.item.ItemStack; +//TODO: Remove this class in 1.13 +@Deprecated public class Farmables { /** * Can be used to add IFarmables to some of the vanilla farm logics. diff --git a/src/main/java/forestry/api/farming/IFarmLogic.java b/src/main/java/forestry/api/farming/IFarmLogic.java index d499034ad..7db1e3df5 100644 --- a/src/main/java/forestry/api/farming/IFarmLogic.java +++ b/src/main/java/forestry/api/farming/IFarmLogic.java @@ -20,6 +20,11 @@ import net.minecraftforge.fml.relauncher.SideOnly; import forestry.api.core.ForestryAPI; +/** + * The IFarmLogic is used by farm blocks and multi-blocks to cultivate and harvest crops and plants. + * + * Every farm block has only ony one logic a multi-block farm has four, one for every direction. + */ public interface IFarmLogic { /** @@ -29,21 +34,72 @@ public interface IFarmLogic { int getFertilizerConsumption(); /** + * @param hydrationModifier A modifier that depends on the weather and the biome of the farm. + * * @return The amount of water that the {@link IFarmHousing} automatically removes after this logic cultivated * a block or harvested a crop. */ int getWaterConsumption(float hydrationModifier); + /** + * Checks if the given stack is a resource or a soil that this logic uses to grow plants on or to create other + * products like peat. + */ boolean isAcceptedResource(ItemStack itemstack); + /** + * Checks if the given stack is a germling (plantable sapling, seed, etc.) for any {@link IFarmable} of this farm. + */ boolean isAcceptedGermling(ItemStack itemstack); + /** + * Collects all items that are laying on the ground and are in the {@link IFarmHousing#getArea()} of the farm. + * + * @param world The world of the farm. + * @param farmHousing The farm that uses this logic. + * + * @return A collection that contains all items that were collected. + */ NonNullList collect(World world, IFarmHousing farmHousing); + /** + * Tries to cultivate one or more blocks at the given position and with the given extent. + * + * @param world The world of the farm. + * @param farmHousing The farm that uses this logic. + * @param pos The position at that the logic should start to cultivate. + * @param direction The direction of the extension. + * @param extent How many blocks this logic has to cultivate after it cultivated the block at the given position. + * The positions of the next blocks are having a offset in the given direction. + * @return True if the logic has cultivated any block. + */ boolean cultivate(World world, IFarmHousing farmHousing, BlockPos pos, FarmDirection direction, int extent); + /** + * Tries to harvest one or more blocks at the given position and with the given extent. + * + * @param world The world of the farm. + * @param pos The position at that the logic should start to harvest. + * @param direction The direction of the extension. + * @param extent How many blocks this logic tries to harvest after it has tried to harvested the block at the given position. + * The positions of the next blocks are having a offset in the given direction. + * @return True if the logic has cultivated any block. + */ Collection harvest(World world, BlockPos pos, FarmDirection direction, int extent); + /** + * Returns the {@link IFarmProperties} that created this logic. + * + * @since Forestry 5.8 + * + * @return Returns the {@link IFarmProperties} that created this logic. Returns a fake instance from + * {@link IFarmRegistry#createFakeInstance(IFarmLogic)} if the logic is older that Forestry 5.8. + * TODO: Remove "default" from this method in 1.13 + */ + default IFarmProperties getProperties(){ + return ForestryAPI.farmRegistry.createFakeInstance(this); + } + /** * @deprecated Since Forestry 5.8 logic instances are created at the constructor of the {@link IFarmProperties} and * have a immutable manual state. TODO Remove this method in 1.13 @@ -53,16 +109,6 @@ public interface IFarmLogic { return this; } - /** - * @since Forestry 5.8 - * - * @return Returns the {@link IFarmProperties} that created this logic. Returns a fake instance from - * {@link IFarmRegistry#createFakeInstance(IFarmLogic)} if the logic is older that Forestry 5.8. - */ - default IFarmProperties getInstance(){ - return ForestryAPI.farmRegistry.createFakeInstance(this); - } - /** * Use {@link IFarmRegistry#getProperties(String)} to get the {@link IFarmProperties} for the farm logic and register the soil * with {@link IFarmProperties#registerSoil(ItemStack, IBlockState, boolean)}. @@ -72,8 +118,12 @@ public interface IFarmLogic { // } + default String getUnlocalizedName(){ + return ""; + } + /** - * @return A short localized name for this logic. + * @return Localized short, human-readable identifier used in the farm gui and in tooltips. */ String getName(); diff --git a/src/main/java/forestry/api/farming/package-info.java b/src/main/java/forestry/api/farming/package-info.java index d599fba86..8a04a7f93 100644 --- a/src/main/java/forestry/api/farming/package-info.java +++ b/src/main/java/forestry/api/farming/package-info.java @@ -5,10 +5,11 @@ ******************************************************************************/ @ParametersAreNonnullByDefault @MethodsReturnNonnullByDefault -@API(apiVersion = "2.2.0", owner = "ForestryAPI|core", provides = "ForestryAPI|farming") +@API(apiVersion = "5.8.0", owner = "ForestryAPI|core", provides = "ForestryAPI|farming") package forestry.api.farming; import javax.annotation.ParametersAreNonnullByDefault; import mcp.MethodsReturnNonnullByDefault; + import net.minecraftforge.fml.common.API; diff --git a/src/main/java/forestry/core/circuits/Circuit.java b/src/main/java/forestry/core/circuits/Circuit.java index 88396319b..f1e008ef9 100755 --- a/src/main/java/forestry/core/circuits/Circuit.java +++ b/src/main/java/forestry/core/circuits/Circuit.java @@ -37,7 +37,7 @@ public abstract class Circuit implements ICircuit { @Override public void addTooltip(List list) { - list.add(Translator.translateToLocal(getUnlocalizedName())); + list.add(getLocalizedName()); int i = 1; while (true) { diff --git a/src/main/java/forestry/core/circuits/GuiSolderingIron.java b/src/main/java/forestry/core/circuits/GuiSolderingIron.java index 049346ef6..ca83e5490 100755 --- a/src/main/java/forestry/core/circuits/GuiSolderingIron.java +++ b/src/main/java/forestry/core/circuits/GuiSolderingIron.java @@ -53,7 +53,7 @@ public class GuiSolderingIron extends GuiForestry { if (recipe == null) { description = "(" + Translator.translateToLocal("for.gui.noeffect") + ")"; } else { - description = Translator.translateToLocal(recipe.getCircuit().getUnlocalizedName()); + description = recipe.getCircuit().getLocalizedName(); } int row = i * 20; diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 1693ff687..303aba09d 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -106,7 +106,7 @@ public class Config { // Cultivation public static int planterExtend = 4; - public static boolean ringFarms = false; + public static boolean ringFarms = true; public static int ringSize = 4; // Mail diff --git a/src/main/java/forestry/cultivation/gui/GuiPlanter.java b/src/main/java/forestry/cultivation/gui/GuiPlanter.java index eadaf7eaa..4f892bede 100644 --- a/src/main/java/forestry/cultivation/gui/GuiPlanter.java +++ b/src/main/java/forestry/cultivation/gui/GuiPlanter.java @@ -2,6 +2,7 @@ package forestry.cultivation.gui; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import forestry.core.ModuleCore; import forestry.core.config.Constants; @@ -21,9 +22,9 @@ public class GuiPlanter extends GuiForestryTitled { this.xSize = 202; this.ySize = 192; - ItemStack[] resourceStacks = tile.createResourceStacks(); - ItemStack[] germlingStacks = tile.createGermlingStacks(); - ItemStack[] productionStacks = tile.createProductionStacks(); + NonNullList resourceStacks = tile.createResourceStacks(); + NonNullList germlingStacks = tile.createGermlingStacks(); + NonNullList productionStacks = tile.createProductionStacks(); widgetManager.add(new TankWidget(widgetManager, 178, 44, 0).setOverlayOrigin(xSize, 18)); @@ -31,8 +32,8 @@ public class GuiPlanter extends GuiForestryTitled { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { int index = j + i * 2; - if(resourceStacks.length == 4) { - widgetManager.add(new GhostItemStackWidget(widgetManager, 11 + j * 18, 65 + i * 18, resourceStacks[index], inventorySlots.getSlot(36 + InventoryPlanter.SLOT_RESOURCES_1 + index))); + if(resourceStacks.size() == 4) { + widgetManager.add(new GhostItemStackWidget(widgetManager, 11 + j * 18, 65 + i * 18, resourceStacks.get(index), inventorySlots.getSlot(36 + InventoryPlanter.SLOT_RESOURCES_1 + index))); } } } @@ -41,8 +42,8 @@ public class GuiPlanter extends GuiForestryTitled { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { int index = j + i * 2; - if(germlingStacks.length == 4){ - widgetManager.add(new GhostItemStackWidget(widgetManager, 71 + j * 18, 65 + i * 18, germlingStacks[index], inventorySlots.getSlot(36 + InventoryPlanter.SLOT_GERMLINGS_1 + index))); + if(germlingStacks.size() == 4){ + widgetManager.add(new GhostItemStackWidget(widgetManager, 71 + j * 18, 65 + i * 18, germlingStacks.get(index), inventorySlots.getSlot(36 + InventoryPlanter.SLOT_GERMLINGS_1 + index))); } } } @@ -51,8 +52,8 @@ public class GuiPlanter extends GuiForestryTitled { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { int index = j + i * 2; - if(productionStacks.length == 4) { - widgetManager.add(new GhostItemStackWidget(widgetManager, 131 + j * 18, 65 + i * 18, productionStacks[index], inventorySlots.getSlot(36 + InventoryPlanter.SLOT_PRODUCTION_1 + j + i * 2))); + if(productionStacks.size() == 4) { + widgetManager.add(new GhostItemStackWidget(widgetManager, 131 + j * 18, 65 + i * 18, productionStacks.get(index), inventorySlots.getSlot(36 + InventoryPlanter.SLOT_PRODUCTION_1 + j + i * 2))); } } } diff --git a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java index 9902a00bc..f52d910b5 100644 --- a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java +++ b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java @@ -5,6 +5,7 @@ import java.util.Locale; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; @@ -16,7 +17,6 @@ import forestry.core.gui.widgets.WidgetManager; import forestry.core.render.ColourProperties; import forestry.core.utils.Translator; import forestry.cultivation.inventory.InventoryPlanter; -import org.lwjgl.opengl.GL11; public class GhostItemStackWidget extends ItemStackWidget { private final Slot slot; @@ -30,9 +30,10 @@ public class GhostItemStackWidget extends ItemStackWidget { if (!slot.getHasStack()) { super.draw(startX, startY); } - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_BLEND); + GlStateManager.pushMatrix(); + GlStateManager.disableLighting(); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); String directionString = getDirectionString(); if (!directionString.isEmpty()){ @@ -40,15 +41,16 @@ public class GhostItemStackWidget extends ItemStackWidget { fontRenderer.drawStringWithShadow(getDirectionString(), xPos + startX + 5, yPos + startY + 4, ColourProperties.INSTANCE.get("gui.screen")); } - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); + GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F); TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); textureManager.bindTexture(manager.gui.textureFile); manager.gui.drawTexturedModalRect(xPos + startX, yPos + startY, 206, 0, 16, 16); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_LIGHTING); + GlStateManager.disableBlend(); + GlStateManager.enableDepth(); + GlStateManager.enableLighting(); + GlStateManager.popMatrix(); } private String getDirectionString(){ diff --git a/src/main/java/forestry/cultivation/tiles/TileArboretum.java b/src/main/java/forestry/cultivation/tiles/TileArboretum.java index 065673270..549e53340 100644 --- a/src/main/java/forestry/cultivation/tiles/TileArboretum.java +++ b/src/main/java/forestry/cultivation/tiles/TileArboretum.java @@ -3,6 +3,7 @@ package forestry.cultivation.tiles; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TileArboretum extends TilePlanter { public TileArboretum() { @@ -10,32 +11,32 @@ public class TileArboretum extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[]{ + public NonNullList createGermlingStacks() { + return createList( new ItemStack(Blocks.SAPLING), new ItemStack(Blocks.SAPLING, 1, 2), new ItemStack(Blocks.SAPLING, 1, 2), new ItemStack(Blocks.SAPLING) - }; + ); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[]{ + public NonNullList createResourceStacks() { + return createList( new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT) - }; + ); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(Blocks.LOG), new ItemStack(Items.APPLE), new ItemStack(Items.APPLE), new ItemStack(Blocks.LOG) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TileBog.java b/src/main/java/forestry/cultivation/tiles/TileBog.java index ebcd6815a..12a654363 100644 --- a/src/main/java/forestry/cultivation/tiles/TileBog.java +++ b/src/main/java/forestry/cultivation/tiles/TileBog.java @@ -1,6 +1,7 @@ package forestry.cultivation.tiles; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; import forestry.core.ModuleCore; @@ -10,27 +11,27 @@ public class TileBog extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[0]; + public NonNullList createGermlingStacks() { + return NonNullList.create(); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[]{ + public NonNullList createResourceStacks() { + return createList( new ItemStack(ModuleCore.getBlocks().bogEarth), new ItemStack(ModuleCore.getBlocks().bogEarth), new ItemStack(ModuleCore.getBlocks().bogEarth), new ItemStack(ModuleCore.getBlocks().bogEarth) - }; + ); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(ModuleCore.getItems().peat), new ItemStack(ModuleCore.getItems().peat), new ItemStack(ModuleCore.getItems().peat), new ItemStack(ModuleCore.getItems().peat) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java b/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java index 17a1a865b..6ef256889 100644 --- a/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java +++ b/src/main/java/forestry/cultivation/tiles/TileFarmCrops.java @@ -3,6 +3,7 @@ package forestry.cultivation.tiles; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TileFarmCrops extends TilePlanter { public TileFarmCrops() { @@ -10,32 +11,32 @@ public class TileFarmCrops extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[]{ + public NonNullList createGermlingStacks() { + return createList( new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.POTATO), new ItemStack(Items.CARROT), new ItemStack(Items.BEETROOT_SEEDS) - }; + ); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[]{ + public NonNullList createResourceStacks() { + return createList( new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT), new ItemStack(Blocks.DIRT) - }; + ); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(Items.WHEAT), new ItemStack(Items.POTATO), new ItemStack(Items.CARROT), new ItemStack(Items.BEETROOT) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java b/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java index 60b65f636..1d6916586 100644 --- a/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java +++ b/src/main/java/forestry/cultivation/tiles/TileFarmEnder.java @@ -3,6 +3,7 @@ package forestry.cultivation.tiles; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TileFarmEnder extends TilePlanter { public TileFarmEnder() { @@ -10,32 +11,32 @@ public class TileFarmEnder extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[]{ + public NonNullList createGermlingStacks() { + return createList( new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack(Blocks.CHORUS_FLOWER) - }; + ); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[]{ + public NonNullList createResourceStacks() { + return createList( new ItemStack(Blocks.END_STONE), new ItemStack(Blocks.END_STONE), new ItemStack(Blocks.END_STONE), new ItemStack(Blocks.END_STONE) - }; + ); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(Blocks.CHORUS_FLOWER), new ItemStack(Items.CHORUS_FRUIT), new ItemStack(Items.CHORUS_FRUIT), new ItemStack(Blocks.CHORUS_FLOWER) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java b/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java index 19d63f6bb..e99abd04c 100644 --- a/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java +++ b/src/main/java/forestry/cultivation/tiles/TileFarmGourd.java @@ -2,6 +2,7 @@ package forestry.cultivation.tiles; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TileFarmGourd extends TilePlanter { public TileFarmGourd() { @@ -9,22 +10,22 @@ public class TileFarmGourd extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[0]; + public NonNullList createGermlingStacks() { + return NonNullList.create(); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[0]; + public NonNullList createResourceStacks() { + return NonNullList.create(); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(Blocks.MELON_BLOCK), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java b/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java index ecb696869..5ae5f36f7 100644 --- a/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java +++ b/src/main/java/forestry/cultivation/tiles/TileFarmMushroom.java @@ -2,6 +2,7 @@ package forestry.cultivation.tiles; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TileFarmMushroom extends TilePlanter { public TileFarmMushroom() { @@ -9,32 +10,32 @@ public class TileFarmMushroom extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[]{ + public NonNullList createGermlingStacks() { + return createList( new ItemStack(Blocks.RED_MUSHROOM), new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack(Blocks.RED_MUSHROOM) - }; + ); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[]{ + public NonNullList createResourceStacks() { + return createList( new ItemStack(Blocks.MYCELIUM), new ItemStack(Blocks.DIRT, 1, 2), new ItemStack(Blocks.DIRT, 1, 2), new ItemStack(Blocks.MYCELIUM) - }; + ); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(Blocks.RED_MUSHROOM), new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack(Blocks.BROWN_MUSHROOM), new ItemStack(Blocks.RED_MUSHROOM) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TileFarmNether.java b/src/main/java/forestry/cultivation/tiles/TileFarmNether.java index be6b651a4..be8c5f29c 100644 --- a/src/main/java/forestry/cultivation/tiles/TileFarmNether.java +++ b/src/main/java/forestry/cultivation/tiles/TileFarmNether.java @@ -3,6 +3,7 @@ package forestry.cultivation.tiles; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TileFarmNether extends TilePlanter { public TileFarmNether() { @@ -10,32 +11,32 @@ public class TileFarmNether extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[]{ + public NonNullList createGermlingStacks() { + return createList( new ItemStack(Items.NETHER_WART), new ItemStack(Items.NETHER_WART), new ItemStack(Items.NETHER_WART), new ItemStack(Items.NETHER_WART) - }; + ); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[]{ + public NonNullList createResourceStacks() { + return createList( new ItemStack(Blocks.SOUL_SAND), new ItemStack(Blocks.SOUL_SAND), new ItemStack(Blocks.SOUL_SAND), new ItemStack(Blocks.SOUL_SAND) - }; + ); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[]{ + public NonNullList createProductionStacks() { + return createList( new ItemStack(Items.NETHER_WART), new ItemStack(Items.NETHER_WART), new ItemStack(Items.NETHER_WART), new ItemStack(Items.NETHER_WART) - }; + ); } } diff --git a/src/main/java/forestry/cultivation/tiles/TilePlantation.java b/src/main/java/forestry/cultivation/tiles/TilePlantation.java index 3e7b7619c..23fb31822 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlantation.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlantation.java @@ -1,6 +1,7 @@ package forestry.cultivation.tiles; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; public class TilePlantation extends TilePlanter { @@ -9,17 +10,17 @@ public class TilePlantation extends TilePlanter { } @Override - public ItemStack[] createGermlingStacks() { - return new ItemStack[0]; + public NonNullList createGermlingStacks() { + return NonNullList.create(); } @Override - public ItemStack[] createResourceStacks() { - return new ItemStack[0]; + public NonNullList createResourceStacks() { + return NonNullList.create(); } @Override - public ItemStack[] createProductionStacks() { - return new ItemStack[0]; + public NonNullList createProductionStacks() { + return NonNullList.create(); } } diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index 2680c0b60..6da34f056 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -501,10 +501,14 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return tankManager; } - public abstract ItemStack[] createGermlingStacks(); + protected NonNullList createList(ItemStack... stacks){ + return NonNullList.from(ItemStack.EMPTY, stacks); + } - public abstract ItemStack[] createResourceStacks(); + public abstract NonNullList createGermlingStacks(); - public abstract ItemStack[] createProductionStacks(); + public abstract NonNullList createResourceStacks(); + + public abstract NonNullList createProductionStacks(); } diff --git a/src/main/java/forestry/farming/FarmRegistry.java b/src/main/java/forestry/farming/FarmRegistry.java index e028d7477..1ccd1245c 100644 --- a/src/main/java/forestry/farming/FarmRegistry.java +++ b/src/main/java/forestry/farming/FarmRegistry.java @@ -145,13 +145,13 @@ public final class FarmRegistry implements IFarmRegistry { for(String entry : fertilizerList){ String[] spited = entry.split(";"); if(spited.length < 2){ - Log.error("Foretsry failed to parse a entry of the fertilizer config."); + Log.error("Forestry failed to parse a entry of the fertilizer config."); continue; } String itemName = spited[0]; ItemStack fertilizerItem = ItemStackUtil.parseItemStackString(itemName, OreDictionary.WILDCARD_VALUE); if(fertilizerItem == null || fertilizerItem.isEmpty()){ - Log.error("Foretsry failed to parse a entry of the fertilizer config, because the item doesn't exists."); + Log.error("Forestry failed to parse a entry of the fertilizer config, because the item doesn't exists."); continue; } String value = spited[1]; diff --git a/src/main/java/forestry/farming/ModuleFarming.java b/src/main/java/forestry/farming/ModuleFarming.java index 66e661017..e913ed20f 100644 --- a/src/main/java/forestry/farming/ModuleFarming.java +++ b/src/main/java/forestry/farming/ModuleFarming.java @@ -246,7 +246,7 @@ public class ModuleFarming extends BlankForestryModule { Circuits.farmCocoaManual = new CircuitFarmLogic("manualCocoa", cocoaFarm, true); Circuits.farmEnderManaged = new CircuitFarmLogic("managedEnder", enderFarm, false); - Circuits.farmEnderManual = new CircuitFarmLogic("manualEnder", enderFarm, false); + Circuits.farmEnderManual = new CircuitFarmLogic("manualEnder", enderFarm, true); enderFarm.registerSoil(new ItemStack(Blocks.END_STONE), Blocks.END_STONE.getDefaultState()); } diff --git a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java index b27f090c1..fa381ee90 100755 --- a/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java +++ b/src/main/java/forestry/farming/circuits/CircuitFarmLogic.java @@ -33,6 +33,16 @@ public class CircuitFarmLogic extends Circuit { this.logic = logic; } + @Override + public String getUnlocalizedName() { + return logic.getUnlocalizedName(); + } + + @Override + public String getLocalizedName() { + return logic.getName(); + } + /** * @deprecated TODO: Remove this method in 1.13 */ diff --git a/src/main/java/forestry/farming/logic/FarmLogic.java b/src/main/java/forestry/farming/logic/FarmLogic.java index 62a4b4581..0ee747f3b 100755 --- a/src/main/java/forestry/farming/logic/FarmLogic.java +++ b/src/main/java/forestry/farming/logic/FarmLogic.java @@ -35,6 +35,7 @@ import forestry.api.farming.IFarmLogic; import forestry.api.farming.IFarmProperties; import forestry.api.farming.IFarmable; import forestry.api.farming.ISoil; +import forestry.core.utils.Translator; import forestry.core.utils.VectUtil; public abstract class FarmLogic implements IFarmLogic { @@ -55,6 +56,12 @@ public abstract class FarmLogic implements IFarmLogic { return properties.getSoils(); } + @Override + public String getName() { + String unformatted = isManual ? "for.farm.grammar.manual" : "for.farm.grammar.managed"; + return Translator.translateToLocalFormatted(unformatted, Translator.translateToLocal(getUnlocalizedName())); + } + @Override public FarmLogic setManual(boolean flag) { return this; diff --git a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java index 0e363786c..768c061ef 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicArboreal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicArboreal.java @@ -52,8 +52,8 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous { } @Override - public String getName() { - return "Managed Arboretum"; + public String getUnlocalizedName() { + return "for.farm.arboretum"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java index ccb549774..64d5c10ea 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCocoa.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCocoa.java @@ -51,8 +51,8 @@ public class FarmLogicCocoa extends FarmLogic { } @Override - public String getName() { - return "Cocoa Plantation"; + public String getUnlocalizedName() { + return "for.farm.cocoa"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicCrops.java b/src/main/java/forestry/farming/logic/FarmLogicCrops.java index 9160a142e..3e57ab87d 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicCrops.java +++ b/src/main/java/forestry/farming/logic/FarmLogicCrops.java @@ -90,12 +90,7 @@ public class FarmLogicCrops extends FarmLogicWatered { } @Override - public String getName() { - if (isManual) { - return "Manual Crop Farm"; - } else { - return "Managed Crop Farm"; - } + public String getUnlocalizedName() { + return "for.farm.crops"; } - } diff --git a/src/main/java/forestry/farming/logic/FarmLogicEnder.java b/src/main/java/forestry/farming/logic/FarmLogicEnder.java index e590c7c15..28968daf4 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicEnder.java +++ b/src/main/java/forestry/farming/logic/FarmLogicEnder.java @@ -37,8 +37,8 @@ public class FarmLogicEnder extends FarmLogicHomogeneous { } @Override - public String getName() { - return "Manual Ender Farm"; + public String getUnlocalizedName() { + return "for.farm.ender"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicGourd.java b/src/main/java/forestry/farming/logic/FarmLogicGourd.java index 3f5638630..6349294c6 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicGourd.java +++ b/src/main/java/forestry/farming/logic/FarmLogicGourd.java @@ -32,8 +32,8 @@ public class FarmLogicGourd extends FarmLogic { } @Override - public String getName() { - return "Gourd Farm"; + public String getUnlocalizedName() { + return "for.farm.gourd"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java index 6228fd024..186e911be 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicInfernal.java +++ b/src/main/java/forestry/farming/logic/FarmLogicInfernal.java @@ -34,8 +34,8 @@ public class FarmLogicInfernal extends FarmLogicHomogeneous { } @Override - public String getName() { - return "Managed Infernal Farm"; + public String getUnlocalizedName() { + return "for.farm.infernal"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java index 6945b21ec..ee63c5dde 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicMushroom.java +++ b/src/main/java/forestry/farming/logic/FarmLogicMushroom.java @@ -23,14 +23,9 @@ public class FarmLogicMushroom extends FarmLogicArboreal { public FarmLogicMushroom(IFarmProperties properties, boolean isManual) { super(properties, isManual); } - @Override - public String getName() { - if (isManual) { - return "Manual Shroom Farm"; - } else { - return "Managed Shroom Farm"; - } + public String getUnlocalizedName() { + return "for.farm.shroom"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java index 6303fbbd6..d81a2585f 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicOrchard.java +++ b/src/main/java/forestry/farming/logic/FarmLogicOrchard.java @@ -126,8 +126,8 @@ public class FarmLogicOrchard extends FarmLogic { } @Override - public String getName() { - return "Orchard"; + public String getUnlocalizedName() { + return "for.farm.orchard"; } private Collection getHarvestBlocks(World world, BlockPos position) { diff --git a/src/main/java/forestry/farming/logic/FarmLogicPeat.java b/src/main/java/forestry/farming/logic/FarmLogicPeat.java index 19565518f..53974db9a 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicPeat.java +++ b/src/main/java/forestry/farming/logic/FarmLogicPeat.java @@ -37,12 +37,8 @@ public class FarmLogicPeat extends FarmLogicWatered { } @Override - public String getName() { - if (isManual) { - return "Manual Peat Bog"; - } else { - return "Managed Peat Bog"; - } + public String getUnlocalizedName() { + return "for.farm.peat"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java b/src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java index 3d83cb94b..1db5bec0c 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRedOrchid.java @@ -29,11 +29,8 @@ public class FarmLogicRedOrchid extends FarmLogicHomogeneous { } @Override - public String getName() { - if (isManual) { - return "Manual Orchid Farm"; - } - return "Managed Orchid Farm"; + public String getUnlocalizedName() { + return "for.farm.orchid"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicReeds.java b/src/main/java/forestry/farming/logic/FarmLogicReeds.java index 4ddd5e6c3..7d87e7ce7 100644 --- a/src/main/java/forestry/farming/logic/FarmLogicReeds.java +++ b/src/main/java/forestry/farming/logic/FarmLogicReeds.java @@ -31,12 +31,8 @@ public class FarmLogicReeds extends FarmLogicSoil { } @Override - public String getName() { - if (isManual) { - return "Manual Reed Farm"; - } else { - return "Managed Reed Farm"; - } + public String getUnlocalizedName() { + return "for.farm.reed"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicRubber.java b/src/main/java/forestry/farming/logic/FarmLogicRubber.java index 6a220ffd2..efedb5fc9 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicRubber.java +++ b/src/main/java/forestry/farming/logic/FarmLogicRubber.java @@ -49,8 +49,8 @@ public class FarmLogicRubber extends FarmLogic { } @Override - public String getName() { - return "Rubber Plantation"; + public String getUnlocalizedName() { + return "for.farm.rubber"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java index c865ddaf4..a394b98b1 100755 --- a/src/main/java/forestry/farming/logic/FarmLogicSucculent.java +++ b/src/main/java/forestry/farming/logic/FarmLogicSucculent.java @@ -33,12 +33,8 @@ public class FarmLogicSucculent extends FarmLogicSoil { } @Override - public String getName() { - if (isManual) { - return "Manual Succulent Farm"; - } else { - return "Managed Succulent Farm"; - } + public String getUnlocalizedName() { + return "for.farm.succulent"; } @Override diff --git a/src/main/java/forestry/farming/logic/FarmProperties.java b/src/main/java/forestry/farming/logic/FarmProperties.java index 71393ed3e..f83d02774 100644 --- a/src/main/java/forestry/farming/logic/FarmProperties.java +++ b/src/main/java/forestry/farming/logic/FarmProperties.java @@ -40,7 +40,10 @@ public final class FarmProperties implements IFarmProperties { @Override public Collection getFarmables() { if (farmables == null) { - farmables = farmablesIdentifiers.stream().map(FarmRegistry.getInstance()::getFarmables).flatMap(Collection::stream).collect(Collectors.toSet()); + farmables = farmablesIdentifiers.stream() + .map(FarmRegistry.getInstance()::getFarmables) + .flatMap(Collection::stream) + .collect(Collectors.toSet()); } return farmables; } @@ -55,6 +58,7 @@ public final class FarmProperties implements IFarmProperties { soils.add(new Soil(resource, soilState, hasMetaData)); } + @Override public boolean isAcceptedSoil(IBlockState ground) { for (ISoil soil : soils) { IBlockState soilState = soil.getSoilState(); diff --git a/src/main/java/forestry/plugins/PluginExtraUtilities.java b/src/main/java/forestry/plugins/PluginExtraUtilities.java index 83405f1d5..78d5f6ac2 100644 --- a/src/main/java/forestry/plugins/PluginExtraUtilities.java +++ b/src/main/java/forestry/plugins/PluginExtraUtilities.java @@ -64,6 +64,7 @@ public class PluginExtraUtilities extends CompatPlugin { orchidFarm.registerSoil(new ItemStack(Blocks.LIT_REDSTONE_ORE), Blocks.LIT_REDSTONE_ORE.getDefaultState()); Circuits.farmOrchidManaged = new CircuitFarmLogic("managedOrchid", orchidFarm, false); + Circuits.farmOrchidManual = new CircuitFarmLogic("manualOrchid", orchidFarm, true); orchidStack = new ItemStack(item); } @@ -83,10 +84,12 @@ public class PluginExtraUtilities extends CompatPlugin { public void registerRecipes() { if(Circuits.farmOrchidManaged != null) { ICircuitLayout layoutManaged = ChipsetManager.circuitRegistry.getLayout("forestry.farms.managed"); - if(layoutManaged == null){ + ICircuitLayout layoutManual = ChipsetManager.circuitRegistry.getLayout("forestry.farms.manual"); + if(layoutManaged == null || layoutManual == null){ return; } ChipsetManager.solderManager.addRecipe(layoutManaged, ModuleCore.getItems().tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManaged); + ChipsetManager.solderManager.addRecipe(layoutManual, ModuleCore.getItems().tubes.get(EnumElectronTube.ORCHID, 1), Circuits.farmOrchidManual); } } From c5178be22524d94492bfefe5402dd9820372089c Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Mon, 22 Jan 2018 19:54:14 +0100 Subject: [PATCH 08/12] Add missing fluid handler capability to the planter --- .../cultivation/tiles/TilePlanter.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index 6da34f056..3f7eea655 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -16,13 +16,16 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3i; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.CapabilityFluidHandler; import forestry.api.core.EnumHumidity; import forestry.api.core.EnumTemperature; @@ -501,6 +504,21 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I return tankManager; } + + @Override + public boolean hasCapability(Capability capability, @Nullable EnumFacing facing) { + return capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY || super.hasCapability(capability, facing); + } + + @Override + @Nullable + public T getCapability(Capability capability, @Nullable EnumFacing facing) { + if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY) { + return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(getTankManager()); + } + return super.getCapability(capability, facing); + } + protected NonNullList createList(ItemStack... stacks){ return NonNullList.from(ItemStack.EMPTY, stacks); } From 207f15ed0bc378cd0ec43c2d3b804b0e4b737662 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Tue, 23 Jan 2018 15:29:30 +0100 Subject: [PATCH 09/12] Remove unneeded GL state changes --- .../forestry/cultivation/gui/widgets/GhostItemStackWidget.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java index f52d910b5..969f9d412 100644 --- a/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java +++ b/src/main/java/forestry/cultivation/gui/widgets/GhostItemStackWidget.java @@ -30,7 +30,6 @@ public class GhostItemStackWidget extends ItemStackWidget { if (!slot.getHasStack()) { super.draw(startX, startY); } - GlStateManager.pushMatrix(); GlStateManager.disableLighting(); GlStateManager.disableDepth(); GlStateManager.enableBlend(); @@ -50,7 +49,6 @@ public class GhostItemStackWidget extends ItemStackWidget { GlStateManager.disableBlend(); GlStateManager.enableDepth(); GlStateManager.enableLighting(); - GlStateManager.popMatrix(); } private String getDirectionString(){ From 3caf8cbfefcb5e470f2ada7cb754348a2b2382b0 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Tue, 23 Jan 2018 15:36:38 +0100 Subject: [PATCH 10/12] Update Lang --- lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lang b/lang index 4ee2f885f..39f488d0e 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 4ee2f885f8f6af1b3d498667bae4d59dbcd69551 +Subproject commit 39f488d0e3c3aa8960c61584885c99ad4c14b905 From 7679dfc3930c11c936b5b1f7950321fbe8a60575 Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Sun, 28 Jan 2018 18:38:29 +0100 Subject: [PATCH 11/12] Make cultivation farms more expensive --- lang | 2 +- src/main/java/forestry/core/config/Config.java | 2 ++ .../forestry/core/items/ItemRegistryCore.java | 2 ++ .../java/forestry/core/utils/OreDictUtil.java | 2 ++ .../forestry/cultivation/ModuleCultivation.java | 14 +++++++------- .../forestry/cultivation/tiles/TilePlanter.java | 4 ++-- .../java/forestry/factory/ModuleFactory.java | 8 +++++++- .../forestry/farming/gui/FarmLogicSlot.java | 16 +++++++++------- .../farming/multiblock/FarmController.java | 4 ++-- .../forestry/models/item/flexible_casing.json | 6 ++++++ .../forestry/textures/items/flexible_casing.png | Bin 0 -> 408 bytes 11 files changed, 40 insertions(+), 20 deletions(-) create mode 100644 src/main/resources/assets/forestry/models/item/flexible_casing.json create mode 100644 src/main/resources/assets/forestry/textures/items/flexible_casing.png diff --git a/lang b/lang index 39f488d0e..c560d5270 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 39f488d0e3c3aa8960c61584885c99ad4c14b905 +Subproject commit c560d52707b3976bbe51c4ba7c3d26fdb947ce75 diff --git a/src/main/java/forestry/core/config/Config.java b/src/main/java/forestry/core/config/Config.java index 303aba09d..a487c3352 100755 --- a/src/main/java/forestry/core/config/Config.java +++ b/src/main/java/forestry/core/config/Config.java @@ -99,6 +99,7 @@ public class Config { // Farm public static int farmSize = 2; + public static float fertilizerModifier = 1.0F; public static boolean squareFarms = false; private static boolean enableExUtilEnderLily = true; private static boolean enableExUtilRedOrchid = true; @@ -275,6 +276,7 @@ public class Config { } farmSize = configCommon.getIntLocalized("tweaks.farms", "size", farmSize, 1, 3); + fertilizerModifier = configCommon.getFloatLocalized("tweaks.farms", "fertilizer", fertilizerModifier, 0.1F, 5.0F); squareFarms = configCommon.getBooleanLocalized("tweaks.farms", "square", squareFarms); enableExUtilEnderLily = configCommon.getBooleanLocalized("tweaks.farms", "enderlily", enableExUtilEnderLily); enableExUtilRedOrchid = configCommon.getBooleanLocalized("tweaks.farms", "redorchid", enableExUtilRedOrchid); diff --git a/src/main/java/forestry/core/items/ItemRegistryCore.java b/src/main/java/forestry/core/items/ItemRegistryCore.java index cfc4381f5..2884fa8a7 100644 --- a/src/main/java/forestry/core/items/ItemRegistryCore.java +++ b/src/main/java/forestry/core/items/ItemRegistryCore.java @@ -55,6 +55,7 @@ public class ItemRegistryCore extends ItemRegistry { public final ItemForestry sturdyCasing; public final ItemForestry hardenedCasing; public final ItemForestry impregnatedCasing; + public final ItemForestry flexibleCasing; public final ItemStack gearBronze; public final ItemStack gearCopper; public final ItemStack gearTin; @@ -110,6 +111,7 @@ public class ItemRegistryCore extends ItemRegistry { sturdyCasing = registerItem(new ItemForestry(), "sturdy_machine"); hardenedCasing = registerItem(new ItemForestry(), "hardened_machine"); impregnatedCasing = registerItem(new ItemForestry(), "impregnated_casing"); + flexibleCasing = registerItem(new ItemForestry(), "flexible_casing"); craftingMaterial = registerItem(new ItemCraftingMaterial(), "crafting_material"); diff --git a/src/main/java/forestry/core/utils/OreDictUtil.java b/src/main/java/forestry/core/utils/OreDictUtil.java index bda0e0b6d..c427dd11d 100644 --- a/src/main/java/forestry/core/utils/OreDictUtil.java +++ b/src/main/java/forestry/core/utils/OreDictUtil.java @@ -78,4 +78,6 @@ public class OreDictUtil { public static final String DYE_YELLOW = "dyeYellow"; public static final String DYE_BLUE = "dyeBlue"; public static final String DYE_RED = "dyeRed"; + + public static final String SLIMEBALL = "slimeball"; } diff --git a/src/main/java/forestry/cultivation/ModuleCultivation.java b/src/main/java/forestry/cultivation/ModuleCultivation.java index a5e8d73f0..f1f9b492c 100644 --- a/src/main/java/forestry/cultivation/ModuleCultivation.java +++ b/src/main/java/forestry/cultivation/ModuleCultivation.java @@ -67,7 +67,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.GOLD, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_crops", blocks.farmCrops, @@ -76,7 +76,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.BRONZE, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("peat_bog", blocks.peatBog, @@ -85,7 +85,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.OBSIDIAN, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_mushroom", blocks.farmMushroom, @@ -94,7 +94,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.APATITE, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_gourd", blocks.farmGourd, @@ -103,7 +103,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.LAPIS, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_nether", blocks.farmNether, @@ -112,7 +112,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.BLAZE, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); RecipeUtil.addRecipe("farm_ender", blocks.farmEnder, @@ -121,7 +121,7 @@ public class ModuleCultivation extends BlankForestryModule { "GBG", 'G', OreDictUtil.BLOCK_GLASS, 'T', coreItems.tubes.get(EnumElectronTube.ENDER, 1), - 'C', coreItems.sturdyCasing, + 'C', coreItems.flexibleCasing, 'B', coreItems.circuitboards.get(EnumCircuitBoardType.BASIC)); for(BlockPlanter planter : getBlocks().getPlanters()){ diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index 3f7eea655..195076b2f 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -257,7 +257,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I } private boolean cullCrop(ICrop crop) { - final int fertilizerConsumption = logic.getFertilizerConsumption(); + final int fertilizerConsumption = (int)(logic.getFertilizerConsumption() * Config.fertilizerModifier * 2); IErrorLogic errorLogic = getErrorLogic(); @@ -314,7 +314,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I if (hasFarmland && !FarmHelper.isCycleCanceledByListeners(logic, farmSide, Collections.emptySet())) { final float hydrationModifier = hydrationManager.getHydrationModifier(); - final int fertilizerConsumption = logic.getFertilizerConsumption(); + final int fertilizerConsumption = (int)(logic.getFertilizerConsumption() * Config.fertilizerModifier * 2); final int liquidConsumption = logic.getWaterConsumption(hydrationModifier); final FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption); diff --git a/src/main/java/forestry/factory/ModuleFactory.java b/src/main/java/forestry/factory/ModuleFactory.java index 964e40f12..a5c2e25b6 100644 --- a/src/main/java/forestry/factory/ModuleFactory.java +++ b/src/main/java/forestry/factory/ModuleFactory.java @@ -328,7 +328,13 @@ public class ModuleFactory extends BlankForestryModule { "XXX", '#', new ItemStack(Items.REPEATER, 1, 0), 'X', new ItemStack(Blocks.REDSTONE_ORE, 1, 0)}); - + RecipeManagers.fabricatorManager.addRecipe(ItemStack.EMPTY, Fluids.GLASS.getFluid(500), coreItems.flexibleCasing.getItemStack(), new Object[]{ + "#E#", + "B B", + "#E#", + '#', OreDictUtil.INGOT_BRONZE, + 'B', OreDictUtil.SLIMEBALL, + 'E', "gemEmerald"}); String[] dyes = {"dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite"}; diff --git a/src/main/java/forestry/farming/gui/FarmLogicSlot.java b/src/main/java/forestry/farming/gui/FarmLogicSlot.java index 4e17be333..e86d2a830 100644 --- a/src/main/java/forestry/farming/gui/FarmLogicSlot.java +++ b/src/main/java/forestry/farming/gui/FarmLogicSlot.java @@ -10,17 +10,19 @@ ******************************************************************************/ package forestry.farming.gui; -import forestry.api.farming.FarmDirection; -import forestry.api.farming.IFarmLogic; -import forestry.core.gui.tooltips.ToolTip; -import forestry.core.gui.widgets.Widget; -import forestry.core.gui.widgets.WidgetManager; -import forestry.farming.multiblock.IFarmControllerInternal; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderItem; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.item.ItemStack; +import forestry.api.farming.FarmDirection; +import forestry.api.farming.IFarmLogic; +import forestry.core.config.Config; +import forestry.core.gui.tooltips.ToolTip; +import forestry.core.gui.widgets.Widget; +import forestry.core.gui.widgets.WidgetManager; +import forestry.farming.multiblock.IFarmControllerInternal; + public class FarmLogicSlot extends Widget { private final IFarmControllerInternal farmController; @@ -65,7 +67,7 @@ public class FarmLogicSlot extends Widget { public void refresh() { toolTip.clear(); toolTip.add(getLogic().getName()); - toolTip.add("Fertilizer: " + getLogic().getFertilizerConsumption()); + toolTip.add("Fertilizer: " + (int)(getLogic().getFertilizerConsumption() * Config.fertilizerModifier)); toolTip.add("Water: " + getLogic().getWaterConsumption(farmController.getFarmLedgerDelegate().getHydrationModifier())); } }; diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index 9ac70d73a..2634a69f6 100755 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -501,7 +501,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen if (hasFarmland && !FarmHelper.isCycleCanceledByListeners(logic, farmSide, farmListeners)) { final float hydrationModifier = hydrationManager.getHydrationModifier(); - final int fertilizerConsumption = logic.getFertilizerConsumption(); + final int fertilizerConsumption = (int)(logic.getFertilizerConsumption() * Config.fertilizerModifier); final int liquidConsumption = logic.getWaterConsumption(hydrationModifier); final FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption); @@ -558,7 +558,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } } - final int fertilizerConsumption = provider.getFertilizerConsumption(); + final int fertilizerConsumption = (int)(provider.getFertilizerConsumption() * Config.fertilizerModifier); IErrorLogic errorLogic = getErrorLogic(); diff --git a/src/main/resources/assets/forestry/models/item/flexible_casing.json b/src/main/resources/assets/forestry/models/item/flexible_casing.json new file mode 100644 index 000000000..48566c3b0 --- /dev/null +++ b/src/main/resources/assets/forestry/models/item/flexible_casing.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "forestry:items/flexible_casing" + } +} diff --git a/src/main/resources/assets/forestry/textures/items/flexible_casing.png b/src/main/resources/assets/forestry/textures/items/flexible_casing.png new file mode 100644 index 0000000000000000000000000000000000000000..1c0fcb15fa1bc2327056b3b348c4862a5ee292fe GIT binary patch literal 408 zcmV;J0cZY+P)PoA<66taLK z(WSO*3`~6s$bR4F=f}gsPP~7-&f@+0b+guToINlrBXxORlQ>(TpL!U(N$&m042h+} zYoHoqH=(V$b{$(yXluUL61Z5^dd9n?wo2*iD*b2~xrk7ojN_`zNw8k|hd>_>`0|_^F4u2+=o#DR2WvO4KW~ zHAh^8@KX=L@qoS=5F8KY9E|mj~AV3vHC!Gq;39z{?YtvAUR@qIv7Ye~(|dny7 Cqoz3k literal 0 HcmV?d00001 From 05d1eb87ce1132fb82e2c60d10324697ab2d44da Mon Sep 17 00:00:00 2001 From: Nedelosk Date: Sun, 28 Jan 2018 22:54:35 +0100 Subject: [PATCH 12/12] Round fertilizer values --- src/main/java/forestry/cultivation/tiles/TilePlanter.java | 4 ++-- src/main/java/forestry/farming/gui/FarmLogicSlot.java | 2 +- src/main/java/forestry/farming/multiblock/FarmController.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/forestry/cultivation/tiles/TilePlanter.java b/src/main/java/forestry/cultivation/tiles/TilePlanter.java index 195076b2f..51131edcc 100644 --- a/src/main/java/forestry/cultivation/tiles/TilePlanter.java +++ b/src/main/java/forestry/cultivation/tiles/TilePlanter.java @@ -257,7 +257,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I } private boolean cullCrop(ICrop crop) { - final int fertilizerConsumption = (int)(logic.getFertilizerConsumption() * Config.fertilizerModifier * 2); + final int fertilizerConsumption = Math.round(logic.getFertilizerConsumption() * Config.fertilizerModifier * 2); IErrorLogic errorLogic = getErrorLogic(); @@ -314,7 +314,7 @@ public abstract class TilePlanter extends TilePowered implements IFarmHousing, I if (hasFarmland && !FarmHelper.isCycleCanceledByListeners(logic, farmSide, Collections.emptySet())) { final float hydrationModifier = hydrationManager.getHydrationModifier(); - final int fertilizerConsumption = (int)(logic.getFertilizerConsumption() * Config.fertilizerModifier * 2); + final int fertilizerConsumption = Math.round(logic.getFertilizerConsumption() * Config.fertilizerModifier * 2); final int liquidConsumption = logic.getWaterConsumption(hydrationModifier); final FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption); diff --git a/src/main/java/forestry/farming/gui/FarmLogicSlot.java b/src/main/java/forestry/farming/gui/FarmLogicSlot.java index e86d2a830..0946a1ffc 100644 --- a/src/main/java/forestry/farming/gui/FarmLogicSlot.java +++ b/src/main/java/forestry/farming/gui/FarmLogicSlot.java @@ -67,7 +67,7 @@ public class FarmLogicSlot extends Widget { public void refresh() { toolTip.clear(); toolTip.add(getLogic().getName()); - toolTip.add("Fertilizer: " + (int)(getLogic().getFertilizerConsumption() * Config.fertilizerModifier)); + toolTip.add("Fertilizer: " + Math.round(getLogic().getFertilizerConsumption() * Config.fertilizerModifier)); toolTip.add("Water: " + getLogic().getWaterConsumption(farmController.getFarmLedgerDelegate().getHydrationModifier())); } }; diff --git a/src/main/java/forestry/farming/multiblock/FarmController.java b/src/main/java/forestry/farming/multiblock/FarmController.java index 2634a69f6..e9f899b58 100755 --- a/src/main/java/forestry/farming/multiblock/FarmController.java +++ b/src/main/java/forestry/farming/multiblock/FarmController.java @@ -501,7 +501,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen if (hasFarmland && !FarmHelper.isCycleCanceledByListeners(logic, farmSide, farmListeners)) { final float hydrationModifier = hydrationManager.getHydrationModifier(); - final int fertilizerConsumption = (int)(logic.getFertilizerConsumption() * Config.fertilizerModifier); + final int fertilizerConsumption = Math.round(logic.getFertilizerConsumption() * Config.fertilizerModifier); final int liquidConsumption = logic.getWaterConsumption(hydrationModifier); final FluidStack liquid = new FluidStack(FluidRegistry.WATER, liquidConsumption); @@ -558,7 +558,7 @@ public class FarmController extends RectangularMultiblockControllerBase implemen } } - final int fertilizerConsumption = (int)(provider.getFertilizerConsumption() * Config.fertilizerModifier); + final int fertilizerConsumption = Math.round(provider.getFertilizerConsumption() * Config.fertilizerModifier); IErrorLogic errorLogic = getErrorLogic();