bebeli555 Posted April 12, 2020 Posted April 12, 2020 So i know how to get blocks in inventory like this int newSlot = -1; for(int i = 0; i < 9; i++) { // filter out non-block items ItemStack stack = mc.player.inventory.getStackInSlot(i); if(stack == ItemStack.EMPTY || !(stack.getItem() instanceof ItemBlock)) { continue; } // only use whitelisted blocks Block block = ((ItemBlock) stack.getItem()).getBlock(); if(!ec.getValBoolean()){ if (!(block instanceof BlockSoulSand)) { continue; } } else { if (!(block instanceof BlockSoulSand) && !(block instanceof BlockSoulSand)) { continue; } } newSlot = i; break; } // check if any blocks were found if(newSlot == -1) return; // set slot int oldSlot = mc.player.inventory.currentItem; mc.player.inventory.currentItem = newSlot; But how can i do this for a wither skeleton skull its not a block?
bebeli555 Posted April 12, 2020 Author Posted April 12, 2020 Nvm i figured it out int newSlot = -1; for(int i = 0; i < 9; i++) { // filter out non-block items ItemStack stack = mc.player.inventory.getStackInSlot(i); if(stack == ItemStack.EMPTY || !(stack.getItem() instanceof ItemSkull)) { continue; } newSlot = i; break; } // check if any blocks were found if(newSlot == -1) return; // set slot int oldSlot = mc.player.inventory.currentItem; mc.player.inventory.currentItem = newSlot; This doesnt check if the skull is wither skeleton but whatever i never have other skulls than that so
Recommended Posts