Posted September 11, 201411 yr I am trying to make a Item that can plant seeds next to it in the hot bar in a #x# area. The issue is I need to some how find out if the item is plantable if so plant it in a #x# area
September 11, 201411 yr canPlaceBlockAt should auto detect if allowed to be planted Check out my blog! http://www.whov.altervista.org
September 13, 201411 yr Author Sorry I worded that bad, I can't figure how when I right click with my item have it plant the seed that is next to it in the hot bar in a area around me. The area bit I can do, and I can get what Item is next to mine in the hot bar.
September 13, 201411 yr @Override public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if(side!=1 || world.getBlock(x, y, z) != Blocks.farmland)return false; if(world.isRemote)return true; int radius = 3; for(int x2 = -radius; x2<=radius; x2++) for(int z2 = -radius; z2<=radius; z2++) if(player.canPlayerEdit(x+x2, y, z+z2, side, is) && world.getBlock(x+x2, y+1, z+z2).getMaterial().isReplaceable() && world.getBlock(x+x2, y, z+z2) == Blocks.farmland) world.setBlock(x+x2, y+1, z+z2, Blocks.wheat, 0, 3); return true; }
September 13, 201411 yr Author That would work for vanilla only, I am wanting it to work with other mods aswell.
September 13, 201411 yr @Override public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { ItemStack next = player.inventory.currentItem+1 < player.inventory.getSizeInventory() ? player.inventory.getStackInSlot(player.inventory.currentItem+1) : null; if(side!=1 || !(next!=null && next.getItem() instanceof IPlantable))return false; int radius = 3; for(int x2 = -radius; x2<=radius; x2++) for(int z2 = -radius; z2<=radius; z2++){ if(next.stackSize>0)next.getItem().onItemUse(next, player, world, x+x2, y, z+z2, side, hitX, hitY, hitZ); if(next.stackSize<=0)player.inventory.setInventorySlotContents(player.inventory.currentItem+1, null); } return true; } I think it works.
September 13, 201411 yr Author Ahh I see thanks!, didn't know you could use "getItem().onItemUse" like that with other items. That was what I was missing.
September 14, 201411 yr You have to be specific about "next to" when you talk about the hot bar, there is "to the left side" and "to the right side". Either check both sides or require a specific side for the seeds to be on. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.