Jump to content

Identify block next to player 1.16


BliX5

Recommended Posts

New to modding, and I'm trying to make a climbing feature, so if you jump next to a certain block, you'll start climbing. The problem is: I don't know how to identify a block next to a player, only directly under. Any help would be appreciated. Thanks in advance.

Link to comment
Share on other sites

The player has a Position value. Use it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

@Mod.EventBusSubscriber(modid = main.MOD_ID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
public class ModClientEvents {

    @SubscribeEvent
    public static void onJumpNearStone(LivingEvent.LivingJumpEvent event) {
        LivingEntity player = event.getEntityLiving();
        World world = player.getEntityWorld();
        BlockPos pos = player.func_233580_cy_();
        if (world.getBlockState(pos.add(1, 0, 0)).getBlock() == Blocks.STONE)  {
            main.LOGGER.info(pos.add(1, 0, 0));
        } else if (world.getBlockState(pos.add(-1, 0, 0)).getBlock() == Blocks.STONE) {
            main.LOGGER.info(pos.add(-1, 0, 0));
        } else if (world.getBlockState(pos.add(0, 0, 1)).getBlock() == Blocks.STONE) {
            main.LOGGER.info(pos.add(0, 0, 1));
        } else if (world.getBlockState(pos.add(0, 0, -1)).getBlock() == Blocks.STONE) {
            main.LOGGER.info(pos.add(0, 0, -1));
        }
    }
}

It's probably very inefficient, but it works (mostly). My only problem is I must've messed up some code with the player, so instead of tracking only the player, it tracks every entity. I noticed this when I kept getting random messages when I wasn't jumping, but turning off mob spawning fixed the issue. Help?

Link to comment
Share on other sites

Put in a if statement checking if it is the player?

8 hours ago, poopoodice said:

The event is called LivingJumpEvent, it is triggered whenever a LivingEntity jumps. You can use instanceof syntax to check if the entity is player.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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
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.