Can someone please help me on how to make my modded hoe or another item apply a bone meal effect on right click? Ive tried the bone meal code and i changed some things but it didn't work; no errors or anything just nothing happens when i right click.
if (!p_77648_2_.capabilities.isCreativeMode)
{
--p_77648_1_.stackSize;
}
}
return true;
}
}
return false;
}
}
public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_)
{
if (p_150919_1_ instanceof WorldServer)
return applyBonemeal(p_150919_0_, p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, FakePlayerFactory.getMinecraft((WorldServer)p_150919_1_));
return false;
}
public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_, EntityPlayer player)
{
Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_);
BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
if (!p_150919_1_.isRemote)
{
p_150919_0_.stackSize--;
}
return true;
}
if (block instanceof IGrowable)
{
IGrowable igrowable = (IGrowable)block;
if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote))
{
if (!p_150919_1_.isRemote)
{
if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_))
{
igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_);
}
--p_150919_0_.stackSize;
}
return true;
}
}
return false;
}
}
I even changed:
onItemUse to onRightClick
I even tried it with items instead of the hoe and nothing works....any ideas?
I still do not know what to change in order for it to work. Ive been trying to get this function to work for days and its killing me that i cant get it to work.
Can someone please help me on how to make my modded hoe or another item apply a bone meal effect on right click? Ive tried the bone meal code and i changed some things but it didn't work; no errors or anything just nothing happens when i right click.
if (!p_77648_2_.capabilities.isCreativeMode)
{
--p_77648_1_.stackSize;
}
}
return true;
}
}
return false;
}
}
public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_)
{
if (p_150919_1_ instanceof WorldServer)
return appItemUselyBonemeal(p_150919_0_, p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, FakePlayerFactory.getMinecraft((WorldServer)p_150919_1_));
return false;
}
public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_, EntityPlayer player)
{
Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_);
BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
if (!p_150919_1_.isRemote)
{
p_150919_0_.stackSize--;
}
return true;
}
if (block instanceof IGrowable)
{
IGrowable igrowable = (IGrowable)block;
if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote))
{
if (!p_150919_1_.isRemote)
{
if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_))
{
igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_);
}
--p_150919_0_.stackSize;
}
return true;
}
}
return false;
}
}
I even changed:
onItemUse to onRightClick
I even tried it with items instead of the hoe and nothing works....any ideas?
Change onItemUse back, it's the only event that can interface with blocks.
Can someone please help me on how to make my modded hoe or another item apply a bone meal effect on right click? Ive tried the bone meal code and i changed some things but it didn't work; no errors or anything just nothing happens when i right click.
package com.rudy.Item;
import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLog;
import net.minecraft.block.IGrowable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.FakePlayerFactory;
import net.minecraftforge.event.entity.player.BonemealEvent;
public class CHoe extends ItemHoe{
public CHoe(ToolMaterial p_i45343_1_) {
super(p_i45343_1_);
}
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_))
{
return false;
}
else
{
if (p_77648_1_.getItem() == ModItems.CHoe)
{
if (applyBonemeal(p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_2_))
{
if (!p_77648_3_.isRemote)
{
p_77648_3_.playAuxSFX(2005, p_77648_4_, p_77648_5_, p_77648_6_, 0);
}
return true;
}
}
else if (p_77648_1_.getItemDamage() == 3)
{
Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);
int i1 = p_77648_3_.getBlockMetadata(p_77648_4_, p_77648_5_, p_77648_6_);
if (block == Blocks.log && BlockLog.func_150165_c(i1) == 3)
{
if (p_77648_7_ == 0)
{
return false;
}
if (p_77648_7_ == 1)
{
return false;
}
if (p_77648_7_ == 2)
{
--p_77648_6_;
}
if (p_77648_7_ == 3)
{
++p_77648_6_;
}
if (p_77648_7_ == 4)
{
--p_77648_4_;
}
if (p_77648_7_ == 5)
{
++p_77648_4_;
}
if (p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_, p_77648_6_))
{
int j1 = Blocks.cocoa.onBlockPlaced(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, p_77648_9_, p_77648_10_, 0);
p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, Blocks.cocoa, j1, 2);
if (!p_77648_2_.capabilities.isCreativeMode)
{
--p_77648_1_.stackSize;
}
}
return true;
}
}
return false;
}
}
public static boolean func_150919_a(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_)
{
if (p_150919_1_ instanceof WorldServer)
return applyBonemeal(p_150919_0_, p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, FakePlayerFactory.getMinecraft((WorldServer)p_150919_1_));
return false;
}
public static boolean applyBonemeal(ItemStack p_150919_0_, World p_150919_1_, int p_150919_2_, int p_150919_3_, int p_150919_4_, EntityPlayer player)
{
Block block = p_150919_1_.getBlock(p_150919_2_, p_150919_3_, p_150919_4_);
BonemealEvent event = new BonemealEvent(player, p_150919_1_, block, p_150919_2_, p_150919_3_, p_150919_4_);
if (MinecraftForge.EVENT_BUS.post(event))
{
return false;
}
if (event.getResult() == Result.ALLOW)
{
if (!p_150919_1_.isRemote)
{
p_150919_0_.stackSize--;
}
return true;
}
if (block instanceof IGrowable)
{
IGrowable igrowable = (IGrowable)block;
if (igrowable.func_149851_a(p_150919_1_, p_150919_2_, p_150919_3_, p_150919_4_, p_150919_1_.isRemote))
{
if (!p_150919_1_.isRemote)
{
if (igrowable.func_149852_a(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_))
{
igrowable.func_149853_b(p_150919_1_, p_150919_1_.rand, p_150919_2_, p_150919_3_, p_150919_4_);
}
--p_150919_0_.stackSize;
}
return true;
}
}
return false;
}
}
I even changed:
onItemUse to onRightClick
I even tried it with items instead of the hoe and nothing works....any ideas?
When you copy Minecraft code, you can change stuff like:
ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_
to:
ItemStack itemStack, EntityPlayer player, World world
When you do that, you might be able to figure out what the code is actually doing, and then answer your own question
In Eclipse there is the Refactor/Rename, with a shortcut of Shift+Alt+r, when you select the variable name to refactor.
As your code looks now, I wouldn't make any guess as to what it is doing or not doing.
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
I still do not know what to change in order for it to work. Ive been trying to get this function to work for days and its killing me that i cant get it to work.
I cant figure it out
What can't you figure out?
How to rename variables in Eclipse?
[url=2482915-wip-arkcraft-survival-evolved-dinos-taming]
no i get that part. I dont get how to make the bone meal function work
Change onItemUse back, it's the only event that can interface with blocks.
I tried that first and it didnt work