diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java index 7409da07e..3dbbdc646 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -209,7 +209,7 @@ public final class InitBooklet{ new BookletChapter("rangedCollector", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockRangedCollector), new PageTextOnly(1).addTextReplacement("", TileEntityRangedCollector.RANGE), new PageCrafting(2, BlockCrafting.recipeRangedCollector).setNoText()); //RF Using Blocks - new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant(); + new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemToPage(new ItemStack(InitItems.itemCanolaSeed)), new PagePicture(3, "page_farmer_cactus", 105).addItemToPage(new ItemStack(Blocks.CACTUS)), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant(); new BookletChapter("fireworkBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFireworkBox), new PageTextOnly(1).addTextReplacement("", TileEntityFireworkBox.USE_PER_SHOT), new PageCrafting(2, BlockCrafting.recipeFireworkBox)).setSpecial(); new BookletChapter("miner", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockMiner), new PageTextOnly(1).addTextReplacement("", TileEntityMiner.ENERGY_USE_PER_BLOCK).addTextReplacement("", TileEntityMiner.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipeMiner)).setSpecial(); new BookletChapterCoffee("coffeeMachine", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).addItemToPage(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).addItemToPage(new ItemStack(InitItems.itemCoffee)), new PagePicture(3, "page_coffee_machine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setWildcard().setNoText(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java index e5e19fba7..514e31a87 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; +import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.CactusFarmerBehavior; import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.init.Blocks; @@ -41,6 +42,7 @@ public final class InitCrafting{ ActuallyAdditionsAPI.addOilGenRecipe(InitFluids.fluidEmpoweredOil.getName(), 80, 600); ActuallyAdditionsAPI.addFarmerBehavior(new DefaultFarmerBehavior()); + ActuallyAdditionsAPI.addFarmerBehavior(new CactusFarmerBehavior()); RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShaped", RecipeKeepDataShaped.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped"); RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShapeless", RecipeKeepDataShapeless.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java new file mode 100644 index 000000000..28b5151dd --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/CactusFarmerBehavior.java @@ -0,0 +1,78 @@ +/* + * This file ("CactusFarmerBehavior.java") is part of the Actually Additions mod for Minecraft. + * It is created and owned by Ellpeck and distributed + * under the Actually Additions License to be found at + * http://ellpeck.de/actaddlicense + * View the source code at https://github.com/Ellpeck/ActuallyAdditions + * + * © 2015-2016 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer; + +import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; +import de.ellpeck.actuallyadditions.api.internal.IFarmer; +import net.minecraft.block.Block; +import net.minecraft.block.BlockCactus; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.List; + +public class CactusFarmerBehavior implements IFarmerBehavior{ + + @Override + public boolean tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){ + int use = 250; + if(farmer.getEnergy() >= use){ + Item item = seed.getItem(); + if(item instanceof ItemBlock){ + Block block = Block.getBlockFromItem(item); + if(block instanceof BlockCactus && block.canPlaceBlockAt(world, pos)){ + IBlockState state = block.getDefaultState(); + world.setBlockState(pos, state, 2); + world.playEvent(2001, pos, Block.getStateId(state)); + + farmer.extractEnergy(use); + return true; + } + } + } + return false; + } + + @Override + public boolean tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){ + int use = 250; + if(farmer.getEnergy() >= use){ + IBlockState state = world.getBlockState(pos); + if(state.getBlock() instanceof BlockCactus){ + for(int i = 2; i >= 1; i--){ + if(farmer.getEnergy() >= use){ + BlockPos up = pos.up(i); + IBlockState upState = world.getBlockState(up); + if(upState.getBlock() instanceof BlockCactus){ + List drops = upState.getBlock().getDrops(world, up, upState, 0); + + if(drops != null && !drops.isEmpty()){ + if(farmer.addToOutputInventory(drops, false)){ + world.playEvent(2001, up, Block.getStateId(upState)); + world.setBlockToAir(up); + + farmer.extractEnergy(use); + farmer.addToOutputInventory(drops, true); + } + } + } + } + } + return true; + } + } + return false; + } +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 30eec6733..2def4c9b7 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -1080,7 +1080,9 @@ booklet.actuallyadditions.chapter.bioReactor.name=Bio Reactor booklet.actuallyadditions.chapter.bioReactor.text.1=The Bio Reactor uses all types of seeds, foodstuffs and plants to generate CF! To do this, just place the items in its GUI. If you try this out, you will notice that it doesn't generate that much power by default. However, the more different kinds of plants, seeds and foodstuffs it has, the more power it will generate! booklet.actuallyadditions.chapter.farmer.name=Farmer -booklet.actuallyadditions.chapter.farmer.text.1=The Farmer is a block that can, once placed in the world, plant and harvest crops like Wheat, Potatoes, Canola and more. The left side of its GUI is reserved for seeds, while the right side will contain the harvested goods. It will farm in a 9x9 area in front of it. For every operation, it uses CF. my fam +booklet.actuallyadditions.chapter.farmer.text.1=The Farmer is a block that can, once placed in the world, plant and harvest different types of crops and other plants which can all be seen on the following pages. The left side of its GUI is reserved for seeds and other things that should be planted, while the right side will contain the harvested goods. It will farm in a 9x9 area in front of it. It uses varying amounts of CF per operation. my fam +booklet.actuallyadditions.chapter.farmer.text.2=Farming basic crops crops like Wheat, Potatoes, Canola, Flax and so on. Ground will be tilled by the Farmer itself. +booklet.actuallyadditions.chapter.farmer.text.3=Farming Cactus. Sand needs to be laid out for it to be planted. Cactus higher than 2 blocks will have the top broken off and placed inside of the Farmer. booklet.actuallyadditions.chapter.lensMoreDeath.name=Lens of the Killer booklet.actuallyadditions.chapter.lensMoreDeath.text.1=The Lens of the Killer works much like the Lens of Certain Death, however it will also drop experience and player-kill loot. This means, however, that it will use a lot more power. To pick up the experience it drops, you might want to try an Experience Solidifier. diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_cactus.png b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_cactus.png new file mode 100644 index 000000000..ba3d59557 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_cactus.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_crops.png b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_crops.png new file mode 100644 index 000000000..3ab99b52f Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_crops.png differ