Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mod.drakania.ChestFinder;
- import java.util.ArrayList;
- import java.util.List;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraft.util.ChatComponentText;
- import net.minecraft.util.ChatStyle;
- import net.minecraft.util.EnumChatFormatting;
- import net.minecraft.world.ChunkCoordIntPair;
- import net.minecraft.world.World;
- public class ItemChestFinder extends Item{
- public ItemChestFinder()
- {
- this.maxStackSize = 1;}
- EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
- int i = (int) entity.chunkCoordX;
- int j = (int) entity.chunkCoordY;
- int k = (int) entity.chunkCoordZ;
- int x= i;
- int y = j;
- int z = k;
- @Override
- public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
- List<TileEntity> tiles = world.loadedTileEntityList;
- ArrayList<TileEntity> tilesNear = new ArrayList<TileEntity>();
- ChunkCoordIntPair entityChunk = world.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ).getChunkCoordIntPair();
- for(TileEntity tile : tiles) {
- ChunkCoordIntPair tileChunk = world.getChunkFromBlockCoords(tile.xCoord, tile.zCoord).getChunkCoordIntPair();
- if(tileChunk.chunkXPos >= entityChunk.chunkXPos - 2 &&
- tileChunk.chunkXPos <= entity.chunkCoordX + 2 &&
- tileChunk.chunkZPos >= entity.chunkCoordZ - 2 &&
- tileChunk.chunkZPos <= entity.chunkCoordZ + 2) {
- tilesNear.add(tile);
- }
- }
- player.addChatComponentMessage(new ChatComponentText("Il y'a entité(s) dans ce chunk").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
- return super.onItemRightClick(is, world, player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement