本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getItemStackFromSlot方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getItemStackFromSlot方法的具体用法?Java EntityLivingBase.getItemStackFromSlot怎么用?Java EntityLivingBase.getItemStackFromSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getItemStackFromSlot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdate
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onUpdate(LivingEvent.LivingUpdateEvent ev) {
EntityLivingBase entity = ev.getEntityLiving();
for (EntityEquipmentSlot slot : armor) {
Map<UUID, AbilitySeries> associated = map.get(slot);
ItemStack stack = entity.getItemStackFromSlot(slot);
if (!stack.isEmpty() && RandoresItemData.hasData(stack) && stack.getItem() instanceof RandoresItemArmor && EmpoweredEnchantment.appliedTo(stack)) {
RandoresWorldData.delegateVoid(new RandoresItemData(stack), def -> {
associated.put(entity.getPersistentID(), def.getAbilitySeries());
def.getAbilitySeries().onArmorUpdate(entity);
}, () -> {});
} else if (associated.containsKey(entity.getPersistentID())) {
associated.remove(entity.getPersistentID()).onArmorCancel(entity);
}
}
}
示例2: getEntityEquipment
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public List<ItemStack> getEntityEquipment(EntityLivingBase entityIn)
{
List<ItemStack> list = Lists.<ItemStack>newArrayList();
for (EntityEquipmentSlot entityequipmentslot : this.applicableEquipmentTypes)
{
ItemStack itemstack = entityIn.getItemStackFromSlot(entityequipmentslot);
if (!itemstack.func_190926_b())
{
list.add(itemstack);
}
}
return list;
}
示例3: getEntityEquipment
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Nullable
public Iterable<ItemStack> getEntityEquipment(EntityLivingBase entityIn)
{
List<ItemStack> list = Lists.<ItemStack>newArrayList();
for (EntityEquipmentSlot entityequipmentslot : this.applicableEquipmentTypes)
{
ItemStack itemstack = entityIn.getItemStackFromSlot(entityequipmentslot);
if (itemstack != null)
{
list.add(itemstack);
}
}
return list.size() > 0 ? list : null;
}
示例4: apply
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public boolean apply(@Nullable Entity p_apply_1_)
{
if (!p_apply_1_.isEntityAlive())
{
return false;
}
else if (!(p_apply_1_ instanceof EntityLivingBase))
{
return false;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)p_apply_1_;
return entitylivingbase.getItemStackFromSlot(EntityLiving.getSlotForItemStack(this.armor)) != null ? false : (entitylivingbase instanceof EntityLiving ? ((EntityLiving)entitylivingbase).canPickUpLoot() : (entitylivingbase instanceof EntityArmorStand ? true : entitylivingbase instanceof EntityPlayer));
}
}
示例5: onEntityUpdate
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityUpdate(LivingUpdateEvent event)
{
EntityLivingBase living = event.getEntityLiving();
if(living instanceof IBurnInDay && living.world.isDaytime() && !living.world.isRemote && !living.isChild() && ((IBurnInDay)living).shouldBurn() && living.getBrightness() > 0.5F &&
living.getRNG().nextFloat() * 30.0F < (living.getBrightness() - 0.4F) * 2.0F && living.world.canSeeSky(new BlockPos(living.posX, living.posY + (double)living.getEyeHeight(), living.posZ)))
{
boolean flag = true;
ItemStack itemstack = living.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!itemstack.isEmpty())
{
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(itemstack.getItemDamage() + living.getRNG().nextInt(2));
if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
{
living.renderBrokenItemStack(itemstack);
living.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY);
}
}
flag = false;
}
if (flag)
{
living.setFire(8);
}
}
}
示例6: doArmor
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void doArmor(EntityLivingBase hurt, EntityLivingBase cause) {
for (EntityEquipmentSlot slot : armorSlots) {
if (!hurt.getItemStackFromSlot(slot).isEmpty() && EmpoweredEnchantment.appliedTo(hurt.getItemStackFromSlot(slot))) {
ItemStack stack = hurt.getItemStackFromSlot(slot);
if(RandoresItemData.hasData(stack)) {
RandoresWorldData.delegateVoid(new RandoresItemData(stack), definition -> definition.getAbilitySeries().onArmorHit(hurt, cause), () -> {});
}
}
}
}
示例7: doPassiveArmor
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void doPassiveArmor(EntityLivingBase entity) {
for (EntityEquipmentSlot slot : armorSlots) {
if (!entity.getItemStackFromSlot(slot).isEmpty() && EmpoweredEnchantment.appliedTo(entity.getItemStackFromSlot(slot))) {
ItemStack stack = entity.getItemStackFromSlot(slot);
if(RandoresItemData.hasData(stack)) {
RandoresWorldData.delegateVoid(new RandoresItemData(stack), definition -> definition.getAbilitySeries().onArmorUpdate(entity), () -> {});
}
}
}
}
示例8: getWearingSetCount
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/** Get how many pieces of armor of a specified type the entity is wearing */
public static int getWearingSetCount(EntityLivingBase entity, Class<? extends ItemArmor> armorClass) {
ItemStack HEAD, CHEST, LEGS, FEET;
HEAD = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
CHEST = entity.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LEGS = entity.getItemStackFromSlot(EntityEquipmentSlot.LEGS);
FEET = entity.getItemStackFromSlot(EntityEquipmentSlot.FEET);
boolean helm = !HEAD.isEmpty() && armorClass.isInstance(HEAD.getItem());
boolean chest = !CHEST.isEmpty() && armorClass.isInstance(CHEST.getItem());
boolean legs = !LEGS.isEmpty() && armorClass.isInstance(LEGS.getItem());
boolean boots = !FEET.isEmpty() && armorClass.isInstance(FEET.getItem());
return (helm ? 1 : 0) + (chest ? 1 : 0) + (legs ? 1 : 0) + (boots ? 1 : 0);
}
示例9: isWearingCustomSkull
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static boolean isWearingCustomSkull(EntityLivingBase entity) {
return entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD) != null && entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD).getItem() instanceof ItemSkullBase;
}
示例10: doRenderLayer
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
if (entitylivingbaseIn instanceof AbstractClientPlayer)
{
AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer)entitylivingbaseIn;
if (abstractclientplayer.isPlayerInfoSet() && abstractclientplayer.getLocationElytra() != null)
{
this.renderPlayer.bindTexture(abstractclientplayer.getLocationElytra());
}
else if (abstractclientplayer.hasElytraCape() && abstractclientplayer.hasPlayerInfo() && abstractclientplayer.getLocationCape() != null && abstractclientplayer.isWearing(EnumPlayerModelParts.CAPE))
{
this.renderPlayer.bindTexture(abstractclientplayer.getLocationCape());
}
else
{
ResourceLocation resourcelocation1 = TEXTURE_ELYTRA;
if (Config.isCustomItems())
{
resourcelocation1 = CustomItems.getCustomElytraTexture(itemstack, resourcelocation1);
}
this.renderPlayer.bindTexture(resourcelocation1);
}
}
else
{
ResourceLocation resourcelocation = TEXTURE_ELYTRA;
if (Config.isCustomItems())
{
resourcelocation = CustomItems.getCustomElytraTexture(itemstack, resourcelocation);
}
this.renderPlayer.bindTexture(resourcelocation);
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, 0.125F);
this.modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entitylivingbaseIn);
this.modelElytra.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
if (itemstack.isItemEnchanted())
{
LayerArmorBase.renderEnchantedGlint(this.renderPlayer, entitylivingbaseIn, this.modelElytra, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
示例11: doRenderLayer
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!itemstack.func_190926_b())
{
Item item = itemstack.getItem();
Minecraft minecraft = Minecraft.getMinecraft();
GlStateManager.pushMatrix();
if (entitylivingbaseIn.isSneaking())
{
GlStateManager.translate(0.0F, 0.2F, 0.0F);
}
boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager;
if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager))
{
float f = 2.0F;
float f1 = 1.4F;
GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
GlStateManager.scale(0.7F, 0.7F, 0.7F);
GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
}
this.modelRenderer.postRender(0.0625F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (item == Items.SKULL)
{
float f2 = 1.1875F;
GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);
if (flag)
{
GlStateManager.translate(0.0F, 0.0625F, 0.0F);
}
GameProfile gameprofile = null;
if (itemstack.hasTagCompound())
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8))
{
String s = nbttagcompound.getString("SkullOwner");
if (!StringUtils.isBlank(s))
{
gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
}
}
}
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing);
}
else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD)
{
float f3 = 0.625F;
GlStateManager.translate(0.0F, -0.25F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.625F, -0.625F, -0.625F);
if (flag)
{
GlStateManager.translate(0.0F, 0.1875F, 0.0F);
}
minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
}
GlStateManager.popMatrix();
}
}
示例12: getLightLevel
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static int getLightLevel(Entity p_getLightLevel_0_)
{
if (p_getLightLevel_0_ == Config.getMinecraft().getRenderViewEntity() && !Config.isDynamicHandLight())
{
return 0;
}
else
{
if (p_getLightLevel_0_ instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)p_getLightLevel_0_;
if (entityplayer.isSpectator())
{
return 0;
}
}
if (p_getLightLevel_0_.isBurning())
{
return 15;
}
else if (p_getLightLevel_0_ instanceof EntityFireball)
{
return 15;
}
else if (p_getLightLevel_0_ instanceof EntityTNTPrimed)
{
return 15;
}
else if (p_getLightLevel_0_ instanceof EntityBlaze)
{
EntityBlaze entityblaze = (EntityBlaze)p_getLightLevel_0_;
return entityblaze.isCharged() ? 15 : 10;
}
else if (p_getLightLevel_0_ instanceof EntityMagmaCube)
{
EntityMagmaCube entitymagmacube = (EntityMagmaCube)p_getLightLevel_0_;
return (double)entitymagmacube.squishFactor > 0.6D ? 13 : 8;
}
else
{
if (p_getLightLevel_0_ instanceof EntityCreeper)
{
EntityCreeper entitycreeper = (EntityCreeper)p_getLightLevel_0_;
if ((double)entitycreeper.getCreeperFlashIntensity(0.0F) > 0.001D)
{
return 15;
}
}
if (p_getLightLevel_0_ instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)p_getLightLevel_0_;
ItemStack itemstack3 = entitylivingbase.getHeldItemMainhand();
int i = getLightLevel(itemstack3);
ItemStack itemstack1 = entitylivingbase.getHeldItemOffhand();
int j = getLightLevel(itemstack1);
ItemStack itemstack2 = entitylivingbase.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
int k = getLightLevel(itemstack2);
int l = Math.max(i, j);
return Math.max(l, k);
}
else if (p_getLightLevel_0_ instanceof EntityItem)
{
EntityItem entityitem = (EntityItem)p_getLightLevel_0_;
ItemStack itemstack = getItemStack(entityitem);
return getLightLevel(itemstack);
}
else
{
return 0;
}
}
}
}
示例13: getBackpack
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static ItemStack getBackpack(EntityLivingBase living) {
return !living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty()
&& living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() instanceof ItemSoldierBackpack
? living.getItemStackFromSlot(EntityEquipmentSlot.CHEST) : ItemStack.EMPTY;
}
示例14: getItemStackFromSlot
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Nullable
public ItemStack getItemStackFromSlot(EntityLivingBase living, EntityEquipmentSlot slotIn)
{
return living.getItemStackFromSlot(slotIn);
}
示例15: doRenderLayer
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (itemstack != null && itemstack.getItem() != null)
{
Item item = itemstack.getItem();
Minecraft minecraft = Minecraft.getMinecraft();
GlStateManager.pushMatrix();
if (entitylivingbaseIn.isSneaking())
{
GlStateManager.translate(0.0F, 0.2F, 0.0F);
}
boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombie && ((EntityZombie)entitylivingbaseIn).isVillager();
if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager))
{
float f = 2.0F;
float f1 = 1.4F;
GlStateManager.translate(0.0F, 0.5F * scale, 0.0F);
GlStateManager.scale(0.7F, 0.7F, 0.7F);
GlStateManager.translate(0.0F, 16.0F * scale, 0.0F);
}
this.modelRenderer.postRender(0.0625F);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (item == Items.SKULL)
{
float f2 = 1.1875F;
GlStateManager.scale(1.1875F, -1.1875F, -1.1875F);
if (flag)
{
GlStateManager.translate(0.0F, 0.0625F, 0.0F);
}
GameProfile gameprofile = null;
if (itemstack.hasTagCompound())
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8))
{
String s = nbttagcompound.getString("SkullOwner");
if (!StringUtils.isNullOrEmpty(s))
{
gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s));
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
}
}
}
TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing);
}
else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD)
{
float f3 = 0.625F;
GlStateManager.translate(0.0F, -0.25F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.scale(0.625F, -0.625F, -0.625F);
if (flag)
{
GlStateManager.translate(0.0F, 0.1875F, 0.0F);
}
minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD);
}
GlStateManager.popMatrix();
}
}