Jump to content

wendrom

Members
  • Posts

    2
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

wendrom's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thank you very much! It works exactly as I need it to now. I just changed [embed=425,349]World world = Minecraft.getMinecraft().theWorld;[/embed] to [embed=425,349]World world = MinecraftServer.getServer().worldServers[0];[/embed]
  2. So I got a list of block positions that I iterate through. They are locations of chests to put random items in. [embed=425,349]public List<BlockPos> chestGeneric = new ArrayList<BlockPos>();[/embed] I use this method to go to each chest and put some items in (I'm using paper just to test). [embed=425,349] public void fillChests() { World world = Minecraft.getMinecraft().theWorld; System.out.println("Filling chests..."); Random rand = new Random(); for (Iterator<BlockPos> iter = chestGeneric.iterator(); iter.hasNext() { BlockPos position = iter.next(); TileEntityChest chest = (TileEntityChest)world.getTileEntity(position); System.out.println("> Looking for chest..."); if (chest.getBlockType() == Blocks.chest) { System.out.println(">> chest at x: " + position.getX() + " y: " + position.getY() + " z: " + position.getZ()); for (int i = 0; i < 5; i++) { System.out.println(">>> Setting slot: " + i); chest.setInventorySlotContents(rand.nextInt(chest.getSizeInventory()), new ItemStack(Items.paper, 5)); } world.markBlockForUpdate(position); } } System.out.println("Chests filled."); } [/embed] This runs when I do a command and the log outputs this with no errors: [embed=425,349] [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:41]: Filling chests... [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:47]: > Looking for chest... [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:50]: >> chest at x: -71 y: 87 z: 257 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 0 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 1 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 2 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 3 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 4 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:47]: > Looking for chest... [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:50]: >> chest at x: -66 y: 87 z: 257 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 0 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 1 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 2 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 3 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:53]: >>> Setting slot: 4 [17:05:01] [server thread/INFO] [sTDOUT]: [wendrom.quarry.Room:fillChests:59]: Chests filled. [/embed] But in game when I look in the chests, there are no items found and I don't know why. Any ideas?
×
×
  • Create New...

Important Information

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