Java Code Examples for net.minecraft.init.Items

The following are top voted examples for showing how to use net.minecraft.init.Items. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: BaseClient   File: ItemCarrotOnAStick.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (playerIn.isRiding() && playerIn.ridingEntity instanceof EntityPig)
    {
        EntityPig entitypig = (EntityPig)playerIn.ridingEntity;

        if (entitypig.getAIControlledByPlayer().isControlledByPlayer() && itemStackIn.getMaxDamage() - itemStackIn.getMetadata() >= 7)
        {
            entitypig.getAIControlledByPlayer().boostSpeed();
            itemStackIn.damageItem(7, playerIn);

            if (itemStackIn.stackSize == 0)
            {
                ItemStack itemstack = new ItemStack(Items.fishing_rod);
                itemstack.setTagCompound(itemStackIn.getTagCompound());
                return itemstack;
            }
        }
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 2
Project: CustomWorldGen   File: EntityAISkeletonRiders.java   Source Code and License 6 votes vote down vote up
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, EntityHorse p_188514_2_)
{
    EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.worldObj);
    entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null);
    entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ);
    entityskeleton.hurtResistantTime = 60;
    entityskeleton.enablePersistence();

    if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD) == null)
    {
        entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
    }

    EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false);
    EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false);
    entityskeleton.worldObj.spawnEntityInWorld(entityskeleton);
    return entityskeleton;
}
 
Example 3
Project: BaseClient   File: EntityPig.java   Source Code and License 6 votes vote down vote up
public EntityPig(World worldIn)
{
    super(worldIn);
    this.setSize(0.9F, 0.9F);
    ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
    this.tasks.addTask(2, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 0.3F));
    this.tasks.addTask(3, new EntityAIMate(this, 1.0D));
    this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot_on_a_stick, false));
    this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.carrot, false));
    this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D));
    this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
    this.tasks.addTask(8, new EntityAILookIdle(this));
}
 
Example 4
Project: AdvancedCombat   File: Swords.java   Source Code and License 6 votes vote down vote up
private static void setupMaterials() {
		// regular materials
		advancedWood = EnumHelper.addToolMaterial("advancedWood", 1, 236, 8.0F, 1.75F, 8);
		(advancedStone = EnumHelper.addToolMaterial("advancedStone", 2, 524, 12.0F, 3.0F, 3)).setRepairItem(new ItemStack(ACBlocks.advancedStone));
		(advancedIron = EnumHelper.addToolMaterial("advancedIron", 3, 2250, 18.0F, 10.0F, 7)).setRepairItem(new ItemStack(Blocks.IRON_BLOCK));
		(advancedGold = EnumHelper.addToolMaterial("advancedGold", 2, 1561, 8.0F, 6.0F, 15)).setRepairItem(new ItemStack(Blocks.GOLD_BLOCK));
		(advancedEmerald = EnumHelper.addToolMaterial("advancedEmerald", 4, 3122, 12.0F, ACConfig.emeraldSwordDamage - 4, 22)).setRepairItem(new ItemStack(Blocks.EMERALD_BLOCK));
		(advancedDiamond = EnumHelper.addToolMaterial("advancedDiamond", 4, 8192, 24.0F, 20.0F, 5)).setRepairItem(new ItemStack(Blocks.DIAMOND_BLOCK));
		(netherStar = EnumHelper.addToolMaterial("netherStar", 4, 9366, 20.0F, 26.0F, 1)).setRepairItem(new ItemStack(Items.NETHER_STAR));
		(advancedNetherStar = EnumHelper.addToolMaterial("advancedNetherStar", 5, 16384, 30.0F, 56.0F, 0)).setRepairItem(new ItemStack(ACBlocks.netherStarBlock));
		
		creative = EnumHelper.addToolMaterial("creative_", 1000, 1, 0, 0, 0);
		
		// thaumic materials
//		advancedThaumium = EnumHelper.addToolMaterial("advancedThaumium", 3, 2250, 18.0F, 11.0F, 12);
//		advancedElemental = EnumHelper.addToolMaterial("advancedElemental", 4, 6144, 24.0F, 22.0F, 8);
//		advancedVoid = EnumHelper.addToolMaterial("advancedVoid", 4, 524, 18.0F, 24.0F, 12);
//		advancedCrimson = EnumHelper.addToolMaterial("advancedCrimson", 4, 668, 20.0F, 30.0F, 12);
//		advancedPrimal = EnumHelper.addToolMaterial("advancedPrimal", 5, 937, 22.0F, 36.0F, 12);
//		if(ASModIntegration.thaumcraftExists) {
//			advancedThaumium.setRepairItem(new ItemStack(BlocksTC.metal, 1, 0));
//			advancedVoid.setRepairItem(new ItemStack(BlocksTC.metal, 1, 1));
//		}
	}
 
Example 5
Project: Backmemed   File: EntityAISkeletonRiders.java   Source Code and License 6 votes vote down vote up
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, AbstractHorse p_188514_2_)
{
    EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.world);
    entityskeleton.onInitialSpawn(p_188514_1_, (IEntityLivingData)null);
    entityskeleton.setPosition(p_188514_2_.posX, p_188514_2_.posY, p_188514_2_.posZ);
    entityskeleton.hurtResistantTime = 60;
    entityskeleton.enablePersistence();

    if (entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD).func_190926_b())
    {
        entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, new ItemStack(Items.IRON_HELMET));
    }

    entityskeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false));
    entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false));
    entityskeleton.world.spawnEntityInWorld(entityskeleton);
    return entityskeleton;
}
 
Example 6
Project: DecompiledMinecraft   File: EntityPainting.java   Source Code and License 6 votes vote down vote up
/**
 * Called when this entity is broken. Entity parameter may be null.
 */
