Search in sources :

Example 1 with IGardeningManager

use of binnie.botany.api.gardening.IGardeningManager in project Binnie by ForestryMC.

the class ItemSoilMeter method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    Block block = worldIn.getBlockState(pos).getBlock();
    IGardeningManager gardening = BotanyCore.getGardening();
    if (!gardening.isSoil(block)) {
        pos = pos.down();
        block = worldIn.getBlockState(pos).getBlock();
    }
    if (!gardening.isSoil(block)) {
        pos = pos.down();
        block = worldIn.getBlockState(pos).getBlock();
    }
    if (gardening.isSoil(block) && worldIn.isRemote) {
        IBlockSoil soil = (IBlockSoil) block;
        String info = I18N.localise("botany.soil.type") + ": " + EnumHelper.getLocalisedName(soil.getType(worldIn, pos), true) + ", " + TextFormatting.WHITE + I18N.localise("botany.moisture") + ": " + EnumHelper.getLocalisedName(soil.getMoisture(worldIn, pos), true) + ", " + TextFormatting.WHITE + I18N.localise("botany.ph") + ": " + EnumHelper.getLocalisedName(soil.getPH(worldIn, pos), true);
        ITextComponent chat = new TextComponentString(info);
        player.sendStatusMessage(chat, false);
    }
    return EnumActionResult.SUCCESS;
}
Also used : IBlockSoil(binnie.botany.api.gardening.IBlockSoil) ITextComponent(net.minecraft.util.text.ITextComponent) Block(net.minecraft.block.Block) TextComponentString(net.minecraft.util.text.TextComponentString) IGardeningManager(binnie.botany.api.gardening.IGardeningManager) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with IGardeningManager

use of binnie.botany.api.gardening.IGardeningManager in project Binnie by ForestryMC.

the class ItemTrowel method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack stack = player.getHeldItem(hand);
    if (!player.canPlayerEdit(pos, facing, stack)) {
        return EnumActionResult.FAIL;
    }
    Block block = worldIn.getBlockState(pos).getBlock();
    if (facing == EnumFacing.DOWN || (!worldIn.isAirBlock(pos.up()) && ModuleManager.isModuleEnabled(Constants.BOTANY_MOD_ID, BotanyModuleUIDs.FLOWERS) && worldIn.getBlockState(pos.up()).getBlock() != ModuleFlowers.flower) || (block != Blocks.GRASS && block != Blocks.DIRT && block != Blocks.GRASS_PATH)) {
        return EnumActionResult.PASS;
    }
    worldIn.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
    if (worldIn.isRemote) {
        return EnumActionResult.SUCCESS;
    }
    IGardeningManager gardening = BotanyCore.getGardening();
    EnumMoisture moisture = gardening.getNaturalMoisture(worldIn, pos);
    EnumAcidity acidity = gardening.getNaturalPH(worldIn, pos);
    gardening.plantSoil(worldIn, pos, EnumSoilType.SOIL, moisture, acidity);
    stack.damageItem(1, player);
    return EnumActionResult.SUCCESS;
}
Also used : EnumMoisture(binnie.botany.api.gardening.EnumMoisture) EnumAcidity(binnie.botany.api.gardening.EnumAcidity) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) IGardeningManager(binnie.botany.api.gardening.IGardeningManager)

Example 3 with IGardeningManager

use of binnie.botany.api.gardening.IGardeningManager in project Binnie by ForestryMC.

the class ModuleGardening method doInit.

