本文整理汇总了Java中net.minecraft.item.ItemStack.isItemStackDamageable方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.isItemStackDamageable方法的具体用法?Java ItemStack.isItemStackDamageable怎么用?Java ItemStack.isItemStackDamageable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.isItemStackDamageable方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performEffect
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
EnumHand hand = null;
if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
if (hand != null) {
ItemStack stack = entity.getHeldItem(hand).copy();
entity.setHeldItem(hand, ItemStack.EMPTY);
if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
}
EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
ei.setPickupDelay(200);
ei.setNoDespawn();
if (!world.isRemote) world.spawnEntity(ei);
}
}
}
示例2: getContainerItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ItemStack getContainerItem(ItemStack stack)
{
if (stack == null) return null;
if (stack.getItem().hasContainerItem(stack))
{
stack = stack.getItem().getContainerItem(stack);
if (stack != null && stack.isItemStackDamageable() && stack.getMetadata() > stack.getMaxDamage())
{
ForgeEventFactory.onPlayerDestroyItem(craftingPlayer.get(), stack, null);
return null;
}
return stack;
}
return null;
}
示例3: apply
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack apply(ItemStack stack, Random rand, LootContext context)
{
if (stack.isItemStackDamageable())
{
float f = 1.0F - this.damageRange.generateFloat(rand);
stack.setItemDamage(MathHelper.floor(f * (float)stack.getMaxDamage()));
}
else
{
LOGGER.warn("Couldn\'t set damage of loot item {}", new Object[] {stack});
}
return stack;
}
示例4: onEntityUpdate
import net.minecraft.item.ItemStack; //导入方法依赖的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);
}
}
}
示例5: updateTick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* The update tick for the ingame UI
*/
public void updateTick() {
if (this.recordPlayingUpFor > 0) {
--this.recordPlayingUpFor;
}
if (this.field_175195_w > 0) {
--this.field_175195_w;
if (this.field_175195_w <= 0) {
this.field_175201_x = "";
this.field_175200_y = "";
}
}
++this.updateCounter;
this.streamIndicator.func_152439_a();
if (this.mc.thePlayer != null) {
ItemStack itemstack = this.mc.thePlayer.inventory.getCurrentItem();
if (itemstack == null) {
this.remainingHighlightTicks = 0;
} else if (this.highlightingItemStack != null && itemstack.getItem() == this.highlightingItemStack.getItem()
&& ItemStack.areItemStackTagsEqual(itemstack, this.highlightingItemStack)
&& (itemstack.isItemStackDamageable()
|| itemstack.getMetadata() == this.highlightingItemStack.getMetadata())) {
if (this.remainingHighlightTicks > 0) {
--this.remainingHighlightTicks;
}
} else {
this.remainingHighlightTicks = 40;
}
this.highlightingItemStack = itemstack;
}
}
示例6: isHittingPosition
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isHittingPosition(BlockPos pos)
{
ItemStack itemstack = this.mc.player.getHeldItemMainhand();
boolean flag = this.currentItemHittingBlock.func_190926_b() && itemstack.func_190926_b();
if (!this.currentItemHittingBlock.func_190926_b() && !itemstack.func_190926_b())
{
flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
}
return pos.equals(this.currentBlock) && flag;
}
示例7: onLivingUpdate
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
if (this.worldObj.isDaytime() && !this.worldObj.isRemote)
{
float f = this.getBrightness(1.0F);
BlockPos blockpos = new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);
if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
{
boolean flag = true;
ItemStack itemstack = this.getEquipmentInSlot(4);
if (itemstack != null)
{
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
{
this.renderBrokenItemStack(itemstack);
this.setCurrentItemOrArmor(4, (ItemStack)null);
}
}
flag = false;
}
if (flag)
{
this.setFire(8);
}
}
}
if (this.worldObj.isRemote && this.getSkeletonType() == 1)
{
this.setSize(0.72F, 2.535F);
}
super.onLivingUpdate();
}
示例8: canApply
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Determines if this enchantment can be applied to a specific ItemStack.
*/
public boolean canApply(ItemStack stack)
{
return stack.isItemStackDamageable() ? true : super.canApply(stack);
}
示例9: onLivingUpdate
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
* use this to react to sunlight and start to burn.
*/
public void onLivingUpdate()
{
if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild())
{
float f = this.getBrightness(1.0F);
BlockPos blockpos = new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ);
if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canSeeSky(blockpos))
{
boolean flag = true;
ItemStack itemstack = this.getEquipmentInSlot(4);
if (itemstack != null)
{
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
{
this.renderBrokenItemStack(itemstack);
this.setCurrentItemOrArmor(4, (ItemStack)null);
}
}
flag = false;
}
if (flag)
{
this.setFire(8);
}
}
}
if (this.isRiding() && this.getAttackTarget() != null && this.ridingEntity instanceof EntityChicken)
{
((EntityLiving)this.ridingEntity).getNavigator().setPath(this.getNavigator().getPath(), 1.5D);
}
super.onLivingUpdate();
}
示例10: processRightClick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public EnumActionResult processRightClick(EntityPlayer player, World worldIn, ItemStack stack, EnumHand hand)
{
if (this.gameType == GameType.SPECTATOR)
{
return EnumActionResult.PASS;
}
else if (player.getCooldownTracker().hasCooldown(stack.getItem()))
{
return EnumActionResult.PASS;
}
else
{
if (net.minecraftforge.common.ForgeHooks.onItemRightClick(player, hand, stack)) return net.minecraft.util.EnumActionResult.PASS;
int i = stack.stackSize;
int j = stack.getMetadata();
ActionResult<ItemStack> actionresult = stack.useItemRightClick(worldIn, player, hand);
ItemStack itemstack = (ItemStack)actionresult.getResult();
if (itemstack == stack && itemstack.stackSize == i && itemstack.getMaxItemUseDuration() <= 0 && itemstack.getMetadata() == j)
{
return actionresult.getType();
}
else
{
player.setHeldItem(hand, itemstack);
if (this.isCreative())
{
itemstack.stackSize = i;
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.stackSize == 0)
{
player.setHeldItem(hand, (ItemStack)null);
net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(player, itemstack, hand);
}
if (!player.isHandActive())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return actionresult.getType();
}
}
}
示例11: dropEquipment
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Drop the equipment for this entity.
*/
protected void dropEquipment(boolean wasRecentlyHit, int lootingModifier)
{
for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
{
ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);
double d0;
switch (entityequipmentslot.getSlotType())
{
case HAND:
d0 = (double)this.inventoryHandsDropChances[entityequipmentslot.getIndex()];
break;
case ARMOR:
d0 = (double)this.inventoryArmorDropChances[entityequipmentslot.getIndex()];
break;
default:
d0 = 0.0D;
}
boolean flag = d0 > 1.0D;
if (itemstack != null && (wasRecentlyHit || flag) && (double)(this.rand.nextFloat() - (float)lootingModifier * 0.01F) < d0)
{
if (!flag && itemstack.isItemStackDamageable())
{
int i = Math.max(itemstack.getMaxDamage() - 25, 1);
int j = itemstack.getMaxDamage() - this.rand.nextInt(this.rand.nextInt(i) + 1);
if (j > i)
{
j = i;
}
if (j < 1)
{
j = 1;
}
itemstack.setItemDamage(j);
}
this.entityDropItem(itemstack, 0.0F);
}
}
}
示例12: getMetadata
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
protected int getMetadata(ItemStack stack)
{
return stack.isItemStackDamageable() ? 0 : stack.getMetadata();
}
示例13: damageAndDrop
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static EntityItem damageAndDrop(EntityCreature entity, ItemStack stack) {
if (stack.isItemStackDamageable()) {
stack.setItemDamage(stack.getMaxDamage() - entity.getRNG().nextInt(1 + entity.getRNG().nextInt(Math.max(stack.getMaxDamage() - 3, 1))));
}
return drop(entity, stack);
}
示例14: tryUseItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Attempts to right-click use an item by the given EntityPlayer in the given World
*/
public boolean tryUseItem(EntityPlayer player, World worldIn, ItemStack stack)
{
if (this.gameType == WorldSettings.GameType.SPECTATOR)
{
return false;
}
else
{
int i = stack.stackSize;
int j = stack.getMetadata();
ItemStack itemstack = stack.useItemRightClick(worldIn, player);
if (itemstack != stack || itemstack != null && (itemstack.stackSize != i || itemstack.getMaxItemUseDuration() > 0 || itemstack.getMetadata() != j))
{
player.inventory.mainInventory[player.inventory.currentItem] = itemstack;
if (this.isCreative())
{
itemstack.stackSize = i;
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(j);
}
}
if (itemstack.stackSize == 0)
{
player.inventory.mainInventory[player.inventory.currentItem] = null;
}
if (!player.isUsingItem())
{
((EntityPlayerMP)player).sendContainerToPlayer(player.inventoryContainer);
}
return true;
}
else
{
return false;
}
}
}