Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to get player position on an axis in 1.17.1


llynxfyre
 Share

Recommended Posts

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. 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

13 minutes ago, llynxfyre said:

doing minecraft.getinstance().player.position().y shows a warning of Resource leak: '<unassigned Closeable value>' is not closed at this location.

This is Eclipse being broken.

13 minutes ago, llynxfyre said:

What does getinstance.player actually do?

It calls a method "getInstance" and then accesses the "player" field. Look up what a singleton is.

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Hi, I have enchantment named "Stun" that can be applied to weapon and that has 3 levels: Level 1 - 10% chance to stun mob for 1 sec Level 2 - 20% chance to stun mob for 2 secs Level 3 - 30% chance to stun mob for 3 secs Plan is to apply MobEffect named StunnedMobEffect on doPostAttack in enchantment. StunnedMobEffect should have variable duration based on the level of enchantment that was applied on weapon. I am trying to find an example on how to do the following: How can I set duration of effect dynamically? How can I track whether duration has expired? I have found these two methods that can be overriden:   public void applyEffectTick(LivingEntity pLivingEntity, int pAmplifier) { public boolean isDurationEffectTick(int pDuration, int pAmplifier) { But looking at the source code of MobEffect class, I can't figure out what pAmplifier is? Any hints / samples on this would be appreciated.          
    • 2022-01-22 07:41:00,800 main WARN Advanced terminal features are not available in this environment [07:41:00] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--gameDir, ., --launchTarget, fmlserver, --fml.forgeVersion, 36.2.23, --fml.mcpVersion, 20210115.111550, --fml.mcVersion, 1.16.5, --fml.forgeGroup, net.minecraftforge, nogui] [07:41:00] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 8.0.9+86+master.3cf110c starting: java version 17.0.2 by Oracle Corporation Exception in thread "main" java.lang.IllegalAccessError: class cpw.mods.modlauncher.SecureJarHandler (in unnamed module @0x7ff95560) cannot access class sun.security.util.ManifestEntryVerifier (in module java.base) because module java.base does not export sun.security.util to unnamed module @0x7ff95560         at cpw.mods.modlauncher.SecureJarHandler.lambda$static$1(SecureJarHandler.java:41)         at cpw.mods.modlauncher.api.LamdbaExceptionUtils.uncheck(LamdbaExceptionUtils.java:95)         at cpw.mods.modlauncher.SecureJarHandler.<clinit>(SecureJarHandler.java:41)         at cpw.mods.modlauncher.Launcher.lambda$new$6(Launcher.java:55)         at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:52)         at cpw.mods.modlauncher.api.TypesafeMap.computeIfAbsent(TypesafeMap.java:47)         at cpw.mods.modlauncher.Environment.computePropertyIfAbsent(Environment.java:62)         at cpw.mods.modlauncher.Launcher.<init>(Launcher.java:55)         at cpw.mods.modlauncher.Launcher.main(Launcher.java:66)         at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63)         at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60)         at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) i have the same how do i fix it  
    • Hi, I'm facing an issue that a custom datapack is always loaded before the mod's datapack. Means the users/players are not able to override mod's configurations/data at all. I've tried to alternate the order of datapack by using the /datapack commands, however the actual loading order does not change at all. (I can confirm that both datapacks are working as usual by disabling one of them at a time, the correspond data is loaded correctly), is it the mod's problem or...? Thanks.
    • I'm trying to play a custom modpack with a few dozen mods, but when I try to create a world it hits 100% and then crashes and I can't figure out why. Here's the crash log:  
    • I already created a github account to upload the debug logs but i dont know where to find them also when it disconnects it say something like io.netty.util.illegalreferencecountexception
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.