Posted April 23, 201510 yr I am working on an electricity mod where you have a copper wire item and I want it to place a copper wire block when you click. When I run it, all I get is the little item use animation that Minecraft has. Here is my onItemUse function from my copper wire class: @Override public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){ boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos); BlockPos blockpos1 = flag ? pos : pos.offset(side); System.out.println("Spawn that block!!!"); worldIn.setBlockState(blockpos1, ModBlocks.copper_wire_block.getDefaultState()); return false; } I am not even getting the "Spawn that block!!!" message in the console output. EDIT: Full code below: Copper wire item class: package com.hexhax.mod.items; import com.hexhax.mod.init.ModBlocks; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; public class CopperWire extends Item{ @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ){ boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos); BlockPos blockpos1 = flag ? pos : pos.offset(side); System.out.println("Spawn that block!!!"); worldIn.setBlockState(blockpos1, ModBlocks.copper_wire_block.getDefaultState()); return true; } @Override public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { return itemStackIn; } } Copper Wire Block Class: package com.pixelnectar.infinity.blocks; import com.pixelnectar.infinity.init.InfinityBlocks; import net.minecraft.block.Block; import net.minecraft.block.material.Material; public class CopperWireBlock extends Block{ public CopperWireBlock() { super(Material.circuits); } }
April 23, 201510 yr Author Hey, thanks for the quick response. I just tried that and it still doesn't do anything.
April 23, 201510 yr Maybe it's because your returning false. Minecraft says this in the javdocs: ... * @return Return true to prevent any further processing. */ I don't know if that has anything to do with it.
April 23, 201510 yr Author Unfortunately, that did not do anything either. Is there maybe some kind of config I have to do when I register my item? I have everything registered properly to be able to craft, view in my own creative tab, etc, but I might have missed something.
April 24, 201510 yr Show full code please. 1.7.10 is no longer supported by forge, you are on your own.
April 24, 201510 yr Author I have posted the full code for both my item class and my block class. If there is anything else I need to show, just let me know.
April 24, 201510 yr Unfortunately, that did not do anything either. Is there maybe some kind of config I have to do when I register my item? I have everything registered properly to be able to craft, view in my own creative tab, etc, but I might have missed something. You changed it to return false, correct? Maker of the Craft++ mod.
April 24, 201510 yr it is curios coz the mine works @Override public boolean onItemUse(ItemStack sierra, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { chat.chatda(playerIn, "onItemUse pos="+pos); System.out.println("onItemUse pos="+pos); setInttag(sierra, "bx0", pos.getX() ); setInttag(sierra, "by0", pos.getY() ); setInttag(sierra, "bz0", pos.getZ() ); setInttag(sierra, "bf0", side.getIndex()); return false; } and im returning false and i dont see anyting wrong whith your code
April 24, 201510 yr Look at how ItemReed does it, that's what string uses instead of the normal Item class. And if you didn't know, the string item when placed places tripwire.
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.