public void onBroken(Entity brokenEntity)
{
    if (this.worldObj.getGameRules().getBoolean("doEntityDrops"))
    {
        if (brokenEntity instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)brokenEntity;

            if (entityplayer.capabilities.isCreativeMode)
            {
                return;
            }
        }

        this.entityDropItem(new ItemStack(Items.painting), 0.0F);
    }
}
 
Example 7
Project: connor41-etfuturum2   File: ModRecipes.java   Source Code and License 6 votes vote down vote up
private static void tweakRecipes() {
	if (EtFuturum.enableDoors) {
		Items.wooden_door.setMaxStackSize(64);
		Items.iron_door.setMaxStackSize(64);
		removeFirstRecipeFor(Items.wooden_door);
		removeFirstRecipeFor(Items.iron_door);
	}

	if (EtFuturum.enableFences) {
		removeFirstRecipeFor(Blocks.fence);
		removeFirstRecipeFor(Blocks.fence_gate);
		Blocks.fence.setCreativeTab(null);
		Blocks.fence_gate.setCreativeTab(null);
	}

	if (EtFuturum.enableBurnableBlocks) {
		Blocks.fire.setFireInfo(Blocks.fence_gate, 5, 20);
		Blocks.fire.setFireInfo(Blocks.fence, 5, 20);
		Blocks.fire.setFireInfo(Blocks.deadbush, 60, 100);
	}
}
 
Example 8
Project: pnc-repressurized   File: TileEntityPressureChamberInterface.java   Source Code and License 6 votes vote down vote up
@Override
public void handleGUIButtonPress(int guiID, EntityPlayer player) {
    if (guiID == 1) {
        if (filterMode.ordinal() >= EnumFilterMode.values().length - 1) {
            filterMode = EnumFilterMode.ITEM;
        } else {
            filterMode = EnumFilterMode.values()[filterMode.ordinal() + 1];
        }
        //when an SideOnly exception is thrown this method automatically will set the filter mode to Item.
        filterHandler.doesItemMatchFilter(new ItemStack(Items.STICK));

    } else if (guiID == 2) {
        creativeTabID++;
        if (creativeTabID == 5 || creativeTabID == 11) creativeTabID++;
        if (creativeTabID >= CreativeTabs.CREATIVE_TAB_ARRAY.length) {
            creativeTabID = 0;
        }
    } else if (guiID == 0) {
        redstoneMode++;
        if (redstoneMode > 2) redstoneMode = 0;
    }
}
 
Example 9
Project: minecraft-quiverbow   File: RPG.java   Source Code and License 6 votes vote down vote up
@Override
public void addRecipes()
{
	if (this.Enabled)
	{
		// One Firework Rocket Launcher (empty)
		GameRegistry.addRecipe(new ItemStack(this, 1 , this.getMaxDamage()), "x  ", "yx ", "zyx",
				'x', Blocks.planks,
				'y', Items.iron_ingot,
				'z', Items.flint_and_steel
				);
	}
	else if (Main.noCreative) { this.setCreativeTab(null); }	// Not enabled and not allowed to be in the creative menu

	// Fill the RPG with 1 rocket
	GameRegistry.addRecipe(new ItemStack(this), " ab", "zya", " x ",
			'x', new ItemStack(this, 1 , this.getMaxDamage()),
			'y', Blocks.tnt,
			'z', Blocks.planks,
			'a', Items.paper,
			'b', Items.string
			);
}
 
Example 10
Project: Backmemed   File: TileEntityFurnace.java   Source Code and License 6 votes vote down vote up
/**
 * Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
 */
public void smeltItem()
{
    if (this.canSmelt())
    {
        ItemStack itemstack = (ItemStack)this.furnaceItemStacks.get(0);
        ItemStack itemstack1 = FurnaceRecipes.instance().getSmeltingResult(itemstack);
        ItemStack itemstack2 = (ItemStack)this.furnaceItemStacks.get(2);

        if (itemstack2.func_190926_b())
        {
            this.furnaceItemStacks.set(2, itemstack1.copy());
        }
        else if (itemstack2.getItem() == itemstack1.getItem())
        {
            itemstack2.func_190917_f(1);
        }

        if (itemstack.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && itemstack.getMetadata() == 1 && !((ItemStack)this.furnaceItemStacks.get(1)).func_190926_b() && ((ItemStack)this.furnaceItemStacks.get(1)).getItem() == Items.BUCKET)
        {
            this.furnaceItemStacks.set(1, new ItemStack(Items.WATER_BUCKET));
        }

        itemstack.func_190918_g(1);
    }
}
 
Example 11
Project: Backmemed   File: EntityZombie.java   Source Code and License 6 votes vote down vote up
/**
 * Gives armor or weapon for entity based on given DifficultyInstance
 */
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty)
{
    super.setEquipmentBasedOnDifficulty(difficulty);

    if (this.rand.nextFloat() < (this.world.getDifficulty() == EnumDifficulty.HARD ? 0.05F : 0.01F))
    {
        int i = this.rand.nextInt(3);

        if (i == 0)
        {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SWORD));
        }
        else
        {
            this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, new ItemStack(Items.IRON_SHOVEL));
        }
    }
}
 
Example 12
Project: DecompiledMinecraft   File: EntityPig.java   Source Code and License 6 votes vote down vote up
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
{
    int i = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_);

    for (int j = 0; j < i; ++j)
    {
        if (this.isBurning())
        {
            this.dropItem(Items.cooked_porkchop, 1);
        }
        else
        {
            this.dropItem(Items.porkchop, 1);
        }
    }

    if (this.getSaddled())
    {
        this.dropItem(Items.saddle, 1);
    }
}
 
