Posted November 29, 20213 yr Hello, I know I've been quite active here lately and I promise I'll get out of your hair once i can work out this final thing. Essentially I'm looking for a way to get the player's Position on a specific axis and use its value in an if statement. I've experimented with classes vec3 and vec3i as the method getY() seemed promising, but i didn't know how to use it with the player and I had issues with the method being non-static. Any help would be appreciated.
November 29, 20213 yr Author @SubscribeEvent public void whenGameMusicPlays(final PlaySoundEvent event) { if (event.getName().equals("music.game") && ) { ResourceLocation loc = new ResourceLocation(CaveMusic.MODID + ":" + "music.overworld.underground"); SimpleSoundInstance MyPSR = new SimpleSoundInstance( loc, SoundSource.MUSIC, 1.0f, 1.0f, false, 0, SoundInstance.Attenuation.NONE, 0.0D, 0.0D, 0.0D, true); event.setResultSound(MyPSR); essentially i tried a few combinations of vec3i, vec3, Player and getY() after the &&. I was essentially throwing spaghetti at the wall because i didn't know what i needed to use in 1.17.1. I want to be able to test if player's position on the Y axis is less than a certain value. I'm really sorry if this is a stupid question.
November 30, 20213 yr you can get a Player in client Events via Minecraft.getInstance().player Note: this only works in client Events
November 30, 20213 yr Author 6 hours ago, Luis_ST said: you can get a Player in client Events via Minecraft.getInstance().player Note: this only works in client Events doing minecraft.getinstance().player.position().y shows a warning of Resource leak: '<unassigned Closeable value>' is not closed at this location. What does getinstance.player actually do?
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.