Posted August 27, 20205 yr 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.
August 27, 20205 yr 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.
August 27, 20205 yr it returns the new position. Through World.getBlockState(pos) you can get the blockstate, and then get the block from it.
August 27, 20205 yr Author @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?
August 27, 20205 yr The event is called LivingJumpEvent, it is triggered whenever a LivingEntity jumps. You can use instanceof syntax to check if the entity is player.
August 27, 20205 yr Author I tested it and the code tracks all entities, not just the player. How can I make LivingJumpEvent only track the player?
August 27, 20205 yr Put in a if statement checking if it is the player? On 8/27/2020 at 6:41 AM, 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.
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.