Example 13
Project: minecraft-quiverbow   File: QuiverBow.java   Source Code and License 6 votes vote down vote up
@Override
public void addRecipes()	// Enabled defines whether or not the item can be crafted. Reloading existing weapons is always permitted.
{
	if (this.Enabled)
	{
		// One quiverbow with 256 damage value (empty)
		GameRegistry.addRecipe(new ItemStack(this, 1 , this.getMaxDamage()), "zxy", "xzy", "zxy",
				'x', Items.stick,
				'y', Items.string,
				'z', Items.leather
				);
	}
	else if (Main.noCreative) { this.setCreativeTab(null); }	// Not enabled and not allowed to be in the creative menu

	// Ammo
	ItemStack bundle = Helper.getAmmoStack(ArrowBundle.class, 0);

	Helper.makeAmmoRecipe(bundle, 1, 8, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 2, 16, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 3, 24, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 4, 32, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 5, 40, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 6, 48, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 7, 56, this.getMaxDamage(), this);
	Helper.makeAmmoRecipe(bundle, 8, 64, this.getMaxDamage(), this);
}
 
Example 14
Project: Elicitation   File: GuiGuidebookPages.java   Source Code and License 6 votes vote down vote up
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
	GlStateManager.color(1, 1, 1, 1);
	GlStateManager.disableLighting();
	RenderHelper.disableStandardItemLighting();
	RenderHelper.enableGUIStandardItemLighting();
	GlStateManager.enableAlpha();
	Minecraft.getMinecraft().getTextureManager().bindTexture(GUIDEBOOK_GUI_TEXTURE);

       int i = (width - 256) / 2;
       int j = (height - 192) / 2;
       this.drawTexturedModalRect(i, j, 0, 0, 256, 192);
       this.itemRender.renderItemIntoGUI(new ItemStack(Items.WRITABLE_BOOK), (width / 2) - 100, (height / 2) - 85);
       //String text = "test tset";
       //this.fontRendererObj.drawString(text, (width / 2) - ((text.length() * 5) / 2), (height / 2) - 30, TextFormatting.GRAY.getColorIndex());
}
 
Example 15
Project: BaseClient   File: EntityWither.java   Source Code and License 6 votes vote down vote up
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
{
    EntityItem entityitem = this.dropItem(Items.nether_star, 1);

    if (entityitem != null)
    {
        entityitem.setNoDespawn();
    }

    if (!this.worldObj.isRemote)
    {
        for (EntityPlayer entityplayer : this.worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(50.0D, 100.0D, 50.0D)))
        {
            entityplayer.triggerAchievement(AchievementList.killWither);
        }
    }
}
 
Example 16
Project: Backmemed   File: EntityCreeper.java   Source Code and License 6 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);

    if (this.world.getGameRules().getBoolean("doMobLoot"))
    {
        if (cause.getEntity() instanceof EntitySkeleton)
        {
            int i = Item.getIdFromItem(Items.RECORD_13);
            int j = Item.getIdFromItem(Items.RECORD_WAIT);
            int k = i + this.rand.nextInt(j - i + 1);
            this.dropItem(Item.getItemById(k), 1);
        }
        else if (cause.getEntity() instanceof EntityCreeper && cause.getEntity() != this && ((EntityCreeper)cause.getEntity()).getPowered() && ((EntityCreeper)cause.getEntity()).isAIEnabled())
        {
            ((EntityCreeper)cause.getEntity()).incrementDroppedSkulls();
            this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
        }
    }
}
 
Example 17
Project: DecompiledMinecraft   File: ItemMap.java   Source Code and License 6 votes vote down vote up
/**
 * Called when item is crafted/smelted. Used only by maps so far.
 */
public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
    if (stack.hasTagCompound() && stack.getTagCompound().getBoolean("map_is_scaling"))
    {
        MapData mapdata = Items.filled_map.getMapData(stack, worldIn);
        stack.setItemDamage(worldIn.getUniqueDataId("map"));
        MapData mapdata1 = new MapData("map_" + stack.getMetadata());
        mapdata1.scale = (byte)(mapdata.scale + 1);

        if (mapdata1.scale > 4)
        {
            mapdata1.scale = 4;
        }

        mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale);
        mapdata1.dimension = mapdata.dimension;
        mapdata1.markDirty();
        worldIn.setItemData("map_" + stack.getMetadata(), mapdata1);
    }
}
 
Example 18
Project: Backmemed   File: DynamicLights.java   Source Code and License 6 votes vote down vote up
public static int getLightLevel(ItemStack p_getLightLevel_0_)
{
    if (p_getLightLevel_0_ == null)
    {
        return 0;
    }
    else
    {
        Item item = p_getLightLevel_0_.getItem();

        if (item instanceof ItemBlock)
        {
            ItemBlock itemblock = (ItemBlock)item;
            Block block = itemblock.getBlock();

            if (block != null)
            {
                return block.getLightValue(block.getDefaultState());
            }
        }

        return item == Items.LAVA_BUCKET ? Blocks.LAVA.getLightValue(Blocks.LAVA.getDefaultState()) : (item != Items.BLAZE_ROD && item != Items.BLAZE_POWDER ? (item == Items.GLOWSTONE_DUST ? 8 : (item == Items.PRISMARINE_CRYSTALS ? 8 : (item == Items.MAGMA_CREAM ? 8 : (item == Items.NETHER_STAR ? Blocks.BEACON.getLightValue(Blocks.BEACON.getDefaultState()) / 2 : 0)))) : 10);
    }
}
 
Example 19
Project: BetterBeginningsReborn   File: RegisterItems.java   Source Code and License 6 votes vote down vote up
public static void tweakVanilla()
{
	((ItemFood) Items.BEEF).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 20);
	((ItemFood) Items.PORKCHOP).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 25);
	((ItemFood) Items.FISH).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 30, 1), 60); // Both fish types here
	((ItemFood) Items.MUTTON).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 20, 0), 25);
	((ItemFood) Items.RABBIT).setPotionEffect(new PotionEffect(MobEffects.HUNGER, 25, 0), 30);

	if(BBConfig.makeStuffStackable)
	{
		// Let's face it, the vanilla stack sizes for these suck.
		Items.MINECART.setMaxStackSize(16);
		// Strangely enough the oak one doesn't change name.
		Items.OAK_DOOR.setMaxStackSize(16);
		Items.SPRUCE_DOOR.setMaxStackSize(16);
		Items.BIRCH_DOOR.setMaxStackSize(16);
		Items.ACACIA_DOOR.setMaxStackSize(16);
		Items.DARK_OAK_DOOR.setMaxStackSize(16);
		Items.IRON_DOOR.setMaxStackSize(16);
	}

	if(BBConfig.moduleFurnaces) Items.FURNACE_MINECART.setUnlocalizedName(ModMain.MODID + ".kilnCart");
}
 
