I had this in 1.7.10, with no errors Until in 1.8 they removed the world.setblock
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world,
EntityPlayer entityPlayer) {
if(entityPlayer.capabilities.isCreativeMode||entityPlayer.inventory.consumeInventoryItem(Items.sugar))
{
//play sound stuff com.example.examplemod.SoundHandler.onEntityPlay("fizz", Event.player.worldObj, Event.player, 1, 1);
if (!world.isClient)
{
Vec3 look = entityPlayer.getLookVec();
world.setBlock((int) (entityPlayer.posX + look.xCoord * 5),
(int) (entityPlayer.posY + look.yCoord * 5),
(int) (entityPlayer.posZ + look.zCoord * 5),
Block.getBlockById(79));
}
}
return itemStack;
}
Now, how do i set a block in 1.8 in the direction the player is facing and if a block is in the way replace it with packed ice. Also how do i play a sound each time the left click is clicked
In 1.8 you use BlockState instead of setblock.
// Get the reference to the block we want to place
Block blk = Blocks.furnace;
// Make a position.
BlockPos pos0 = new BlockPos(pos.getX()+1, (pos.getY()+1) , pos.getZ());
// Get the default state(basically metadata 0)
IBlockState state0=blk.getDefaultState();
// set the block
world.setBlockState(pos0, state0);
I suggest you do some reading up on blockstates.
You should listen to PlayerInteractEvent for your sound playing. There are several ways to play sounds, so you just have to google which method you want to use.
@SubscribeEvent
public void playerdidsomething(PlayerInteractEvent event)
{
}