Invisible quantity when 1

Discussion in 'Plugin Development' started by TheDiamond06, Feb 26, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    TheDiamond06

    Here is what I have
    Code:
                                                if(b.getType() == Material.GLOWSTONE)
                                                {
                                                    Random rand = new Random();
                                                   
                                                    int amount = rand.nextInt(4);
                                                   
                                                    ItemStack one = new ItemStack(Material.GLOWSTONE_DUST);
                                                   
                                                    b.setType(Material.AIR);
                                                   
                                                    int a = one.getAmount();
                                                    p.getInventory().remove(one);
                                                    ItemStack two = new ItemStack(Material.GLOWSTONE_DUST, a + amount);
                                                    p.getInventory().addItem(two);
                                                    p.updateInventory();
                                                }
    
    This seems to be working fine but when the random integer chooses 1 a new ItemStack in my inventory appears that seems to be invisible. When I click or drop it it disappears. How would I fix this or make it so the lowest random is 2 instead?
     
  2. Offline

    Hoolean Retired Staff

    It's far more likely that the ItemStack is rendered invisible when the random value produced is zero. How to counter-act this issue? Simply add 1 to amount. :)
     
Thread Status:
Not open for further replies.

Share This Page