Jump to content

[1.8] Current biome


HeXHaX

Recommended Posts

How do I get the biome the player is currently in?  Here is what I am using right now:

 

BlockPos blockPos = new BlockPos(Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posY, Minecraft.getMinecraft().thePlayer.posZ);
String currentBiome = event.world.getBiomeGenForCoords(blockPos).biomeName;

 

This bit of code is inside a tick event function which uses the WorldTickEvent.  As of now, currentBiome is being set to "Hell" no matter where I am: Jungle, Desert, Forest, Ocean, Nether, End, it doesn't matter.  What am I doing wrong?

Link to comment
Share on other sites

There is this code in GuiOverlayDebug:

BlockPos blockpos = new BlockPos(this.mc.getRenderViewEntity().posX, this.mc.getRenderViewEntity().getEntityBoundingBox().minY, this.mc.getRenderViewEntity().posZ);
(...)
if (this.mc.theWorld != null && this.mc.theWorld.isBlockLoaded(blockpos))
            {
                Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(blockpos);
                arraylist.add("Biome: " + chunk.getBiome(blockpos, this.mc.theWorld.getWorldChunkManager()).biomeName);

 

You might wanna look into how it works as I don't know (never used) code you posted and why it doesn't work.

 

Overall - BIG WTF!

DON'T USE MINECRAFT CLASS IN WorldTickEvent - never ever!

You might want to use PlayerTickEvent for per-player effect.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Could you please explain why not to use the Minecraft class in the WorldTickEvent?  I only started modding two weeks ago, so even though I am capable of understanding this stuff, I have no clue where to find it out because of poor documentation/community organization.  So even though I know you mean well, your comment doesn't really help me understand what I am doing; it just gives me an example of code from vanilla that I can adapt to my application.

Link to comment
Share on other sites

There are two sides (threads) running:

Logical CLIENT and logical SERVER.

On Client.jar there are both running (the client has an integrated server in background) therefore accessing it won't crash.

On Server.jar (dedic) there is only SERVER logical side - classes like Minecraft or any other client class are simply not there - it will crash.

You cannot have any client-class reference in class used by server. That is why you use Proxies.

 

As to TickEvents:

There are 5 tick events.

SERVER, CLIENT, WORLD, PLAYER and RENDER.

 

Server runs only on server thread, client and render on client.

 

Player tick runs on both (that means that each side runs code once, unless you do world.isRemote - true=client, false=server; worldObj can be found also in any entity - e.g player from PlayerTickEvent).

As to WorldTickEvent - it runs for EVERY loaded world once per tick and ONLY for SERVER.

The client has always ONE world (the one the client's player "thePlayer" is in called "theWorld" - those are accessible from Minecraf.class for client purposes only). On forge build 1306 - WorldTickEvent will NOT be called on client world, BUT it might have changed, I am just outdated.

 

More:

Each TickEvent has 2 Phases - START and END.

Whenever you use TickEvent - pick one phase (event.phase) - otherwise your code will run twice.

START happens before all other updates like entity or tileentity updates, END happens last.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

It's beyond me.  Initially, there is only one thank you, but after I reload the page, another one appears out of the blue.  It's almost like it's adding a dummy account before mine with a blank username because there is a comma preceding my username in the thank you.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.