Posted November 22, 201410 yr Hello! I have simple question, is there a simple workaround for IInventory.setInventorySlotContents putting ghost items in the inventory, or do I have to set up a packet system or something like that? Thanks! 2 Examples of it: @Override public void updateEntity(){ ArrayList<ItemStack> ores = new ArrayList<ItemStack>(1); for(String oreName : OreDictionary.getOreNames()){ if(oreName.toLowerCase().startsWith("ore")) { ores = ListHelper.combine2(OreDictionary.getOres(oreName), ores); } } if(Tick == 40 && PowerStored > 0){ Tick = 0; int randomInt = 0; Random randomGenerator = new Random(); if(ores.size() > 0) { randomInt = randomGenerator.nextInt(ores.size()); } ItemStack oreToGen = ores.get(randomInt); for(TileEntity entity : TileHelper.getBlockSides(this)){ if(entity instanceof IInventory && end == false){ int size = ((IInventory) entity).getSizeInventory(); for(int i = 0; i < size; i++){ try { if(((IInventory) entity).getStackInSlot(i) != null){ if (((IInventory) entity).getStackInSlot(i).getItem().equals(oreToGen.getItem()) && ((IInventory) entity).getStackInSlot(i).stackSize < ((IInventory) entity).getInventoryStackLimit()) { ((IInventory) entity).getStackInSlot(i).stackSize++; } } else if (((IInventory) entity).getStackInSlot(i) == null) { //HERE ((IInventory) entity).setInventorySlotContents(i, oreToGen); } } catch(NullPointerException e){ e.printStackTrace(); } } this.end = true; } } this.end = false; } Tick++; } And: public void updateInventory(){ System.out.println("1"); for(Recipe recipe : Recipes.techTableRecipes){ System.out.println("2"); int temp = 0; int[] output = new int[9]; output[0] = 0; output[1] = 0; output[2] = 0; output[3] = 0; output[4] = 0; output[5] = 0; output[6] = 0; output[7] = 0; output[8] = 0; for(ItemStack item : recipe.Input){ System.out.println("3"); if(this.getStackInSlot(temp) != null) { if (item.getItem() == this.getStackInSlot(temp).getItem()) { System.out.println("4"); output[temp] = 1; } else { output[temp] = 0; } } else{ if(this.getStackInSlot(temp) == null && item.getItem() == null){ output[temp] = 1; } else { output[temp] = 0; } } temp++; } if(checkOutput(output)){ System.out.println("5"); this.setInventorySlotContents2(0, null); this.setInventorySlotContents2(1, null); this.setInventorySlotContents2(2, null); this.setInventorySlotContents2(3, null); this.setInventorySlotContents2(4, null); this.setInventorySlotContents2(5, null); this.setInventorySlotContents2(6, null); this.setInventorySlotContents2(7, null); this.setInventorySlotContents2(8, null); //HERE this.setInventorySlotContents2(10, recipe.Output);[/b][/u] } } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.