Jump to content

Detect number of tileentity in a chunk


Ciolgaming

Recommended Posts

I have find how to detect a tileEntity, but i didn't find to detect all the tileentities in a chunk !

 

Sorry for the spelling mistakes, i am french :)

 

help me my code is : 

package com.mod.ciolmod.init;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import net.minecraftforge.client.event.RenderGameOverlayEvent;

public class InfoOverlay {
		private Minecraft mc = FMLClientHandler.instance().getClient();

		TileEntity biomeString;

		private String fpsString;

		
		
		
		

		@SubscribeEvent

		public void renderGameOverlay(RenderGameOverlayEvent.Post event)

		{	

			int x = MathHelper.floor_double(mc.thePlayer.posX);

			int z = MathHelper.floor_double(mc.thePlayer.posZ);
			

			

			fpsString = mc.debug.split(",", 2)[0];

			biomeString = mc.theWorld.getTileEntity(x, 90, z);



			FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("[Fps] : "+fpsString, 5, 5, 0xffffff);

			FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("Chest : "+biomeString, 5, 25, 0xffffff);

		}
		



}

 

 

 

Sans titrdtfghufdsdftygre.png

Link to comment
Share on other sites

Perhaps these methods will point you in the right direction:

World#getChunkFromBlockCoords(BlockPos pos) = Returns the chunk at the given position.

Chunk#getTileEntityMap() = Returns a map of BlockPos to TileEntity; that is, it returns a Map<BlockPos, TileEntity> containing all the loaded tile entities in that chunk.

Edited by IceMetalPunk
  • Like 1

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

Just now, Ciolgaming said:

Thank you, how to get the number of tileentity in the chunk of the player is please ??

You can get a map's size with Map#size() and a player's position with Entity#getPosition().

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

9 minutes ago, Ciolgaming said:

Yes but i dont understand what do yo say, i didn't find where you want to place this, can you modify the code please ??

I've showed you how to get the player's position, get a chunk from a position, get the tile entity map from a chunk, and get the size of a map. That should be everything you need. Try out the code you think will work, and if it doesn't work, show us the code you've tried and we'll help you further from there.

  • Like 1

Whatever Minecraft needs, it is most likely not yet another tool tier.

Link to comment
Share on other sites

  • Guest locked this topic
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.