当前位置: 首页>>代码示例>>Java>>正文


Java Items.SHIELD属性代码示例

本文整理汇总了Java中net.minecraft.init.Items.SHIELD属性的典型用法代码示例。如果您正苦于以下问题:Java Items.SHIELD属性的具体用法?Java Items.SHIELD怎么用?Java Items.SHIELD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.minecraft.init.Items的用法示例。


在下文中一共展示了Items.SHIELD属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: damageShield

protected void damageShield(float damage)
{
    if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD)
    {
        int i = 1 + MathHelper.floor(damage);
        this.activeItemStack.damageItem(i, this);

        if (this.activeItemStack.func_190926_b())
        {
            EnumHand enumhand = this.getActiveHand();

            if (enumhand == EnumHand.MAIN_HAND)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
            }
            else
            {
                this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a);
            }

            this.activeItemStack = ItemStack.field_190927_a;
            this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F);
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:25,代码来源:EntityPlayer.java

示例2: damageShield

protected void damageShield(float damage)
{
    if (damage >= 3.0F && this.activeItemStack != null && this.activeItemStack.getItem() == Items.SHIELD)
    {
        int i = 1 + MathHelper.floor_float(damage);
        this.activeItemStack.damageItem(i, this);

        if (this.activeItemStack.stackSize <= 0)
        {
            EnumHand enumhand = this.getActiveHand();
            net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this, this.activeItemStack, enumhand);

            if (enumhand == EnumHand.MAIN_HAND)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, (ItemStack)null);
            }
            else
            {
                this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, (ItemStack)null);
            }

            this.activeItemStack = null;
            this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.worldObj.rand.nextFloat() * 0.4F);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:EntityPlayer.java

示例3: getCraftingResult

