Jump to content

MultiMote

Forge Modder
  • Posts

    257
  • Joined

  • Last visited

Posts posted by MultiMote

  1. public Item stack;

     

    @Override

    public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player){

    Random rand = new Random(); //itemRand

     

    for(int m = 0; m < 6; m++) //you said 5

    {

              int r = rand.nextInt(Lootcube.pokelist.length - 1); //nextInt counts from 0

                              stack = Lootcube.pokelist[r];

              player.inventory.addItemStackToInventory(new ItemStack(stack));

              player.inventory.consumeInventoryItem(this);

                              itemStack.stackSize--;

     

    }

     

    return new ItemStack(stack); //why?

                    return itemStack;

     

    }

     

     

     

     

        public static Item[] pokelist = {Items.apple, Items.carrot, Items.potato, Items.slime_ball, Items.arrow, Items.beef, Items.shears};

     

        @Override

        public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player){

            if(world.isRemote)return itemStack; //because ghost items

     

            List<Item> tempList = new ArrayList<Item>();

            tempList.addAll(Arrays.asList(pokelist)); //because remove() causes UnsupportedOperationException

     

            for(int m = 0; m < 5; m++)

            {

                player.inventory.addItemStackToInventory(new ItemStack(tempList.remove(itemRand.nextInt(tempList.size())))); //because science

                itemStack.stackSize--;

            }

            return itemStack;

        }

     

  2.        @Override
        public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
            ItemStack next = player.inventory.currentItem+1 < player.inventory.getSizeInventory() ? player.inventory.getStackInSlot(player.inventory.currentItem+1) : null;
    
            if(side!=1 || !(next!=null && next.getItem() instanceof IPlantable))return false;
            int radius = 3;
    
            for(int x2 = -radius; x2<=radius; x2++)
            for(int z2 = -radius; z2<=radius; z2++){
                  if(next.stackSize>0)next.getItem().onItemUse(next, player, world, x+x2, y, z+z2, side, hitX, hitY, hitZ);
                  if(next.stackSize<=0)player.inventory.setInventorySlotContents(player.inventory.currentItem+1, null);
            }
            return true;
        }
    

    I think it works.

  3.     
        @Override
        public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
            if(side!=1 || world.getBlock(x, y, z) != Blocks.farmland)return false;
            if(world.isRemote)return true;
            int radius = 3;
    
            for(int x2 = -radius; x2<=radius; x2++)
            for(int z2 = -radius; z2<=radius; z2++)
               if(player.canPlayerEdit(x+x2, y, z+z2, side, is) && world.getBlock(x+x2, y+1, z+z2).getMaterial().isReplaceable() && world.getBlock(x+x2, y, z+z2) == Blocks.farmland)
                   world.setBlock(x+x2, y+1, z+z2, Blocks.wheat, 0, 3);
    
            return true;
        }
    

×
×
  • Create New...

Important Information

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