Advertisement
Guest User

Untitled

a guest
Aug 7th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. package com.mod.drakania.ChestFinder;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import net.minecraft.client.Minecraft;
  7. import net.minecraft.entity.Entity;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.item.Item;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.tileentity.TileEntity;
  12. import net.minecraft.util.ChatComponentText;
  13. import net.minecraft.util.ChatStyle;
  14. import net.minecraft.util.EnumChatFormatting;
  15. import net.minecraft.world.ChunkCoordIntPair;
  16. import net.minecraft.world.World;
  17.  
  18. public class ItemChestFinder extends Item{
  19.  
  20. public ItemChestFinder()
  21. {
  22.  
  23. this.maxStackSize = 1;}
  24.  
  25.  
  26.  
  27. EntityPlayer entity = Minecraft.getMinecraft().thePlayer;
  28. int i = (int) entity.chunkCoordX;
  29. int j = (int) entity.chunkCoordY;
  30. int k = (int) entity.chunkCoordZ;
  31. int x= i;
  32. int y = j;
  33. int z = k;
  34.  
  35.  
  36.  
  37. @Override
  38. public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) {
  39.  
  40. List<TileEntity> tiles = world.loadedTileEntityList;
  41.  
  42. ArrayList<TileEntity> tilesNear = new ArrayList<TileEntity>();
  43.  
  44. ChunkCoordIntPair entityChunk = world.getChunkFromBlockCoords((int)entity.posX, (int)entity.posZ).getChunkCoordIntPair();
  45.  
  46. for(TileEntity tile : tiles) {
  47.  
  48. ChunkCoordIntPair tileChunk = world.getChunkFromBlockCoords(tile.xCoord, tile.zCoord).getChunkCoordIntPair();
  49.  
  50. if(tileChunk.chunkXPos >= entityChunk.chunkXPos - 2 &&
  51.  
  52. tileChunk.chunkXPos <= entity.chunkCoordX + 2 &&
  53.  
  54. tileChunk.chunkZPos >= entity.chunkCoordZ - 2 &&
  55.  
  56. tileChunk.chunkZPos <= entity.chunkCoordZ + 2) {
  57.  
  58. tilesNear.add(tile);
  59. }
  60. }
  61.  
  62. player.addChatComponentMessage(new ChatComponentText("Il y'a entité(s) dans ce chunk").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
  63.  
  64. return super.onItemRightClick(is, world, player);
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement