Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How to check what dimension the player is in
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
Mew

How to check what dimension the player is in

By Mew, May 22, 2013 in Modder Support

  • Start new topic

Recommended Posts

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

I am trying to have a GUI show that only gets shown when the player enters the new dimension I have. I can find multiple places where the GUI shows for a split second then disappears, but is there an event, or a special way of tracking what dimension the player is in, and when he changes dimension?

 

-Mew


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

Bump. I really need to know!!! Is diesieben07 online to help?


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

endershadow    36

endershadow

endershadow    36

  • Dragon Slayer
  • endershadow
  • Forge Modder
  • 36
  • 535 posts
Posted May 22, 2013

you could get the worldObj from the player. so it would look i little like

player.worldObj.provider.dimensionId

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15995 posts
Posted May 22, 2013

you could get the worldObj from the player. so it would look i little like

player.worldObj.provider.dimensionId

 

Yup, I use this a lot actually. :P

Namely for packet sending (as I haven't figured out how to convert an EntityPlayer into a Player for use with sendPacketToPlayer, so I use sendPacketToNearby).


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.

Share this post


Link to post
Share on other sites

SanAndreasP    402

SanAndreasP

SanAndreasP    402

  • World Shaper
  • SanAndreasP
  • Forge Modder
  • 402
  • 1689 posts
Posted May 22, 2013

you could get the worldObj from the player. so it would look i little like

player.worldObj.provider.dimensionId

 

Yup, I use this a lot actually. :P

Namely for packet sending (as I haven't figured out how to convert an EntityPlayer into a Player for use with sendPacketToPlayer, so I use sendPacketToNearby).

 

You just cast the EntityPlayer to the Player: (Player)entityPlayer

like you would do it the other way around when receiving the packet: (EntityPlayer)player


Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

you could get the worldObj from the player. so it would look i little like

player.worldObj.provider.dimensionId

 

YAY!!!! Half of what I am looking for...

 

Now I know what to call to check if the player is in a certain dimension, but how do I know WHEN the player changes dimension? Thats what I really want to know :/


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

endershadow    36

endershadow

endershadow    36

  • Dragon Slayer
  • endershadow
  • Forge Modder
  • 36
  • 535 posts
Posted May 22, 2013

you could save the dimension in a variable, and then look at it again later and see if they are the same. I did something like that for my energy-esque network.

Share this post


Link to post
Share on other sites

mnn    76

mnn

mnn    76

  • Diamond Finder
  • mnn
  • Members
  • 76
  • 298 posts
Posted May 22, 2013

implement a class implementing IPlayerTracker (register it with GameRegistry.registerPlayerTracker) and when a player changes dimension it will run onPlayerChangedDimension method in your class ;).


mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

implement a class implementing IPlayerTracker (register it with GameRegistry.registerPlayerTracker) and when a player changes dimension it will run onPlayerChangedDimension method in your class ;).

 

Hmm.. Ill retry with this new way of finding the players dimension...

I tried before and it didn't work :/

 

you could save the dimension in a variable, and then look at it again later and see if they are the same. I did something like that for my energy-esque network.

 

Not really needed I would think xD


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

mnn    76

mnn

mnn    76

  • Diamond Finder
  • mnn
  • Members
  • 76
  • 298 posts
Posted May 22, 2013

