Java Code Examples for net.minecraft.init.Items.BOWL

The following are Jave code examples for showing how to use BOWL of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Got-Wood   File: SappyLog.java   View Source Code Vote up 6 votes
@Override //&& state.getValue(GENERATED)==1
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
		EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
	if(heldItem == null){
		return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
	}
	
	if( !worldIn.isRemote  && heldItem.getItem() == Items.BOWL && side != EnumFacing.UP && side != EnumFacing.DOWN){
		
                  ItemStack itemstack1 = new ItemStack(ItemRegistry.rubber_sap);

                  if (--heldItem.stackSize == 0)
                  {
                      playerIn.setHeldItem(hand, itemstack1);
                  }
                  else if (!playerIn.inventory.addItemStackToInventory(itemstack1))
                  {
                      playerIn.dropItem(itemstack1, false);
                  }
	}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, heldItem, side, hitX, hitY, hitZ);
	
}
 
Example 2
Project: Got-Wood   File: BlockSappyLog.java   View Source Code Vote up 6 votes
@Override //&& state.getValue(GENERATED)==1
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack heldItem = playerIn.getHeldItem(hand);

	if (heldItem.isEmpty()) {
		return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
	}

	if (!worldIn.isRemote && heldItem.getItem() == Items.BOWL && facing != EnumFacing.UP && facing != EnumFacing.DOWN) {

		ItemStack itemstack1 = new ItemStack(ItemRegistry.rubber_sap);

		heldItem.shrink(1);
		if (heldItem.isEmpty()) {
			playerIn.setHeldItem(hand, itemstack1);
		} else if (!playerIn.inventory.addItemStackToInventory(itemstack1)) {
			playerIn.dropItem(itemstack1, false);
		}
	}
	return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);

}
 
Example 3
Project: uniquecrops   File: GrowthSteps.java   View Source Code Vote up 5 votes
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {
	
	Entity item = null, chicken = null;
	List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.add(-3, 0, -3), pos.add(3, 1, 3)));
	for (Entity ent : entities) {
		if (!ent.isDead) {
			if (ent instanceof EntityChicken)
				chicken = ent;
			if (ent instanceof EntityItem && ((EntityItem)ent).getEntityItem().getItem() == Items.BOWL)
				item = ent;
			if (item != null && chicken != null)
				break;
		}
	}
	if (chicken != null && item != null) {
		AxisAlignedBB aabb = new AxisAlignedBB(chicken.getPosition().add(0, 0, 0), chicken.getPosition().add(1, 1, 1));
		List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(chicken, aabb);
		for (Entity entity : list) {
			if (entity != null && entity == item) {
				EntityItem ei = new EntityItem(item.worldObj, item.posX, item.posY, item.posZ, new ItemStack(UCItems.teriyaki));
				((EntityItem)item).getEntityItem().stackSize--;
				if (((EntityItem)item).getEntityItem().stackSize <= 0)
					item.setDead();
				chicken.setDead();
				UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.EXPLOSION_NORMAL, chicken.posX, chicken.posY + 0.5D, chicken.posZ, 3));
				if (!world.isRemote)
					world.spawnEntityInWorld(ei);
				return true;
			}
		}
	}
	else if (chicken != null) {
		UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.HEART, chicken.posX, chicken.posY + 1D, chicken.posZ, 3));
		return true;
	}
	return false;
}
 
Example 4
Project: Backmemed   File: TileEntityFurnace.java   View Source Code Vote up 5 votes
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't
 * fuel
 */
public static int getItemBurnTime(ItemStack stack)
{
    if (stack.func_190926_b())
    {
        return 0;
    }
    else
    {
        Item item = stack.getItem();
        return item == Item.getItemFromBlock(Blocks.WOODEN_SLAB) ? 150 : (item == Item.getItemFromBlock(Blocks.WOOL) ? 100 : (item == Item.getItemFromBlock(Blocks.CARPET) ? 67 : (item == Item.getItemFromBlock(Blocks.LADDER) ? 300 : (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON) ? 100 : (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD ? 300 : (item == Item.getItemFromBlock(Blocks.COAL_BLOCK) ? 16000 : (item instanceof ItemTool && "WOOD".equals(((ItemTool)item).getToolMaterialName()) ? 200 : (item instanceof ItemSword && "WOOD".equals(((ItemSword)item).getToolMaterialName()) ? 200 : (item instanceof ItemHoe && "WOOD".equals(((ItemHoe)item).getMaterialName()) ? 200 : (item == Items.STICK ? 100 : (item != Items.BOW && item != Items.FISHING_ROD ? (item == Items.SIGN ? 200 : (item == Items.COAL ? 1600 : (item == Items.LAVA_BUCKET ? 20000 : (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL ? (item == Items.BLAZE_ROD ? 2400 : (item instanceof ItemDoor && item != Items.IRON_DOOR ? 200 : (item instanceof ItemBoat ? 400 : 0))) : 100)))) : 300)))))))))));
    }
}
 
