Jump to content

Recommended Posts

Posted

Hello,

I wanna make an enchantment, that allows player to break bocks in 3x3 area. However, I need to know, on which side of block is the player looking, when he breaks it. The problem is, that I'm using  BreakEvent and it seems to trigger when the block is already broken, so I can't get the side by Minecraft.getMinecraft().objectMouseOver.sideHit. Does anyone have an idea, how to solve this problem?

Posted

Hello,

I wanna make an enchantment, that allows player to break bocks in 3x3 radium. However, I need to know, on which side of block is the player looking, when he breaks it. The problem is, that I'm using  BreakEvent and it seems to trigger when the block is already broken, so I can't get the side by Minecraft.getMinecraft().objectMouseOver.sideHit. Does anyone have an idea, how to solve this problem?

The event gives you a player you shouldn't be using Minecraft.getMinecraft()... in most events anyways. Just use.

event.getPlayer().getHorizontalFacing().opposite(); // Gives you the face of the block. 

 

Edit: Side note "radium" is not a word, but I think you meant radius, which is not the proper word; what you meant is area.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

This didn't solve my problem. This only works horizontaly (west, east, south, north), but not verticaly (up, down). It also returns the direction the player is looking at, but not the side of the block he is looking at.

Posted

This didn't solve my problem. This only works horizontaly (west, east, south, north), but not verticaly (up, down). It also returns the direction the player is looking at, but not the side of the block he is looking at.

Idk if it is a clean way to do this, but I just used in Block#onBlockStartBreak:

if(world.isRemote) 
{
this.side = Minecraft.getMinecraft().objectMouseOver.sideHit;
}

Posted

This didn't solve my problem. This only works horizontaly (west, east, south, north), but not verticaly (up, down). It also returns the direction the player is looking at, but not the side of the block he is looking at.

Then you did not think hard enough about what I gave you. If it is North or South you will break the same blocks regardless, same with East and West. Then if it is neither of those it can only be up and down, which guess what will break the same blocks regardless.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Even if you're looking up or down it's one of that four directions. It' s basicly the direction the player is facing. And it' s not completely accurate. The side of block palyer is looking at may not be the same af the side player is facing.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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