blu1980 Posted June 17, 2022 Share Posted June 17, 2022 (edited) 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, 2022 by blu1980 Solved Quote Link to comment Share on other sites More sharing options...
loordgek Posted June 17, 2022 Share Posted June 17, 2022 you are running your code client side Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted June 17, 2022 Share Posted June 17, 2022 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) Quote Link to comment Share on other sites More sharing options...
blu1980 Posted June 17, 2022 Author Share Posted June 17, 2022 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. Quote Link to comment Share on other sites More sharing options...
blu1980 Posted June 17, 2022 Author Share Posted June 17, 2022 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. Quote Link to comment Share on other sites More sharing options...
Luis_ST Posted June 17, 2022 Share Posted June 17, 2022 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 Quote Link to comment Share on other sites More sharing options...
blu1980 Posted June 17, 2022 Author Share Posted June 17, 2022 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.