Posted June 17, 20223 yr Here is the code I'm working on currently: @Override public void onArmorTick(ItemStack stack, Level level, Player player) { super.onArmorTick(stack, level, player); if(player.isOnGround() && !onGround) { onGround = true; if(Minecraft.getInstance().level != null) { List<Entity> entities = Utils.getEntities(Minecraft.getInstance().level, player.getBlockX(), player.getBlockZ(), 6); for(Entity e : entities) { if(!e.equals(player)) { e.hurtMarked = true; e.hurt(DamageSource.OUT_OF_WORLD, 5f); } } } } else { if(!player.isOnGround()) onGround = false; } } My problem is that I can't get e.hurt() to work properly. It doesn't seem to do anything in game. EDIT: It's working now, I mistakenly used the Minecraft class to get the client level instead of the level provided in the function parameters. oops. Edited June 17, 20223 yr by blu1980 Solved
June 17, 20223 yr 12 minutes ago, blu1980 said: Minecraft.getInstance().level != null this will crash on server, why did you use the client side level and not the given level (second parameter)
June 17, 20223 yr Author 11 minutes ago, loordgek said: you are running your code client side 4 minutes ago, Luis_ST said: this will crash on server, why did you use the client side level and not the given level (second parameter) Oh I see. So I need to run the code server side instead. How do I do that? Sorry if it's a stupid question, somewhat new to modding.
June 17, 20223 yr Author 7 minutes ago, blu1980 said: Oh I see. So I need to run the code server side instead. How do I do that? Sorry if it's a stupid question, somewhat new to modding. Wait nevermind you're right the level is literally the second parameter in the function declaration.
June 17, 20223 yr 15 minutes ago, blu1980 said: Oh I see. So I need to run the code server side instead. How do I do that? Sorry if it's a stupid question, somewhat new to modding. do not use the Minecraft class
June 17, 20223 yr Author Just now, Luis_ST said: do not use the Minecraft class Yes, I've removed that code and used the 'level' object that is passed into the function instead. Thanks!
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.