Example 20
Project: Backmemed   File: EntityPotion.java   Source Code and License 6 votes vote down vote up
public ItemStack getPotion()
{
    ItemStack itemstack = (ItemStack)this.getDataManager().get(ITEM);

    if (itemstack.getItem() != Items.SPLASH_POTION && itemstack.getItem() != Items.LINGERING_POTION)
    {
        if (this.world != null)
        {
            LOGGER.error("ThrownPotion entity {} has no item?!", new Object[] {Integer.valueOf(this.getEntityId())});
        }

        return new ItemStack(Items.SPLASH_POTION);
    }
    else
    {
        return itemstack;
    }
}
 
Example 21
Project: minecraft-quiverbow   File: LapisMagazine.java   Source Code and License 5 votes vote down vote up
@Override
public void addRecipes() 
{
	GameRegistry.addRecipe(new ItemStack(this, 1, this.getMaxDamage()), "x x", "x x", "xgx",
	         'x', Blocks.glass_pane, 
	         'g', new ItemStack(Items.dye, 1, 4)
	 );
}
 
Example 22
Project: rezolve   File: SecurityServerBlock.java   Source Code and License 5 votes vote down vote up
@Override
public void registerRecipes() {
	RezolveMod.addRecipe(
		new ItemStack(this.itemBlock), 
		"oNo",
		"cRc",
		"oDo", 
		
		'o', Blocks.OBSIDIAN,
		'N', Items.NETHER_STAR,
		'c', RezolveMod.ETHERNET_CABLE_BLOCK,
		'R', RezolveMod.REMOTE_SHELL_BLOCK,
		'D', Items.IRON_DOOR
	);
}
 
Example 23
Project: CustomWorldGen   File: EntityRabbit.java   Source Code and License 5 votes vote down vote up
protected void initEntityAI()
{
    this.tasks.addTask(1, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityRabbit.AIPanic(this, 2.2D));
    this.tasks.addTask(2, new EntityAIMate(this, 0.8D));
    this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.CARROT, false));
    this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.GOLDEN_CARROT, false));
    this.tasks.addTask(3, new EntityAITempt(this, 1.0D, Item.getItemFromBlock(Blocks.YELLOW_FLOWER), false));
    this.tasks.addTask(4, new EntityRabbit.AIAvoidEntity(this, EntityPlayer.class, 8.0F, 2.2D, 2.2D));
    this.tasks.addTask(4, new EntityRabbit.AIAvoidEntity(this, EntityWolf.class, 10.0F, 2.2D, 2.2D));
    this.tasks.addTask(4, new EntityRabbit.AIAvoidEntity(this, EntityMob.class, 4.0F, 2.2D, 2.2D));
    this.tasks.addTask(5, new EntityRabbit.AIRaidFarm(this));
    this.tasks.addTask(6, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F));
}
 
Example 24
Project: Backmemed   File: BlockOldLeaf.java   Source Code and License 5 votes vote down vote up
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance)
{
    if (state.getValue(VARIANT) == BlockPlanks.EnumType.OAK && worldIn.rand.nextInt(chance) == 0)
    {
        spawnAsEntity(worldIn, pos, new ItemStack(Items.APPLE));
    }
}
 
Example 25
Project: CustomWorldGen   File: EntityAgeable.java   Source Code and License 5 votes vote down vote up
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (stack != null && stack.getItem() == Items.SPAWN_EGG)
    {
        if (!this.worldObj.isRemote)
        {
            Class <? extends Entity > oclass = EntityList.NAME_TO_CLASS.get(ItemMonsterPlacer.getEntityIdFromItem(stack));

            if (oclass != null && this.getClass() == oclass)
            {
                EntityAgeable entityageable = this.createChild(this);

                if (entityageable != null)
                {
                    entityageable.setGrowingAge(-24000);
                    entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
                    this.worldObj.spawnEntityInWorld(entityageable);

                    if (stack.hasDisplayName())
                    {
                        entityageable.setCustomNameTag(stack.getDisplayName());
                    }

                    if (!player.capabilities.isCreativeMode)
                    {
                        --stack.stackSize;
                    }
                }
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 26
Project: pnc-repressurized   File: PressureChamberPressureEnchantHandler.java   Source Code and License 5 votes vote down vote up
@Override
public NonNullList<ItemStack> craftRecipe(ItemStackHandler inputStacks) {
    ItemStack[] recipeIngredients = getRecipeIngredients(inputStacks);
    ItemStack enchantedTool = recipeIngredients[0];
    ItemStack enchantedBook = recipeIngredients[1];
    
    Map<Enchantment, Integer> bookMap = EnchantmentHelper.getEnchantments(enchantedBook);
    bookMap.forEach((enchant, lvl) -> enchantedTool.addEnchantment(enchant, lvl));
    
    enchantedBook.shrink(1);
    return NonNullList.from(ItemStack.EMPTY, new ItemStack(Items.BOOK));
}
 
Example 27
Project: Backmemed   File: BlockContainer.java   Source Code and License 5 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
    if (te instanceof IWorldNameable && ((IWorldNameable)te).hasCustomName())
    {
        player.addStat(StatList.getBlockStats(this));
        player.addExhaustion(0.005F);

        if (worldIn.isRemote)
        {
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        Item item = this.getItemDropped(state, worldIn.rand, i);

        if (item == Items.field_190931_a)
        {
            return;
        }

        ItemStack itemstack = new ItemStack(item, this.quantityDropped(worldIn.rand));
        itemstack.setStackDisplayName(((IWorldNameable)te).getName());
        spawnAsEntity(worldIn, pos, itemstack);
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack);
    }
}
 
Example 28
Project: CustomWorldGen   File: RecipesMapCloning.java   Source Code and License 5 votes vote down vote up
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    int i = 0;
    ItemStack itemstack = null;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (itemstack1 != null)
        {
            if (itemstack1.getItem() == Items.FILLED_MAP)
            {
                if (itemstack != null)
                {
                    return false;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.MAP)
                {
                    return false;
                }

                ++i;
            }
        }
    }

    return itemstack != null && i > 0;
}
 
