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 06c219d14..652b6a839 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/InitBooklet.java @@ -221,7 +221,7 @@ public final class InitBooklet{ //RF Using Blocks 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("batteryBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockBatteryBox), new PageTextOnly(1), new PageCrafting(2, BlockCrafting.recipeBatteryBox).setNoText()).setSpecial(); - new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemsToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemsToPage(new ItemStack(InitItems.itemCanolaSeed)), new PagePicture(3, "page_farmer_cactus", 105).addItemsToPage(new ItemStack(Blocks.CACTUS)), new PagePicture(4, "page_farmer_wart", 95).addItemsToPage(new ItemStack(Items.NETHER_WART)), new PagePicture(5, "page_farmer_reeds", 105).addItemsToPage(new ItemStack(Items.REEDS)), new PagePicture(6, "page_farmer_melons", 105).addItemsToPage(new ItemStack(Items.MELON), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK)), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant(); + new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1), new PagePicture(2, "page_farmer_crops", 95).addItemsToPage(new ItemStack(Items.WHEAT_SEEDS)).addItemsToPage(new ItemStack(InitItems.itemCanolaSeed)), new PagePicture(3, "page_farmer_cactus", 105).addItemsToPage(new ItemStack(Blocks.CACTUS)), new PagePicture(4, "page_farmer_wart", 95).addItemsToPage(new ItemStack(Items.NETHER_WART)), new PagePicture(5, "page_farmer_reeds", 105).addItemsToPage(new ItemStack(Items.REEDS)), new PagePicture(6, "page_farmer_melons", 105).addItemsToPage(new ItemStack(Items.MELON), new ItemStack(Blocks.PUMPKIN), new ItemStack(Blocks.MELON_BLOCK)), new PagePicture(7, "page_farmer_enderlilly", 105), new PagePicture(8, "page_farmer_redorchid", 105), new PageCrafting(4, BlockCrafting.recipeFarmer).setWildcard().setNoText()).setImportant(); 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).addItemsToPage(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).addItemsToPage(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(); new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("", TileEntityGrinder.ENERGY_USE), new PageCrafting(2, BlockCrafting.recipeCrusher).setWildcard().setNoText(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setWildcard().setNoText(), new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText()); 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 5df9091ce..57b6adbd1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/crafting/InitCrafting.java @@ -15,6 +15,8 @@ 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.*; +import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu.EnderlillyFarmerBehavior; +import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu.RedOrchidFarmerBehavior; import de.ellpeck.actuallyadditions.mod.util.ModUtil; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -45,6 +47,8 @@ public final class InitCrafting{ ActuallyAdditionsAPI.addFarmerBehavior(new NetherWartFarmerBehavior()); ActuallyAdditionsAPI.addFarmerBehavior(new ReedFarmerBehavior()); ActuallyAdditionsAPI.addFarmerBehavior(new MelonPumpkinFarmerBehavior()); + ActuallyAdditionsAPI.addFarmerBehavior(new EnderlillyFarmerBehavior()); + ActuallyAdditionsAPI.addFarmerBehavior(new RedOrchidFarmerBehavior()); 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/exu/EnderlillyFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java new file mode 100644 index 000000000..14540eeca --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/EnderlillyFarmerBehavior.java @@ -0,0 +1,34 @@ +/* + * This file ("EnderlillyFarmerBehavior.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-2017 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockDirt; +import net.minecraft.block.BlockGrass; +import net.minecraft.init.Blocks; + +public class EnderlillyFarmerBehavior extends ExUPlantFarmerBehavior{ + + @Override + protected String getPlantName(){ + return "extrautils2:enderlilly"; + } + + @Override + protected boolean canPlaceOn(Block block){ + return block == Blocks.END_STONE || block instanceof BlockDirt || block instanceof BlockGrass; + } + + @Override + protected int getMaxStage(){ + return 7; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java new file mode 100644 index 000000000..e03e92af2 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/ExUPlantFarmerBehavior.java @@ -0,0 +1,121 @@ +/* + * This file ("ExUPlantFarmerBehavior.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-2017 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; + +import de.ellpeck.actuallyadditions.api.farmer.FarmerResult; +import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior; +import de.ellpeck.actuallyadditions.api.internal.IFarmer; +import de.ellpeck.actuallyadditions.mod.util.StackUtil; +import net.minecraft.block.Block; +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.ResourceLocation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import java.util.List; + +public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{ + + @Override + public FarmerResult tryPlantSeed(ItemStack seed, World world, BlockPos pos, IFarmer farmer){ + int use = 600; + if(farmer.getEnergy() >= use){ + if(StackUtil.isValid(seed)){ + Item item = seed.getItem(); + ResourceLocation reg = item.getRegistryName(); + + if(reg != null && this.getPlantName().equals(reg.toString())){ + if(item instanceof ItemBlock){ + Block block = ((ItemBlock)item).getBlock(); + if(block != null){ + IBlockState stateThere = world.getBlockState(pos); + Block blockThere = stateThere.getBlock(); + + if(world.isAirBlock(pos) || blockThere.isReplaceable(world, pos)){ + BlockPos posBelow = pos.down(); + IBlockState stateBelow = world.getBlockState(posBelow); + + if(this.canPlaceOn(stateBelow.getBlock())){ + world.setBlockState(pos, block.getDefaultState(), 2); + farmer.extractEnergy(use); + + return FarmerResult.SUCCESS; + } + } + + return FarmerResult.STOP_PROCESSING; + } + } + } + } + } + return FarmerResult.FAIL; + } + + @Override + public FarmerResult tryHarvestPlant(World world, BlockPos pos, IFarmer farmer){ + int use = 600; + if(farmer.getEnergy() >= use){ + IBlockState state = world.getBlockState(pos); + Block block = state.getBlock(); + ResourceLocation reg = block.getRegistryName(); + + if(reg != null && this.getPlantName().equals(reg.toString())){ + if(block.getMetaFromState(state) >= this.getMaxStage()){ + List drops = block.getDrops(world, pos, state, 0); + + for(ItemStack stack : drops){ + if(StackUtil.isValid(stack)){ + ResourceLocation itemReg = stack.getItem().getRegistryName(); + if(itemReg != null && this.getPlantName().equals(itemReg.toString())){ + if(StackUtil.getStackSize(stack) <= 1){ + drops.remove(stack); + break; + } + else{ + StackUtil.addStackSize(stack, -1); + } + } + } + } + + if(farmer.addToOutputInventory(drops, false)){ + farmer.addToOutputInventory(drops, true); + + world.playEvent(2001, pos, Block.getStateId(state)); + world.setBlockState(pos, block.getDefaultState(), 2); + + farmer.extractEnergy(use); + + return FarmerResult.SUCCESS; + } + } + + return FarmerResult.STOP_PROCESSING; + } + } + return FarmerResult.FAIL; + } + + @Override + public int getPriority(){ + return 10; + } + + protected abstract String getPlantName(); + + protected abstract boolean canPlaceOn(Block block); + + protected abstract int getMaxStage(); +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java new file mode 100644 index 000000000..3bbd29115 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/apiimpl/farmer/exu/RedOrchidFarmerBehavior.java @@ -0,0 +1,32 @@ +/* + * This file ("RedOrchidFarmerBehavior.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-2017 Ellpeck + */ + +package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockRedstoneOre; + +public class RedOrchidFarmerBehavior extends ExUPlantFarmerBehavior{ + + @Override + protected String getPlantName(){ + return "extrautils2:redorchid"; + } + + @Override + protected boolean canPlaceOn(Block block){ + return block instanceof BlockRedstoneOre; + } + + @Override + protected int getMaxStage(){ + return 6; + } +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index 87844ae62..82feecea4 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -1205,6 +1205,8 @@ booklet.actuallyadditions.chapter.farmer.text.3=Farming Cactus. Sand ne booklet.actuallyadditions.chapter.farmer.text.4=Farming Nether Wart. Soul Sand needs to be laid out for it to be planted. booklet.actuallyadditions.chapter.farmer.text.5=Farming Sugar Cane. Sand and water need to be laid out for it to be planted. Harvested in the same way as Cactus. booklet.actuallyadditions.chapter.farmer.text.6=Farming Melons and Pumpkins. There will be checkerboarded air spaces left out inbetween the seeds for them to grow. +booklet.actuallyadditions.chapter.farmer.text.7=Farming Ender Lillies from Extra Utilities 2. They need to be placed on End Stone, Grass or Dirt. +booklet.actuallyadditions.chapter.farmer.text.8=Farming Red Orchids from Extra Utilities 2. They need to be placed on Redstone Ore. 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_enderlilly.png b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_enderlilly.png new file mode 100644 index 000000000..8890e5da9 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_enderlilly.png differ diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_redorchid.png b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_redorchid.png new file mode 100644 index 000000000..f9ca2a243 Binary files /dev/null and b/src/main/resources/assets/actuallyadditions/textures/gui/booklet/page_farmer_redorchid.png differ