本文整理汇总了Java中net.minecraft.item.ItemStack.getMaxDamage方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getMaxDamage方法的具体用法?Java ItemStack.getMaxDamage怎么用?Java ItemStack.getMaxDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getMaxDamage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onWornTick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
if (player.ticksExisted % 40 == 0 && player instanceof EntityPlayer) {
EntityPlayer p = (EntityPlayer) player;
boolean flag = p.getActivePotionEffect(MobEffects.POISON) != null || p.getActivePotionEffect(MobEffects.NAUSEA) != null || p.getActivePotionEffect(MobEffects.WITHER) != null || p.getActivePotionEffect(MobEffects.BLINDNESS) != null || p.getActivePotionEffect(MobEffects.WEAKNESS) != null;
p.removePotionEffect(MobEffects.NAUSEA);
p.removePotionEffect(MobEffects.WITHER);
p.removePotionEffect(MobEffects.BLINDNESS);
p.removePotionEffect(MobEffects.POISON);
p.removePotionEffect(MobEffects.WEAKNESS);
if (flag) {
itemstack.setItemDamage(itemstack.getItemDamage() + 1);
if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
itemstack.setCount(0);
}
}
}
}
示例2: onUpdate
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int animTick, boolean holdingItem) // Overhauled default
{
if (world.isRemote) { return; } // Not doing this on client side
if (this.getCooldown(stack) > 0) { this.setCooldown(stack, this.getCooldown(stack) - 1); } // Cooling down
if (this.getCooldown(stack) == 1) { this.doCooldownSFX(world, entity); } // One tick before cooldown is done with, so SFX now
if (this.getBurstFire(stack) > 0)
{
this.setBurstFire(stack, this.getBurstFire(stack) - 1); // One done
if (stack.getItemDamage() < stack.getMaxDamage() && holdingItem) // Can only do it if we're loaded and holding the weapon
{
this.doBurstFire(stack, world, entity);
if (this.consumeAmmo(stack, entity, 1)) // We're done here
{
this.dropMagazine(world, stack, entity);
return;
}
// else, still has ammo left. Continue.
}
// else, either not loaded or not held
}
}
示例3: detectAndSendChanges
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void detectAndSendChanges() {
super.detectAndSendChanges();
for(IContainerListener listener : this.listeners) {
ItemStack weapon = this.mercenary.loadout.getStackInSlot(0);
int loaded = weapon.getItem() instanceof ItemWeapon ? weapon.getMaxDamage() - weapon.getItemDamage() : 0;
if(this.primaryAmmo != this.mercenary.getAmmo(0)) {
this.primaryAmmo = this.mercenary.getAmmo(0);
//System.out.println("ammo in:");
listener.sendWindowProperty(this, 0, this.primaryAmmo);
}
weapon = this.mercenary.loadout.getStackInSlot(0);
loaded = weapon.getItem() instanceof ItemWeapon ? weapon.getMaxDamage() - weapon.getItemDamage() : 0;
if(this.secondaryAmmo != this.mercenary.getAmmo(1) + loaded) {
this.secondaryAmmo = this.mercenary.getAmmo(1) + loaded;
listener.sendWindowProperty(this, 1, this.secondaryAmmo);
}
}
}
示例4: checkMatch
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
protected boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
int[] amounts = getAmounts(mirror);
for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
{
for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
{
int subX = x - startX;
int subY = y - startY;
int damage = 0;
Ingredient target = Ingredient.EMPTY;
if (subX >= 0 && subY >= 0 && subX < width && subY < height)
{
damage = amounts[subX + width * subY];
if (mirror)
{
target = input.get(width - subX - 1 + subY * width);
} else
{
target = input.get(subX + subY * width);
}
}
ItemStack slot = inv.getStackInRowAndColumn(x, y);
if (!target.apply(slot) || damage > slot.getMaxDamage() - slot.getItemDamage() + 1)
{
return false;
}
}
}
return true;
}
示例5: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "EnderRifle_empty"; }
if (this.getCooldown(stack) > 0) { return "EnderRifle_hot"; } // Cooling down
return "EnderRifle"; // Regular
}
示例6: 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.world.isDaytime() && !this.world.isRemote)
{
float f = this.getBrightness(1.0F);
BlockPos blockpos = this.getRidingEntity() instanceof EntityBoat ? (new BlockPos(this.posX, (double)Math.round(this.posY), this.posZ)).up() : 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.world.canSeeSky(blockpos))
{
boolean flag = true;
ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);
if (!itemstack.func_190926_b())
{
if (itemstack.isItemStackDamageable())
{
itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));
if (itemstack.getItemDamage() >= itemstack.getMaxDamage())
{
this.renderBrokenItemStack(itemstack);
this.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.field_190927_a);
}
}
flag = false;
}
if (flag)
{
this.setFire(8);
}
}
}
super.onLivingUpdate();
}
示例7: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "LapisCoil2_empty"; } // Empty
if (this.getCooldown(stack) > 0) { return "LapisCoil2_hot"; } // Hot
return "LapisCoil2"; // Regular
}
示例8: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "RPG_Imp_empty"; } // Empty
return "RPG_Imp"; // Regular
}
示例9: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "CrossbowAutoImp_empty"; } // Empty
return "CrossbowAutoImp"; // Regular
}
示例10: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "FenFire_empty"; } // empty
if (this.getCooldown(stack) > 0) { return "FenFire_hot"; } // Cooling down
return "FenFire"; // Regular
}
示例11: getItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getItemStack(Random random)
{
ItemStack itemstack = this.returnStack.copy();
if (this.maxDamagePercent > 0.0F)
{
int i = (int)(this.maxDamagePercent * (float)this.returnStack.getMaxDamage());
int j = itemstack.getMaxDamage() - random.nextInt(random.nextInt(i) + 1);
if (j > i)
{
j = i;
}
if (j < 1)
{
j = 1;
}
itemstack.setItemDamage(j);
}
if (this.enchantable)
{
EnchantmentHelper.addRandomEnchantment(random, itemstack, 30);
}
return itemstack;
}
示例12: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "AquaAcc_empty"; } // empty
return "AquaAcc"; // Regular
}
示例13: getModelTexPath
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getModelTexPath(ItemStack stack) // The model texture path
{
if (stack.getItemDamage() >= stack.getMaxDamage()) { return "FlintDuster_empty"; } // empty
if (this.getCooldown(stack) > 0) { return "FlintDuster_hot"; } // Firing
return "FlintDuster"; // Regular
}
示例14: getRemainingItems
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
NonNullList<ItemStack> items = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
matches(inv, null);
for (int i = 0; i < invSlots.length; i++)
{
int amount = damageAmounts[i];
int invIndex = invSlots[i];
if (amount > 0)
{
ItemStack stack = inv.getStackInSlot(invIndex).copy();
stack.setItemDamage(stack.getItemDamage() + amount);
if (stack.getItemDamage() > stack.getMaxDamage())
{
stack = ForgeHooks.getContainerItem(stack);
}
items.set(invIndex, stack);
} else
{
items.set(invIndex, ForgeHooks.getContainerItem(inv.getStackInSlot(invIndex)));
}
}
return items;
}
示例15: addInformation
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
int damage = stack.getMaxDamage() - stack.getItemDamage() ;
tooltip.add("Uses Left: \u00A7c" + damage);
if (GuiScreen.isShiftKeyDown()) {
tooltip.add(tooltipInfo);
}
if (!GuiScreen.isShiftKeyDown())
tooltip.add(TextFormatting.AQUA + I18n.format("press.for.info.name", "SHIFT"));
}