Example 29
Project: DecompiledMinecraft   File: EntityVillager.java   Source Code and License 5 votes vote down vote up
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)];
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.enchanted_book.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.book), new ItemStack(Items.emerald, j), itemstack));
}
 
Example 30
Project: minecraft-quiverbow   File: Crossbow_Double.java   Source Code and License 5 votes vote down vote up
@Override
public void addRecipes()
{
	if (this.Enabled)
	{
		// One empty double crossbow (upgraded from regular crossbow)
		GameRegistry.addShapelessRecipe(new ItemStack(this, 1 , this.getMaxDamage()),
				Blocks.sticky_piston,
				Items.repeater,
				Helper.getWeaponStackByClass(Crossbow_Compact.class, true)
				);
	}
	else if (Main.noCreative) { this.setCreativeTab(null); }	// Not enabled and not allowed to be in the creative menu

	GameRegistry.addShapelessRecipe(new ItemStack(this),	// Fill the empty crossbow with two arrows
			Items.arrow,
			Items.arrow,
			new ItemStack(this, 1 , this.getMaxDamage())
			);

	GameRegistry.addShapelessRecipe(new ItemStack(this, 1, 1),	// Fill the empty crossbow with one arrow
			Items.arrow,
			new ItemStack(this, 1 , this.getMaxDamage())
			);

	GameRegistry.addShapelessRecipe(new ItemStack(this),	// Fill the half empty crossbow with one arrow
			Items.arrow,
			new ItemStack(this, 1 , 1)
			);
}
 
Example 31
Project: Backmemed   File: EntityPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    if ("Notch".equals(this.getName()))
    {
        this.dropItem(new ItemStack(Items.APPLE, 1), true, false);
    }

    if (!this.world.getGameRules().getBoolean("keepInventory") && !this.isSpectator())
    {
        this.func_190776_cN();
        this.inventory.dropAllItems();
    }

    if (cause != null)
    {
        this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 0.017453292F) * 0.1F);
        this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 0.017453292F) * 0.1F);
    }
    else
    {
        this.motionX = 0.0D;
        this.motionZ = 0.0D;
    }

    this.addStat(StatList.DEATHS);
    this.takeStat(StatList.TIME_SINCE_DEATH);
    this.extinguish();
    this.setFlag(0, false);
}
 
Example 32
Project: customstuff4   File: ItemFilterDeserializerTest.java   Source Code and License 5 votes vote down vote up
@Test
public void test_item()
{
    Map<String, ItemFilter> map = gson.fromJson("{\"filter\":\"minecraft:apple\"}", new TypeToken<Map<String, ItemFilter>>() {}.getType());

    ItemFilter filter = map.get("filter");

    assertTrue(filter.accepts(new ItemStack(Items.APPLE)));
    assertFalse(filter.accepts(new ItemStack(Items.GOLD_INGOT)));
}
 
Example 33
Project: nei-lotr   File: HaradTurbanOrnamentRecipeHandler.java   Source Code and License 5 votes vote down vote up
@Override
protected void loadUsageRecipeHandler(ItemStack ingredient) {
	if (ingredient.getItem() == Items.gold_nugget) {
		NeiLotrUtil.itemStackIteration((count,itemStack) -> {
			handleRecipe(itemStack, true);
		});
	} else {
		handleRecipe(ingredient, true);
	}
}
 
Example 34
Project: BaseClient   File: EntitySheep.java   Source Code and License 5 votes vote down vote up
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() == Items.shears && !this.getSheared() && !this.isChild())
    {
        if (!this.worldObj.isRemote)
        {
            this.setSheared(true);
            int i = 1 + this.rand.nextInt(3);

            for (int j = 0; j < i; ++j)
            {
                EntityItem entityitem = this.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, this.getFleeceColor().getMetadata()), 1.0F);
                entityitem.motionY += (double)(this.rand.nextFloat() * 0.05F);
                entityitem.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
                entityitem.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            }
        }

        itemstack.damageItem(1, player);
        this.playSound("mob.sheep.shear", 1.0F, 1.0F);
    }

    return super.interact(player);
}
 
Example 35
Project: ForgeHax   File: AutoLog.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) {
    if (MC.player != null) {
        int health = (int)(MC.player.getHealth() + MC.player.getAbsorptionAmount());
        if (health <= threshold.get() || (noTotem.getAsBoolean() && !((MC.player.getHeldItemOffhand().getItem() == Items.TOTEM_OF_UNDYING) || MC.player.getHeldItemMainhand().getItem() == Items.TOTEM_OF_UNDYING))) {
            AutoReconnectMod.hasAutoLogged = true;
            getNetworkManager().closeChannel(new TextComponentString("Health too low (" + health + ")"));
            disable();
        }
    }
}
 
Example 36
Project: BaseClient   File: EntityPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause)
{
    super.onDeath(cause);
    this.setSize(0.2F, 0.2F);
    this.setPosition(this.posX, this.posY, this.posZ);
    this.motionY = 0.10000000149011612D;

    if (this.getName().equals("Notch"))
    {
        this.dropItem(new ItemStack(Items.apple, 1), true, false);
    }

    if (!this.worldObj.getGameRules().getBoolean("keepInventory"))
    {
        this.inventory.dropAllItems();
    }

    if (cause != null)
    {
        this.motionX = (double)(-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
        this.motionZ = (double)(-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * (float)Math.PI / 180.0F) * 0.1F);
    }
    else
    {
        this.motionX = this.motionZ = 0.0D;
    }

    this.triggerAchievement(StatList.deathsStat);
    this.func_175145_a(StatList.timeSinceDeathStat);
}
 
