use of binnie.botany.api.gardening.IBlockSoil in project Binnie by ForestryMC.
the class GardeningManager method addWeedKiller.
@Override
public boolean addWeedKiller(World world, BlockPos pos) {
IBlockState oldState = world.getBlockState(pos);
if (!(oldState.getBlock() instanceof IBlockSoil)) {
return false;
}
EnumSoilType type = getSoilType(world, pos);
IBlockState newState = getSoil(type, true, oldState.getValue(BlockSoil.MOISTURE), oldState.getValue(BlockSoil.ACIDITY));
boolean done = world.setBlockState(pos, newState, 2);
if (done && BlockPlant.isWeed(world, pos.up())) {
world.setBlockToAir(pos.up());
}
return done;
}
use of binnie.botany.api.gardening.IBlockSoil 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.IBlockSoil 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.IBlockSoil 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);
}
}
}
use of binnie.botany.api.gardening.IBlockSoil in project Binnie by ForestryMC.
the class ModuleFlowers method onPlantVanilla.
@Deprecated
public void onPlantVanilla(PlayerInteractEvent.RightClickBlock event) {
BlockPos pos = event.getPos();
World world = event.getWorld();
EntityPlayer player = event.getEntityPlayer();
ItemStack heldItem = player.getHeldItemMainhand();
if (event.getWorld().isRemote) {
return;
}
if (heldItem.isEmpty()) {
return;
}
Block block = world.getBlockState(pos).getBlock();
int py = -1;
if (block instanceof IBlockSoil && (world.isAirBlock(pos.up()) || block.isReplaceable(world, pos))) {
py = 1;
}
if (py < 0) {
return;
}
IFlowerRoot flowerRoot = BotanyCore.getFlowerRoot();
IFlower flower = flowerRoot.getConversion(heldItem);
if (flower != null && flowerRoot.plant(world, pos.add(0, py, 0), flower, player.getGameProfile()) && !player.capabilities.isCreativeMode) {
heldItem.shrink(1);
}
}
Aggregations