Example 5
Project: CustomWorldGen   File: ItemSoup.java   View Source Code Vote up 5 votes
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
@Nullable
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    super.onItemUseFinish(stack, worldIn, entityLiving);
    return new ItemStack(Items.BOWL);
}
 
Example 6
Project: Bewitchment   File: TileCauldron.java   View Source Code Vote up 4 votes
@SuppressWarnings("ConstantConditions")
public boolean useCauldron(EntityPlayer player, EnumHand hand, ItemStack heldItem) {
	if (!world.isRemote) {
		if (heldItem.isEmpty()) {
			if (!getContainer().isEmpty()) {
				giveItem(player, hand, ItemStack.EMPTY, getContainer());
				setContainer(ItemStack.EMPTY);
			} else if (inv.isFull() && hasIngredients() && mode != Mode.RITUAL) {
				itemRitualLogic();
			}
			return true;
		}
		//Held Item is not empty
		if (heldItem.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP)) {
			handleLiquid(heldItem.getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.UP));
		} else if (heldItem.getItem() == Items.POTIONITEM && PotionUtils.getEffectsFromStack(heldItem).isEmpty()) {
			int level = inv.getFluidAmount();
			if (level < BUCKET_VOLUME && (inv.getFluid() == null || inv.hasFluid(FluidRegistry.WATER))) {
				play(SoundEvents.ITEM_BUCKET_FILL, 1F, 1F);
				giveItem(player, hand, heldItem, new ItemStack(Items.GLASS_BOTTLE));
				FluidStack fluidStack = new FluidStack(FluidRegistry.WATER, 250);
				inv.fill(fluidStack, true);
			}
		} else if (heldItem.getItem() == Items.GLASS_BOTTLE) {
			if (mode == Mode.POTION) {
				potionRecipeLogic(player, hand, heldItem);
			} else if (mode == Mode.CUSTOM) {
				potionCustomLogic(player, hand, heldItem);
			}
		} else if (heldItem.getItem() == Items.BOWL) {
			ItemStack stewToGive = new ItemStack(ModItems.stew);
			int hunger = 0;
			float saturation = 0f;
			float multiplier = 1.0f;
			for (ItemStack stack : ingredients) {
				if (CauldronRegistry.getFoodValues().get(stack.getItem()) != null) {
					CauldronFoodValue foodValue = CauldronRegistry.getFoodValues().get(stack.getItem());
					hunger += foodValue.hunger * multiplier;
					saturation += foodValue.saturation * multiplier;
					multiplier *= 0.75;
				}
			}
			NBTTagCompound nbt = new NBTTagCompound();
			stewToGive.setTagCompound(nbt);
			nbt.setInteger("hunger", hunger);
			nbt.setFloat("saturation", saturation);

			if (player.addItemStackToInventory(stewToGive)) { //if the player has enough inventory space
				heldItem.setCount(heldItem.getCount() - 1);
				ingredients.clear();
				inv.setFluid(null);
				setContainer(ItemStack.EMPTY);
			}
		} else if (getContainer().isEmpty()) {
			ItemStack copy = heldItem.copy();
			setContainer(copy);
			player.setHeldItem(hand, ItemStack.EMPTY);
		}
	}
	return true;
}
 