Example 37
Project: Technical   File: CentrifugeRecipes.java   Source Code and License 5 votes vote down vote up
private CentrifugeRecipes() {
	
	this.addRecipe(new ItemStack[] { new ItemStack(TechnicalItem.BauxiteDust, 20), null, null },
			new ItemStack[] { new ItemStack(TechnicalItem.GibbsiteDust, 5), new ItemStack(TechnicalItem.BoehmiteDust, 5),
					new ItemStack(TechnicalItem.DiasporeDust, 5), new ItemStack(TechnicalItem.GoethiteDust, 2), new ItemStack(TechnicalItem.HematiteDust2, 2),
					new ItemStack(TechnicalItem.AnataseDust, 1) }, Tier.medium);
	this.addRecipe(new ItemStack[] { new ItemStack(TechnicalItem.ColtanDust, 2), null, null},
			new ItemStack[] { new ItemStack(TechnicalItem.ColumbiteDust, 1), new ItemStack(TechnicalItem.TantaliteDust, 1) }, Tier.advanced);
	this.addRecipe(new ItemStack[] { new ItemStack(TechnicalBlock.DirtGold, 14), new ItemStack(Items.water_bucket, 1), null },
			new ItemStack[] { new ItemStack(Blocks.dirt, 14), new ItemStack(Items.gold_nugget, 1), new ItemStack(Items.bucket, 1) }, Tier.normal);
	this.addRecipe(new ItemStack[] { new ItemStack(Blocks.dirt, 14), new ItemStack(Items.water_bucket, 1), null },
			new ItemStack[] { new ItemStack(Blocks.dirt, 14), new ItemStack(Items.bucket, 1) }, Tier.normal);
}
 
Example 38
Project: Backmemed   File: EntityPlayerSP.java   Source Code and License 5 votes vote down vote up
public void openBook(ItemStack stack, EnumHand hand)
{
    Item item = stack.getItem();

    if (item == Items.WRITABLE_BOOK)
    {
        this.mc.displayGuiScreen(new GuiScreenBook(this, stack, true));
    }
}
 
Example 39
Project: bit-client   File: ItemUtil.java   Source Code and License 5 votes vote down vote up
public static int getPotionSlot(boolean hotbarOnly) {
    try {
        int potSlot = (hotbarOnly ? player_itemSlotHotbar(Items.field_151068_bn) : player_itemSlot(Items.field_151068_bn));
        if (potSlot == -1) return -1;
        ItemStack potStack = Wrapper.player_inventoryItems()[potSlot];
        if (potStack == null) return -1;
        if (isHealthPot(potStack)) return potSlot;
        return -1;
    } catch (Exception e) {
        return -1;
    }
}
 
Example 40
Project: CustomWorldGen   File: ItemMap.java   Source Code and License 5 votes vote down vote up
protected static void scaleMap(ItemStack p_185063_0_, World p_185063_1_, int p_185063_2_)
{
    MapData mapdata = Items.FILLED_MAP.getMapData(p_185063_0_, p_185063_1_);
    p_185063_0_.setItemDamage(p_185063_1_.getUniqueDataId("map"));
    MapData mapdata1 = new MapData("map_" + p_185063_0_.getMetadata());
    mapdata1.scale = (byte)MathHelper.clamp_int(mapdata.scale + p_185063_2_, 0, 4);
    mapdata1.trackingPosition = mapdata.trackingPosition;
    mapdata1.calculateMapCenter((double)mapdata.xCenter, (double)mapdata.zCenter, mapdata1.scale);
    mapdata1.dimension = mapdata.dimension;
    mapdata1.markDirty();
    p_185063_1_.setItemData("map_" + p_185063_0_.getMetadata(), mapdata1);
}
 
Example 41
Project: DecompiledMinecraft   File: EntitySpider.java   Source Code and License 5 votes vote down vote up
/**
 * Drop 0-2 items of this living's type
 */
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
{
    super.dropFewItems(p_70628_1_, p_70628_2_);

    if (p_70628_1_ && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + p_70628_2_) > 0))
    {
        this.dropItem(Items.spider_eye, 1);
    }
}
 
Example 42
Project: Industrial-Foregoing   File: HydratorBlock.java   Source Code and License 5 votes vote down vote up
@Override
public void createRecipe() {
    RecipeUtils.addShapedRecipe(new ItemStack(this), "pfp", "cmc", "rir",
            'p', ItemRegistry.plastic,
            'f', Items.WATER_BUCKET,
            'r', "gearIron",
            'm', MachineCaseItem.INSTANCE,
            'i', Blocks.PISTON,
            'c', ItemRegistry.fertilizer);
}
 
Example 43
Project: BaseClient   File: EnchantmentHelper.java   Source Code and License 5 votes vote down vote up
/**
 * Set the enchantments for the specified stack.
 */
public static void setEnchantments(Map<Integer, Integer> enchMap, ItemStack stack)
{
    NBTTagList nbttaglist = new NBTTagList();
    Iterator iterator = enchMap.keySet().iterator();

    while (iterator.hasNext())
    {
        int i = ((Integer)iterator.next()).intValue();
        Enchantment enchantment = Enchantment.getEnchantmentById(i);

        if (enchantment != null)
        {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            nbttagcompound.setShort("id", (short)i);
            nbttagcompound.setShort("lvl", (short)((Integer)enchMap.get(Integer.valueOf(i))).intValue());
            nbttaglist.appendTag(nbttagcompound);

            if (stack.getItem() == Items.enchanted_book)
            {
                Items.enchanted_book.addEnchantment(stack, new EnchantmentData(enchantment, ((Integer)enchMap.get(Integer.valueOf(i))).intValue()));
            }
        }
    }

    if (nbttaglist.tagCount() > 0)
    {
        if (stack.getItem() != Items.enchanted_book)
        {
            stack.setTagInfo("ench", nbttaglist);
        }
    }
    else if (stack.hasTagCompound())
    {
        stack.getTagCompound().removeTag("ench");
    }
}
 
