Advertisement
Guest User

Untitled

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