It's possible that it's only server-side. But you can easily implement a custom packet to trigger something on a client (if it's really server-side only).


mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

It's possible that it's only server-side. But you can easily implement a custom packet to trigger something on a client (if it's really server-side only).

 

Great. Now I have to create a Packet system for an otherwise simple test.... Haha, nothings ever as simple as it seems to be xD


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

Draco18s    2414

Draco18s

Draco18s    2414

  • Reality Controller
  • Draco18s
  • Members
  • 2414
  • 15995 posts
Posted May 22, 2013

Apparently I'm not allowed to reply to posts any more.  The forum whines that I either submitted another post too recently or already submitted that post.

The hell I did.

 

entityPlayer.dimension

 

All entities have a reference to the dimension that they're in.  No need for listeners or accessing the world object.

 

You just cast the EntityPlayer to the Player: (Player)entityPlayer

like you would do it the other way around when receiving the packet: (EntityPlayer)player

 

Apparently I gave up without actually trying that. xD


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.

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

I tried the entityPlayer.dimension but it didn't work... So ill try any new way that comes to me :P


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

Squawkers13    1

Squawkers13

Squawkers13    1

  • Tree Puncher
  • Squawkers13
  • Members
  • 1
  • 31 posts
Posted May 22, 2013

A lot of people would like to know how you made your dimension.

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 22, 2013

A lot of people would like to know how you made your dimension.

 

Umm. What? I don't understand :/

 

If you want to know how to make a dimension look at Spazzys Solar system mod code on github. Which can be found here: https://github.com/haydenf96/Spazzysmod

 

More specifically these files:

https://github.com/haydenf96/Spazzysmod/blob/master/Spazzysmod/spazzysmod_common/Spazzysmod/world/TeleporterMoonPortal.java

https://github.com/haydenf96/Spazzysmod/blob/master/Spazzysmod/spazzysmod_common/Spazzysmod/world/WorldProviderMoon.java

https://github.com/haydenf96/Spazzysmod/blob/master/Spazzysmod/spazzysmod_common/Spazzysmod/world/chunk/ChunkManagerMoon.java

https://github.com/haydenf96/Spazzysmod/blob/master/Spazzysmod/spazzysmod_common/Spazzysmod/world/SpazzysDimensions.java

https://github.com/haydenf96/Spazzysmod/blob/master/Spazzysmod/spazzysmod_common/Spazzysmod/SpazzysmodBase.java

 

Those are all the files for the Moon dimension in the mod. (I help make that mod, I am ModderPenguin)


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

Squawkers13    1

Squawkers13

Squawkers13    1

  • Tree Puncher
  • Squawkers13
  • Members
  • 1
  • 31 posts
Posted May 23, 2013

Thanks. That helps.

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 23, 2013

Your welcome mate :D


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

Squawkers13    1

Squawkers13

Squawkers13    1

  • Tree Puncher
  • Squawkers13
  • Members
  • 1
  • 31 posts
Posted May 23, 2013

Wait- how do you light the portal?

Share this post


Link to post
Share on other sites

Mew    36

Mew

Mew    36

  • Dragon Slayer
  • Mew
  • Members
  • 36
  • 567 posts
Posted May 23, 2013

I don't have a portal lighter for that... It was just the dimension xD

 

To do that, just look at Wuppy29's 1.4.7 tutorials and look at the portal placer tutorial. That is probably a good way f doing it.


I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes.

 

I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there xD

Share this post


Link to post
Share on other sites

Squawkers13    1

Squawkers13

Squawkers13    1

  • Tree Puncher
  • Squawkers13
  • Members
  • 1
  • 31 posts
Posted May 23, 2013

That is not coded with Pudlehund's Dimension API.

But that requires altering a base class. :0

Share this post


Link to post
Share on other sites

Vinit    0

Vinit

Vinit    0

  • Tree Puncher
  • Vinit
  • Members
  • 0
  • 2 posts
Posted August 22, 2020
On 5/22/2013 at 4:49 PM, endershadow said:

you could get the worldObj from the player. so it would look i little like

player.worldObj.provider.dimensionId

i am new to forge, i m making a mod, it needs to know if player is in end dimension, i used this code

 

public void playerlocation (){

       if (player.worldObj.provider.dimensionId = 1) {
    }

but it highlights the player as red color, what am i missing

 

 

 

my full code + its in a new java class

 

package com.example;
import net.minecraft.entity.Entity;
import net.minecraft.entity.*;
public class Listeners {



    public void playerlocation (){

       if (player.worldObj.provider.dimensionId = 1) {
    }
}

 

Share this post


Link to post
Share on other sites

loordgek    176

loordgek

loordgek    176

  • World Shaper
  • loordgek
  • Members
  • 176
  • 1823 posts
Posted August 22, 2020

make your own thread this on is from 2013

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • PtownCoderSchool
      [HIRING] Minecraft Modders

      By PtownCoderSchool · Posted 58 minutes ago

      Hey all! I run a coding school with a lot of our students coming in looking to get introduced to coding through Minecraft and building their own mods! Whether you're using redstone and some simpler tools, or more advanced and working with Java, please don't hesitate to reach out with your experience!   This is a PAID role. Our students sign up for weekly sessions where you will assist them in making their ideas come to life and teaching them to code along the way.    Due to the pandemic, we are capable of hiring remotely, though you must be located in California.    Interested? Please message me so we can set-up an interview.    Must be be 15+ years old. 
    • brok4d
      [1.16.4] New particle texture for biome.

      By brok4d · Posted 1 hour ago

      I do not know if I explained well, what I try is to change the color of the water particles since my biome is all reddish, I have been looking at the classes of the forge particles and I do not see that it can be modified as I am doing, any Subjection, because you told me to update the forge version to give support, but so if I see that each time the private class is forge, and they cannot be accessed, and also the setParticleTextureIndex method with which it could be select the index of the texture of the particle, in the end I think it will get worse instead of better, if someone thinks otherwise than say it.
    • ryanmanrules
      Delete

      By ryanmanrules · Posted 1 hour ago

      Fixed
    • AdminCat
      The game crashed whilst rendering overlay Error: java.lang.NullPointerException: Rendering overlay Exit Code: -1

      By AdminCat · Posted 2 hours ago

      hhhhhhhhhhhhh  
    • AdminCat
      The game crashed whilst rendering overlay Error: java.lang.NullPointerException: Rendering overlay Exit Code: -1

      By AdminCat · Posted 2 hours ago

      How would I backdate I'm having the same issue here  
  • Topics

    • PtownCoderSchool
      0
      [HIRING] Minecraft Modders

      By PtownCoderSchool
      Started 58 minutes ago

    • brok4d
      1
      [1.16.4] New particle texture for biome.

      By brok4d
      Started 11 hours ago

    • ryanmanrules
      0
      Delete

      By ryanmanrules
      Started 1 hour ago

    • Blake.bill
      12
      The game crashed whilst rendering overlay Error: java.lang.NullPointerException: Rendering overlay Exit Code: -1

      By Blake.bill
      Started September 9, 2020

    • sc0rich
      8
      how do I config mods in 1.16.4?

      By sc0rich
      Started Friday at 02:11 AM

  • Who's Online (See full list)

    • brok4d
    • ピチュウ
    • NorthWestWind
    • BubbySwag
    • fallOut015
    • sarkozi
    • Eksity
    • MegaTigerpaw
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How to check what dimension the player is in
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community