Example 7
Project: Wurst-MC-1.12   File: AutoSoupMod.java   View Source Code Vote up 4 votes
@Override
public void onUpdate()
{
	// sort empty bowls
	for(int i = 0; i < 36; i++)
	{
		// filter out non-bowl items and empty bowl slot
		ItemStack stack =
			WMinecraft.getPlayer().inventory.getStackInSlot(i);
		if(stack == null || stack.getItem() != Items.BOWL || i == 9)
			continue;
		
		// check if empty bowl slot contains a non-bowl item
		ItemStack emptyBowlStack =
			WMinecraft.getPlayer().inventory.getStackInSlot(9);
		boolean swap = !WItem.isNull(emptyBowlStack)
			&& emptyBowlStack.getItem() != Items.BOWL;
		
		// place bowl in empty bowl slot
		WPlayerController.windowClick_PICKUP(i < 9 ? 36 + i : i);
		WPlayerController.windowClick_PICKUP(9);
		
		// place non-bowl item from empty bowl slot in current slot
		if(swap)
			WPlayerController.windowClick_PICKUP(i < 9 ? 36 + i : i);
	}
	
	// search soup in hotbar
	int soupInHotbar = findSoup(0, 9);
	
	// check if any soup was found
	if(soupInHotbar != -1)
	{
		// check if player should eat soup
		if(!shouldEatSoup())
		{
			stopIfEating();
			return;
		}
		
		// save old slot
		if(oldSlot == -1)
			oldSlot = WMinecraft.getPlayer().inventory.currentItem;
		
		// set slot
		WMinecraft.getPlayer().inventory.currentItem = soupInHotbar;
		
		// eat soup
		mc.gameSettings.keyBindUseItem.pressed = true;
		WPlayerController.processRightClick();
		
		return;
	}
	
	stopIfEating();
	
	// search soup in inventory
	int soupInInventory = findSoup(9, 36);
	
	// move soup in inventory to hotbar
	if(soupInInventory != -1)
		WPlayerController.windowClick_QUICK_MOVE(soupInInventory);
}
 
Example 8
Project: Backmemed   File: EntityMooshroom.java   View Source Code Vote up 4 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.BOWL && this.getGrowingAge() >= 0 && !player.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);

        if (itemstack.func_190926_b())
        {
            player.setHeldItem(hand, new ItemStack(Items.MUSHROOM_STEW));
        }
        else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.MUSHROOM_STEW)))
        {
            player.dropItem(new ItemStack(Items.MUSHROOM_STEW), false);
        }

        return true;
    }
    else if (itemstack.getItem() == Items.SHEARS && this.getGrowingAge() >= 0)
    {
        this.setDead();
        this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);

        if (!this.world.isRemote)
        {
            EntityCow entitycow = new EntityCow(this.world);
            entitycow.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
            entitycow.setHealth(this.getHealth());
            entitycow.renderYawOffset = this.renderYawOffset;

            if (this.hasCustomName())
            {
                entitycow.setCustomNameTag(this.getCustomNameTag());
            }

            this.world.spawnEntityInWorld(entitycow);

            for (int i = 0; i < 5; ++i)
            {
                this.world.spawnEntityInWorld(new EntityItem(this.world, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            itemstack.damageItem(1, player);
            this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F);
        }

        return true;
    }
    else
    {
        return super.processInteract(player, hand);
    }
}
 
Example 9
Project: Backmemed   File: ItemSoup.java   View Source Code Vote up 4 votes
/**
 * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using
 * the Item before the action is complete.
 */
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving)
{
    super.onItemUseFinish(stack, worldIn, entityLiving);
    return new ItemStack(Items.BOWL);
}
 
Example 10
Project: CustomWorldGen   File: EntityMooshroom.java   View Source Code Vote up 4 votes
@SuppressWarnings("unused")
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (stack != null && stack.getItem() == Items.BOWL && this.getGrowingAge() >= 0 && !player.capabilities.isCreativeMode)
    {
        if (--stack.stackSize == 0)
        {
            player.setHeldItem(hand, new ItemStack(Items.MUSHROOM_STEW));
        }
        else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.MUSHROOM_STEW)))
        {
            player.dropItem(new ItemStack(Items.MUSHROOM_STEW), false);
        }

        return true;
    }
    else if (false && stack != null && stack.getItem() == Items.SHEARS && this.getGrowingAge() >= 0) //Forge Disable, Moved to onSheared
    {
        this.setDead();
        this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);

        if (!this.worldObj.isRemote)
        {
            EntityCow entitycow = new EntityCow(this.worldObj);
            entitycow.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
            entitycow.setHealth(this.getHealth());
            entitycow.renderYawOffset = this.renderYawOffset;

            if (this.hasCustomName())
            {
                entitycow.setCustomNameTag(this.getCustomNameTag());
            }

            this.worldObj.spawnEntityInWorld(entitycow);

            for (int i = 0; i < 5; ++i)
            {
                this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, this.posX, this.posY + (double)this.height, this.posZ, new ItemStack(Blocks.RED_MUSHROOM)));
            }

            stack.damageItem(1, player);
            this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F);
        }

        return true;
    }
    else
    {
        return super.processInteract(player, hand, stack);
    }
}