Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to replace block with item right click


Recommended Posts

but i can show you the bear outline

@Override public InteractionResult useOn(UseOnContext pContext)

{ if(pContext.getLevel().isClientSide()) {

BlockPos positionClicked = pContext.getClickedPos();

Player player = pContext.getPlayer();

here is supposed to be where i put the placement code after i grab all needed coords but i cant find the right command

pContext.getItemInHand().hurtAndBreak(1, pContext.getPlayer(), (player) -> player.broadcastBreakEvent(player.getUsedItemHand()));

return super.useOn(pContext); }

Link to comment
Share on other sites

but i can show you the bear outline

@Override public InteractionResult useOn(UseOnContext pContext)

{ if(pContext.getLevel().isClientSide()) {

BlockPos positionClicked = pContext.getClickedPos();

Player player = pContext.getPlayer();

here is supposed to be where i put the placement code after i grab all needed coords but i cant find the right command

pContext.getItemInHand().hurtAndBreak(1, pContext.getPlayer(), (Player) -> player.broadcastBreakEvent(player.getUsedItemHand()));

return super.useOn(pContext); }

Player needed a capital P

 

Link to comment
Share on other sites

public class fluorite_dropper extends Item

{ public fluorite_dropper(Properties pProperties) { super(pProperties); } @Override public InteractionResult useOn(UseOnContext pContext)

{ if(pContext.getLevel().isClientSide()) { BlockPos positionClicked = pContext.getClickedPos(); Player player = pContext.getPlayer();

Level#setBlock

pContext.getItemInHand().hurtAndBreak(1, pContext.getPlayer(), (Player) -> player.broadcastBreakEvent(player.getUsedItemHand()));

return super.useOn(pContext); }

return null; }

}

Exactly what i tried i never works this is everything i could collect of my attempts i just need the command that replaces blocks

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.