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;
}
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;
}
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);
}
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);
}
}
}
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);
}
}
}
Aggregations