Example 44
Project: Technical   File: ElectrolyserRecipes.java   Source Code and License 5 votes vote down vote up
public static boolean isItemUsedInRecipe(ItemStack itemStack) {
	Item[] itemsUsed = new Item[] { Items.water_bucket, TechnicalItem.PyrolusiteDust, TechnicalItem.MagnesiumChlorideDust, TechnicalItem.BerylliumChlorideDust };
	for(Item item : itemsUsed)
		if(item == itemStack.getItem())
			return true;
	return false;
}
 
Example 45
Project: DecompiledMinecraft   File: EntityZombie.java   Source Code and License 5 votes vote down vote up
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player)
{
    ItemStack itemstack = player.getCurrentEquippedItem();

    if (itemstack != null && itemstack.getItem() == Items.golden_apple && itemstack.getMetadata() == 0 && this.isVillager() && this.isPotionActive(Potion.weakness))
    {
        if (!player.capabilities.isCreativeMode)
        {
            --itemstack.stackSize;
        }

        if (itemstack.stackSize <= 0)
        {
            player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null);
        }

        if (!this.worldObj.isRemote)
        {
            this.startConversion(this.rand.nextInt(2401) + 3600);
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 46
Project: DecompiledMinecraft   File: EntityItemFrame.java   Source Code and License 5 votes vote down vote up
/**
 * Removes the dot representing this frame's position from the map when the item frame is broken.
 */
private void removeFrameFromMap(ItemStack p_110131_1_)
{
    if (p_110131_1_ != null)
    {
        if (p_110131_1_.getItem() == Items.filled_map)
        {
            MapData mapdata = ((ItemMap)p_110131_1_.getItem()).getMapData(p_110131_1_, this.worldObj);
            mapdata.mapDecorations.remove("frame-" + this.getEntityId());
        }

        p_110131_1_.setItemFrame((EntityItemFrame)null);
    }
}
 
Example 47
Project: CustomWorldGen   File: BlockDoublePlant.java   Source Code and License 5 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
    {
        return null;
    }
    else
    {
        BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)state.getValue(VARIANT);
        return blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.FERN ? null : (blockdoubleplant$enumplanttype == BlockDoublePlant.EnumPlantType.GRASS ? (rand.nextInt(8) == 0 ? Items.WHEAT_SEEDS : null) : Item.getItemFromBlock(this));
    }
}
 
Example 48
Project: Technical   File: TileEntityCentrifugeMedium.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}
 
Example 49
Project: DecompiledMinecraft   File: SlotFurnaceFuel.java   Source Code and License 4 votes vote down vote up
public static boolean isBucket(ItemStack stack)
{
    return stack != null && stack.getItem() != null && stack.getItem() == Items.bucket;
}
 
Example 50
Project: BaseClient   File: RenderPotion.java   Source Code and License 4 votes vote down vote up
public RenderPotion(RenderManager renderManagerIn, RenderItem itemRendererIn)
{
    super(renderManagerIn, Items.potionitem, itemRendererIn);
}
 
Example 51
Project: DecompiledMinecraft   File: BlockRedstoneComparator.java   Source Code and License 4 votes vote down vote up
public Item getItem(World worldIn, BlockPos pos)
{
    return Items.comparator;
}
 
Example 52
Project: CustomWorldGen   File: BlockReed.java   Source Code and License 4 votes vote down vote up
/**
 * Get the Item that this Block should drop when harvested.
 */
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Items.REEDS;
}
 
Example 53
Project: Backmemed   File: TileEntityBrewingStand.java   Source Code and License 4 votes vote down vote up
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    ItemStack itemstack = (ItemStack)this.brewingItemStacks.get(4);

    if (this.fuel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER)
    {
        this.fuel = 20;
        itemstack.func_190918_g(1);
        this.markDirty();
    }

    boolean flag = this.canBrew();
    boolean flag1 = this.brewTime > 0;
    ItemStack itemstack1 = (ItemStack)this.brewingItemStacks.get(3);

    if (flag1)
    {
        --this.brewTime;
        boolean flag2 = this.brewTime == 0;

        if (flag2 && flag)
        {
            this.brewPotions();
            this.markDirty();
        }
        else if (!flag)
        {
            this.brewTime = 0;
            this.markDirty();
        }
        else if (this.ingredientID != itemstack1.getItem())
        {
            this.brewTime = 0;
            this.markDirty();
        }
    }
    else if (flag && this.fuel > 0)
    {
        --this.fuel;
        this.brewTime = 400;
        this.ingredientID = itemstack1.getItem();
        this.markDirty();
    }

    if (!this.world.isRemote)
    {
        boolean[] aboolean = this.createFilledSlotsArray();

        if (!Arrays.equals(aboolean, this.filledSlots))
        {
            this.filledSlots = aboolean;
            IBlockState iblockstate = this.world.getBlockState(this.getPos());

            if (!(iblockstate.getBlock() instanceof BlockBrewingStand))
            {
                return;
            }

            for (int i = 0; i < BlockBrewingStand.HAS_BOTTLE.length; ++i)
            {
                iblockstate = iblockstate.withProperty(BlockBrewingStand.HAS_BOTTLE[i], Boolean.valueOf(aboolean[i]));
            }

            this.world.setBlockState(this.pos, iblockstate, 2);
        }
    }
}
 
