Jump to content

[Solved] [1.10.2] How to get the biome a player is in?


FireController1847

Recommended Posts

Hello! I am currently trying to make a client side mod (my signature), and I am trying to use "onClientTick", but I am not really sure how it works. Could somebody explain to me what it does?

 

This is my current code:

 

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
final Minecraft minecraft = FMLClientHandler.instance().getClient();
final WorldClient world = minecraft.theWorld;
final EntityPlayerSP player = minecraft.thePlayer;

System.out.println("Client Event");
}

 

"Client Event" is not being printed out into console at all, so is it even doing anything?

 

Edit: I am reading an outdated wiki, and it says something like registering the event.. How do I do that? O.o

I am on my journey of making a remake of matmos, as explained here.

Link to comment
Share on other sites

Hmm? ClientTickEvent already gives you the EntityPlayer (and through it, the world as EntityPlayer#worldObj)

Minecraft is already Client-Side, so simply use "Minecraft minecraft = Minecraft.getMinecraft()".

 

Try this instead:

@SubscribeEvent
public void onClientTick(TickEvent.PlayerTickEvent event){
	final Minecraft minecraft = Minecraft.getMinecraft();
	final EntityPlayer player = event.player;
	final World world = player.worldObj;
}

 

Also, have you registered the event-handler to any bus? If it's not registered, it's not going to do anything.

 

To get the biome, as this topic is about, you need to get the player's position, then use world#getBiomeForCoordsBody(BlockPos)

 

 

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

To register an event, you need to register it to a bus. You should use the basic EVENT_BUS here.

Create a private final instance of your EventHandler class. For example, using my eventhandler from one of my mods, called UnderworldMapEventHandler.class,

I would use

private final UnderworldMapEventHandler ANY_NAME_YOU_LIKE = new UnderworldMapEventHandler();

Then in your proxy, register it simply with:

MinecraftForge.EVENTBUS.register(ANY_NAME_YOU_LIKE);

(For those you who sees the issue with event->bus here, don't worry, my own eventhandler uses the TERRAIN_GEN_BUS)

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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