@Override
public void doInit() {
    RecipeUtil recipeUtil = new RecipeUtil(Constants.BOTANY_MOD_ID);
    IGardeningManager gardening = BotanyCore.getGardening();
    recipeUtil.addRecipe("trowel_wood", trowelWood, "d  ", " x ", "  s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "plankWood");
    recipeUtil.addRecipe("trowel_stone", trowelStone, "d  ", " x ", "  s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "cobblestone");
    recipeUtil.addRecipe("trowel_iron", trowelIron, "d  ", " x ", "  s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotIron");
    recipeUtil.addRecipe("trowel_gold", trowelGold, "d  ", " x ", "  s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "ingotGold");
    recipeUtil.addRecipe("trowel_diamond", trowelDiamond, "d  ", " x ", "  s", 'd', Blocks.DIRT, 's', "stickWood", 'x', "gemDiamond");
    recipeUtil.addRecipe("soil_meter", soilMeter, " gg", " rg", "i  ", 'g', "ingotGold", 'r', "dustRedstone", 'i', "ingotIron");
    recipeUtil.addShapelessRecipe("weed_killer", BotanyItems.WEEDKILLER.get(4), new ItemStack(Items.SPIDER_EYE), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS), new ItemStack(Items.WHEAT_SEEDS));
    recipeUtil.addShapelessRecipe("powder_ash", BotanyItems.POWDER_ASH.get(4), Mods.Forestry.stack("ash"));
    recipeUtil.addShapelessRecipe("powder_mulch", BotanyItems.POWDER_MULCH.get(4), Mods.Forestry.stack("mulch"));
    recipeUtil.addShapelessRecipe("powder_compost", BotanyItems.POWDER_COMPOST.get(4), Mods.Forestry.stack("fertilizer_bio"));
    recipeUtil.addShapelessRecipe("powder_fertilizer", BotanyItems.POWDER_FERTILISER.get(4), Mods.Forestry.stack("fertilizer_compound"));
    recipeUtil.addShapelessRecipe("powder_pulp", BotanyItems.POWDER_PULP.get(4), Mods.Forestry.stack("wood_pulp"));
    recipeUtil.addShapelessRecipe("pigment_black", BotanyItems.POWDER_SULPHUR.get(4), "dustSulphur");
    gardening.registerFertiliser(EnumFertiliserType.ACID, BotanyItems.POWDER_SULPHUR.get(1), 1);
    gardening.registerFertiliser(EnumFertiliserType.ACID, BotanyItems.POWDER_MULCH.get(1), 1);
    gardening.registerFertiliser(EnumFertiliserType.ACID, Mods.Forestry.stack("mulch"), 2);
    for (ItemStack stack : OreDictionary.getOres("dustSulfur")) {
        gardening.registerFertiliser(EnumFertiliserType.ACID, stack, 2);
    }
    gardening.registerFertiliser(EnumFertiliserType.ALKALINE, BotanyItems.POWDER_ASH.get(1), 1);
    gardening.registerFertiliser(EnumFertiliserType.ALKALINE, BotanyItems.POWDER_PULP.get(1), 1);
    gardening.registerFertiliser(EnumFertiliserType.ALKALINE, Mods.Forestry.stack("ash"), 2);
    gardening.registerFertiliser(EnumFertiliserType.ALKALINE, Mods.Forestry.stack("wood_pulp"), 2);
    gardening.registerFertiliser(EnumFertiliserType.NUTRIENT, BotanyItems.POWDER_COMPOST.get(1), 1);
    gardening.registerFertiliser(EnumFertiliserType.NUTRIENT, BotanyItems.POWDER_FERTILISER.get(1), 1);
    gardening.registerFertiliser(EnumFertiliserType.NUTRIENT, Mods.Forestry.stack("fertilizer_bio"), 2);
    gardening.registerFertiliser(EnumFertiliserType.NUTRIENT, Mods.Forestry.stack("fertilizer_compound"), 2);
    addFertiliserRecipes(recipeUtil);
}
Also used : ItemStack(net.minecraft.item.ItemStack) IGardeningManager(binnie.botany.api.gardening.IGardeningManager) RecipeUtil(binnie.core.util.RecipeUtil)

Example 4 with IGardeningManager

use of binnie.botany.api.gardening.IGardeningManager in project Binnie by ForestryMC.

the class ModuleGardening method onFertiliseSoil.

@SubscribeEvent
public void onFertiliseSoil(PlayerInteractEvent.RightClickBlock event) {
    World world = event.getWorld();
    if (world == null) {
        return;
    }
    BlockPos pos = event.getPos();
    EntityPlayer player = event.getEntityPlayer();
    if (player == null) {
        return;
    }
    ItemStack heldItem = player.getHeldItemMainhand();
    if (heldItem.isEmpty()) {
        return;
    }
    IGardeningManager gardening = BotanyCore.getGardening();
    Block block = world.getBlockState(event.getPos()).getBlock();
    if (!gardening.isSoil(block)) {
        pos = pos.down();
        block = world.getBlockState(pos).getBlock();
    }
    if (!gardening.isSoil(block)) {
        return;
    }
    IBlockSoil soil = (IBlockSoil) block;
    if (gardening.onFertiliseSoil(heldItem, soil, world, pos, player)) {
        return;
    }
    if (OreDictionaryUtil.hasOreName(heldItem, "weedkiller") && gardening.addWeedKiller(world, pos)) {
        if (!player.capabilities.isCreativeMode) {
            heldItem.shrink(1);
        }
    }
}
Also used : IBlockSoil(binnie.botany.api.gardening.IBlockSoil) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) IGardeningManager(binnie.botany.api.gardening.IGardeningManager) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with IGardeningManager

use of binnie.botany.api.gardening.IGardeningManager in project Binnie by ForestryMC.

the class ModuleGardening method onBonemeal.

@SubscribeEvent
public void onBonemeal(BonemealEvent event) {
    IGardeningManager gardening = BotanyCore.getGardening();
    BlockPos pos = event.getPos();
    Block block = event.getBlock().getBlock();
    if (gardening.isSoil(block)) {
        IBlockSoil soil = (IBlockSoil) block;
        if (soil.fertilise(event.getWorld(), pos, EnumSoilType.LOAM)) {
            event.setResult(Event.Result.ALLOW);
        }
    }
}
Also used : IBlockSoil(binnie.botany.api.gardening.IBlockSoil) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IGardeningManager(binnie.botany.api.gardening.IGardeningManager) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IGardeningManager (binnie.botany.api.gardening.IGardeningManager)9 ItemStack (net.minecraft.item.ItemStack)5 IBlockSoil (binnie.botany.api.gardening.IBlockSoil)4 Block (net.minecraft.block.Block)4 EnumAcidity (binnie.botany.api.gardening.EnumAcidity)3 BlockPos (net.minecraft.util.math.BlockPos)3 EnumMoisture (binnie.botany.api.gardening.EnumMoisture)2 EnumSoilType (binnie.botany.api.gardening.EnumSoilType)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumFertiliserType (binnie.botany.api.gardening.EnumFertiliserType)1 RecipeUtil (binnie.core.util.RecipeUtil)1 FarmDirection (forestry.api.farming.FarmDirection)1 Map (java.util.Map)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 World (net.minecraft.world.World)1