Example 54
Project: DecompiledMinecraft   File: EntityPlayer.java   Source Code and License 4 votes vote down vote up
public boolean replaceItemInInventory(int inventorySlot, ItemStack itemStackIn)
{
    if (inventorySlot >= 0 && inventorySlot < this.inventory.mainInventory.length)
    {
        this.inventory.setInventorySlotContents(inventorySlot, itemStackIn);
        return true;
    }
    else
    {
        int i = inventorySlot - 100;

        if (i >= 0 && i < this.inventory.armorInventory.length)
        {
            int k = i + 1;

            if (itemStackIn != null && itemStackIn.getItem() != null)
            {
                if (itemStackIn.getItem() instanceof ItemArmor)
                {
                    if (EntityLiving.getArmorPosition(itemStackIn) != k)
                    {
                        return false;
                    }
                }
                else if (k != 4 || itemStackIn.getItem() != Items.skull && !(itemStackIn.getItem() instanceof ItemBlock))
                {
                    return false;
                }
            }

            this.inventory.setInventorySlotContents(i + this.inventory.mainInventory.length, itemStackIn);
            return true;
        }
        else
        {
            int j = inventorySlot - 200;

            if (j >= 0 && j < this.theInventoryEnderChest.getSizeInventory())
            {
                this.theInventoryEnderChest.setInventorySlotContents(j, itemStackIn);
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
 
Example 55
Project: CustomWorldGen   File: EntityPotion.java   Source Code and License 4 votes vote down vote up
private boolean isLingering()
{
    return this.getPotion().getItem() == Items.LINGERING_POTION;
}
 
Example 56
Project: BaseClient   File: ContainerEnchantment.java   Source Code and License 4 votes vote down vote up
/**
 * Handles the given Button-click on the server, currently only used by enchanting. Name is for legacy.
 */
public boolean enchantItem(EntityPlayer playerIn, int id)
{
    ItemStack itemstack = this.tableInventory.getStackInSlot(0);
    ItemStack itemstack1 = this.tableInventory.getStackInSlot(1);
    int i = id + 1;

    if ((itemstack1 == null || itemstack1.stackSize < i) && !playerIn.capabilities.isCreativeMode)
    {
        return false;
    }
    else if (this.enchantLevels[id] > 0 && itemstack != null && (playerIn.experienceLevel >= i && playerIn.experienceLevel >= this.enchantLevels[id] || playerIn.capabilities.isCreativeMode))
    {
        if (!this.worldPointer.isRemote)
        {
            List<EnchantmentData> list = this.func_178148_a(itemstack, id, this.enchantLevels[id]);
            boolean flag = itemstack.getItem() == Items.book;

            if (list != null)
            {
                playerIn.removeExperienceLevel(i);

                if (flag)
                {
                    itemstack.setItem(Items.enchanted_book);
                }

                for (int j = 0; j < list.size(); ++j)
                {
                    EnchantmentData enchantmentdata = (EnchantmentData)list.get(j);

                    if (flag)
                    {
                        Items.enchanted_book.addEnchantment(itemstack, enchantmentdata);
                    }
                    else
                    {
                        itemstack.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel);
                    }
                }

                if (!playerIn.capabilities.isCreativeMode)
                {
                    itemstack1.stackSize -= i;

                    if (itemstack1.stackSize <= 0)
                    {
                        this.tableInventory.setInventorySlotContents(1, (ItemStack)null);
                    }
                }

                playerIn.triggerAchievement(StatList.field_181739_W);
                this.tableInventory.markDirty();
                this.xpSeed = playerIn.getXPSeed();
                this.onCraftMatrixChanged(this.tableInventory);
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 57
Project: BaseClient   File: EntityItem.java   Source Code and License 4 votes vote down vote up
/**
 * Called by a player entity when they collide with an entity
 */
public void onCollideWithPlayer(EntityPlayer entityIn)
{
    if (!this.worldObj.isRemote)
    {
        ItemStack itemstack = this.getEntityItem();
        int i = itemstack.stackSize;

        if (this.delayBeforeCanPickup == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityIn.getName())) && entityIn.inventory.addItemStackToInventory(itemstack))
        {
            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log))
            {
                entityIn.triggerAchievement(AchievementList.mineWood);
            }

            if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log2))
            {
                entityIn.triggerAchievement(AchievementList.mineWood);
            }

            if (itemstack.getItem() == Items.leather)
            {
                entityIn.triggerAchievement(AchievementList.killCow);
            }

            if (itemstack.getItem() == Items.diamond)
            {
                entityIn.triggerAchievement(AchievementList.diamonds);
            }

            if (itemstack.getItem() == Items.blaze_rod)
            {
                entityIn.triggerAchievement(AchievementList.blazeRod);
            }

            if (itemstack.getItem() == Items.diamond && this.getThrower() != null)
            {
                EntityPlayer entityplayer = this.worldObj.getPlayerEntityByName(this.getThrower());

                if (entityplayer != null && entityplayer != entityIn)
                {
                    entityplayer.triggerAchievement(AchievementList.diamondsToYou);
                }
            }

            if (!this.isSilent())
            {
                this.worldObj.playSoundAtEntity(entityIn, "random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
            }

            entityIn.onItemPickup(this, i);

            if (itemstack.stackSize <= 0)
            {
                this.setDead();
            }
        }
    }
}
 
Example 58
Project: harshencastle   File: HarshenUtils.java   Source Code and License 4 votes vote down vote up
public static boolean glassContainerHasBlock(GlassContainerValue glass)
{
	 return glassContainerHasState(glass)
			 && Item.getItemFromBlock(((IBlockState)glass.getType().getStateOrLoc()).getBlock()) != Items.AIR;
}
 
Example 59
Project: DecompiledMinecraft   File: BlockReed.java   Source Code and License 4 votes vote down vote up
public Item getItem(World worldIn, BlockPos pos)
{
    return Items.reeds;
}
 
Example 60
Project: CustomWorldGen   File: BlockTripWire.java   Source Code and License 4 votes vote down vote up
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
{
    return new ItemStack(Items.STRING);
}