public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = ItemStack.field_190927_a;
    ItemStack itemstack1 = ItemStack.field_190927_a;

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack2 = inv.getStackInSlot(i);

        if (!itemstack2.func_190926_b())
        {
            if (itemstack2.getItem() == Items.BANNER)
            {
                itemstack = itemstack2;
            }
            else if (itemstack2.getItem() == Items.SHIELD)
            {
                itemstack1 = itemstack2.copy();
            }
        }
    }

    if (itemstack1.func_190926_b())
    {
        return itemstack1;
    }
    else
    {
        NBTTagCompound nbttagcompound = itemstack.getSubCompound("BlockEntityTag");
        NBTTagCompound nbttagcompound1 = nbttagcompound == null ? new NBTTagCompound() : nbttagcompound.copy();
        nbttagcompound1.setInteger("Base", itemstack.getMetadata() & 15);
        itemstack1.setTagInfo("BlockEntityTag", nbttagcompound1);
        return itemstack1;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:35,代码来源:ShieldRecipes.java

示例4: getSlotForItemStack

public static EntityEquipmentSlot getSlotForItemStack(ItemStack stack)
{
    return stack.getItem() != Item.getItemFromBlock(Blocks.PUMPKIN) && stack.getItem() != Items.SKULL ? (stack.getItem() instanceof ItemArmor ? ((ItemArmor)stack.getItem()).armorType : (stack.getItem() == Items.ELYTRA ? EntityEquipmentSlot.CHEST : (stack.getItem() == Items.SHIELD ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND))) : EntityEquipmentSlot.HEAD;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:4,代码来源:EntityLiving.java

示例5: attackEntityAsMob

public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : ItemStack.field_190927_a;

            if (!itemstack.func_190926_b() && !itemstack1.func_190926_b() && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.world.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:EntityMob.java

示例6: matches

public boolean matches(InventoryCrafting inv, World worldIn)
{
    ItemStack itemstack = ItemStack.field_190927_a;
    ItemStack itemstack1 = ItemStack.field_190927_a;

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack2 = inv.getStackInSlot(i);

        if (!itemstack2.func_190926_b())
        {
            if (itemstack2.getItem() == Items.BANNER)
            {
                if (!itemstack1.func_190926_b())
                {
                    return false;
                }

                itemstack1 = itemstack2;
            }
            else
            {
                if (itemstack2.getItem() != Items.SHIELD)
                {
                    return false;
                }

                if (!itemstack.func_190926_b())
                {
                    return false;
                }

                if (itemstack2.getSubCompound("BlockEntityTag") != null)
                {
                    return false;
                }

                itemstack = itemstack2;
            }
        }
    }

    if (!itemstack.func_190926_b() && !itemstack1.func_190926_b())
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:51,代码来源:ShieldRecipes.java

示例7: renderByItem

public void renderByItem(ItemStack itemStackIn)
{
    Item item = itemStackIn.getItem();

    if (item == Items.BANNER)
    {
        this.banner.setItemValues(itemStackIn, false);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (item == Items.SHIELD)
    {
        if (itemStackIn.getSubCompound("BlockEntityTag") != null)
        {
            this.banner.setItemValues(itemStackIn, true);
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
        }
        else
        {
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
        }

        GlStateManager.pushMatrix();
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        this.modelShield.render();
        GlStateManager.popMatrix();
    }
    else if (item == Items.SKULL)
    {
        GameProfile gameprofile = null;

        if (itemStackIn.hasTagCompound())
        {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            if (nbttagcompound.hasKey("SkullOwner", 10))
            {
                gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
            }
            else if (nbttagcompound.hasKey("SkullOwner", 8) && !StringUtils.isBlank(nbttagcompound.getString("SkullOwner")))
            {
                GameProfile gameprofile1 = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
                gameprofile = TileEntitySkull.updateGameprofile(gameprofile1);
                nbttagcompound.removeTag("SkullOwner");
                nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
            }
        }

        if (TileEntitySkullRenderer.instance != null)
        {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 180.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    else if (item == Item.getItemFromBlock(Blocks.ENDER_CHEST))
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (item == Item.getItemFromBlock(Blocks.TRAPPED_CHEST))
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (Block.getBlockFromItem(item) instanceof BlockShulkerBox)
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(field_191274_b[BlockShulkerBox.func_190955_b(item).getMetadata()], 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else
    {
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:73,代码来源:TileEntityItemStackRenderer.java

示例8: attackEntityAsMob

@Override
public boolean attackEntityAsMob(Entity entityIn) {
	float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
	int i = 0;

	if (entityIn instanceof EntityLivingBase) {
		f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
				((EntityLivingBase) entityIn).getCreatureAttribute());
		i += EnchantmentHelper.getKnockbackModifier(this);
	}

	boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

	if (flag) {
		if (i > 0 && entityIn instanceof EntityLivingBase) {
			((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
					(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
			this.motionX *= 0.6D;
			this.motionZ *= 0.6D;
		}

		int j = EnchantmentHelper.getFireAspectModifier(this);

		if (j > 0)
			entityIn.setFire(j * 4);

		if (entityIn instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityIn;
			ItemStack itemstack = this.getHeldItemMainhand();
			ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

			if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
					&& itemstack1.getItem() == Items.SHIELD) {
				float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

				if (this.rand.nextFloat() < f1) {
					entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
					this.world.setEntityState(entityplayer, (byte) 30);
				}
			}
		}

		this.applyEnchantments(this, entityIn);
	}

	return flag;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:47,代码来源:EntityTF2Character.java

示例9: attackEntityAsMob

@Override
public boolean attackEntityAsMob(Entity entityIn) {
	float f = (float) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
	int i = 0;

	if (entityIn instanceof EntityLivingBase) {
		f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(),
				((EntityLivingBase) entityIn).getCreatureAttribute());
		i += EnchantmentHelper.getKnockbackModifier(this);
	}

	boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

	if (flag) {
		if (i > 0 && entityIn instanceof EntityLivingBase) {
			((EntityLivingBase) entityIn).knockBack(this, i * 0.5F, MathHelper.sin(this.rotationYaw * 0.017453292F),
					(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
			this.motionX *= 0.6D;
			this.motionZ *= 0.6D;
		}

		int j = EnchantmentHelper.getFireAspectModifier(this);

		if (j > 0)
			entityIn.setFire(j * 4);

		if (entityIn instanceof EntityPlayer) {
			EntityPlayer entityplayer = (EntityPlayer) entityIn;
			ItemStack itemstack = this.getHeldItemMainhand();
			ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

			if (!itemstack.isEmpty() && itemstack1 != null && itemstack.getItem() instanceof ItemAxe
					&& itemstack1.getItem() == Items.SHIELD) {
				float f1 = 0.25F + EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

				if (this.rand.nextFloat() < f1) {
					entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
					this.world.setEntityState(entityplayer, (byte) 30);
				}
			}
		}

		this.applyEnchantments(this, entityIn);

		if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).getHealth() <= 0)
			if (entityIn instanceof EntityBuilding)
				this.playSound(TF2Sounds.MOB_SAXTON_DESTROY, 2.2F, 1f);
			else
				this.playSound(TF2Sounds.MOB_SAXTON_KILL, 2.2F, 1f);
	}

	return flag;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:53,代码来源:EntitySaxtonHale.java

示例10: attackEntityAsMob

public boolean attackEntityAsMob(Entity entityIn)
{
    float f = (float)this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue();
    int i = 0;

    if (entityIn instanceof EntityLivingBase)
    {
        f += EnchantmentHelper.getModifierForCreature(this.getHeldItemMainhand(), ((EntityLivingBase)entityIn).getCreatureAttribute());
        i += EnchantmentHelper.getKnockbackModifier(this);
    }

    boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), f);

    if (flag)
    {
        if (i > 0 && entityIn instanceof EntityLivingBase)
        {
            ((EntityLivingBase)entityIn).knockBack(this, (float)i * 0.5F, (double)MathHelper.sin(this.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.rotationYaw * 0.017453292F)));
            this.motionX *= 0.6D;
            this.motionZ *= 0.6D;
        }

        int j = EnchantmentHelper.getFireAspectModifier(this);

        if (j > 0)
        {
            entityIn.setFire(j * 4);
        }

        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            ItemStack itemstack = this.getHeldItemMainhand();
            ItemStack itemstack1 = entityplayer.isHandActive() ? entityplayer.getActiveItemStack() : null;

            if (itemstack != null && itemstack1 != null && itemstack.getItem() instanceof ItemAxe && itemstack1.getItem() == Items.SHIELD)
            {
                float f1 = 0.25F + (float)EnchantmentHelper.getEfficiencyModifier(this) * 0.05F;

                if (this.rand.nextFloat() < f1)
                {
                    entityplayer.getCooldownTracker().setCooldown(Items.SHIELD, 100);
                    this.worldObj.setEntityState(entityplayer, (byte)30);
                }
            }
        }

        this.applyEnchantments(this, entityIn);
    }

    return flag;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:52,代码来源:EntityMob.java

示例11: matches

/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    ItemStack itemstack = null;
    ItemStack itemstack1 = null;

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack2 = inv.getStackInSlot(i);

        if (itemstack2 != null)
        {
            if (itemstack2.getItem() == Items.BANNER)
            {
                if (itemstack1 != null)
                {
                    return false;
                }

                itemstack1 = itemstack2;
            }
            else
            {
                if (itemstack2.getItem() != Items.SHIELD)
                {
                    return false;
                }

                if (itemstack != null)
                {
                    return false;
                }

                if (itemstack2.getSubCompound("BlockEntityTag", false) != null)
                {
                    return false;
                }

                itemstack = itemstack2;
            }
        }
    }

    if (itemstack != null && itemstack1 != null)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:54,代码来源:ShieldRecipes.java

示例12: renderByItem

public void renderByItem(ItemStack itemStackIn)
{
    if (itemStackIn.getItem() == Items.BANNER)
    {
        this.banner.setItemValues(itemStackIn);
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
    }
    else if (itemStackIn.getItem() == Items.SHIELD)
    {
        if (itemStackIn.getSubCompound("BlockEntityTag", false) != null)
        {
            this.banner.setItemValues(itemStackIn);
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
        }
        else
        {
            Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
        }

        GlStateManager.pushMatrix();
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        this.modelShield.render();
        GlStateManager.popMatrix();
    }
    else if (itemStackIn.getItem() == Items.SKULL)
    {
        GameProfile gameprofile = null;

        if (itemStackIn.hasTagCompound())
        {
            NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();

            if (nbttagcompound.hasKey("SkullOwner", 10))
            {
                gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
            }
            else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
            {
                GameProfile lvt_2_2_ = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
                gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
                nbttagcompound.removeTag("SkullOwner");
                nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
            }
        }

        if (TileEntitySkullRenderer.instance != null)
        {
            GlStateManager.pushMatrix();
            GlStateManager.disableCull();
            TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
            GlStateManager.enableCull();
            GlStateManager.popMatrix();
        }
    }
    else
    {
        Block block = Block.getBlockFromItem(itemStackIn.getItem());

        if (block == Blocks.ENDER_CHEST)
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
        }
        else if (block == Blocks.TRAPPED_CHEST)
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
        }
        else if (block != Blocks.CHEST) net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());
        else
        {
            TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:73,代码来源:TileEntityItemStackRenderer.java


注:本文中的net.minecraft.init.Items.SHIELD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。