本文整理了Java中net.minecraft.item.ItemStack.getMaxItemUseDuration()
方法的一些代码示例,展示了ItemStack.getMaxItemUseDuration()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.getMaxItemUseDuration()
方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:getMaxItemUseDuration
暂无
代码示例来源:origin: Vazkii/Botania
public ItemLivingwoodBow(String name) {
setCreativeTab(BotaniaCreativeTab.INSTANCE);
setRegistryName(new ResourceLocation(LibMisc.MOD_ID, name));
setTranslationKey(name);
setMaxDamage(500);
addPropertyOverride(new ResourceLocation("minecraft:pull"), (stack, worldIn, entityIn) -> {
if (entityIn == null)
{
return 0.0F;
}
else
{
ItemStack itemstack = entityIn.getActiveItemStack();
return !itemstack.isEmpty() && itemstack.getItem() instanceof ItemLivingwoodBow ? (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) * chargeVelocityMultiplier() / 20.0F : 0.0F;
}
});
}
代码示例来源:origin: SleepyTrousers/EnderIO
private float updatePullProperty(@Nonnull ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
if (stack.getItem() != this || entityIn == null) {
return 0;
}
float res = (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / (float) getDrawTime(stack);
return res;
}
代码示例来源:origin: CoFH/CoFHCore
@Override
public float getFOVMod(ItemStack stack, EntityPlayer player) {
float progress = MathHelper.clamp((stack.getMaxItemUseDuration() - player.getItemInUseCount()) / 20.0F, 0, 1.0F);
return progress * progress * zoomMultiplier;
}
代码示例来源:origin: Mine-and-blade-admin/Battlegear2
public static boolean checkForRightClickFunction(ItemStack stack) {
if (stack.getItemUseAction() == EnumAction.BLOCK || stack.getItemUseAction() == EnumAction.NONE) {
Class<?> c = stack.getItem().getClass();
while (!c.equals(Item.class)) {
if(c.equals(ItemTool.class) || c.equals(ItemSword.class)){
return false;
}
if(getBlackListedMethodIn(c)){
return true;
}
c = c.getSuperclass();
}
return stack.getMaxItemUseDuration() > 0;
}
return true;
}
代码示例来源:origin: vadis365/TheErebus
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
if (entityIn == null) {
return 0.0F;
} else {
return entityIn.getActiveItemStack().getItem() != Items.BOW ? 0.0F
: (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F;
}
}
});
代码示例来源:origin: CoFH/CoFHCore
@SideOnly (Side.CLIENT)
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
if (entityIn == null) {
return 0.0F;
} else {
ItemStack itemstack = entityIn.getActiveItemStack();
return !itemstack.isEmpty() && itemstack.getItem() instanceof ItemBowCore ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
}
}
});
代码示例来源:origin: CoFH/CoFHCore
@Override
public ITextComponent processStack(ItemStack stack) {
EnumAction action = stack.getItemUseAction();
ITextComponent component = new TextComponentString(action.name());
if (action != EnumAction.NONE) {
component.appendText(" | Duration: " + stack.getMaxItemUseDuration());
}
return component;
}
}, Lore("flavorText") {
代码示例来源:origin: Alex-the-666/Ice_and_Fire
@Override
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
if (entityIn == null) {
return 0.0F;
} else {
ItemStack itemstack = entityIn.getActiveItemStack();
return !itemstack.isEmpty() && itemstack.getItem() == ModItems.dragonbone_bow ? (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
}
}
});
代码示例来源:origin: Alex-the-666/Ice_and_Fire
@Override
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
if (entityIn == null) {
return 0.0F;
} else {
ItemStack itemstack = entityIn.getActiveItemStack();
return !itemstack.isEmpty() && itemstack.getItem() instanceof ItemDragonHornActive ? (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
}
}
});
代码示例来源:origin: CyclopsMC/EvilCraft
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
if (entityIn == null) {
return 0.0F;
} else {
ItemStack itemStack = entityIn.getActiveItemStack();
return !itemStack.isEmpty() && itemStack.getItem() instanceof AbstractFocus ? (float)(stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
}
}
});
代码示例来源:origin: WayofTime/BloodMagic
@SideOnly(Side.CLIENT)
public float apply(ItemStack stack, World world, EntityLivingBase entityIn)
{
if (entityIn == null)
{
return 0.0F;
} else
{
ItemStack itemstack = entityIn.getActiveItemStack();
return !itemstack.isEmpty() && itemstack.getItem() == RegistrarBloodMagicItems.SENTIENT_BOW ? (float) (stack.getMaxItemUseDuration() - entityIn.getItemInUseCount()) / 20.0F : 0.0F;
}
}
});
代码示例来源:origin: MatterOverdrive/MatterOverdrive-Legacy-Edition
private void drawProgressBar(ItemStack scanner, EntityPlayer player) {
GlStateManager.pushMatrix();
renderer().bindTexture(spinnerTexture);
int count = player.getItemInUseCount();
int maxCount = scanner.getMaxItemUseDuration();
GlStateManager.alphaFunc(GL_GREATER, (float) count / (float) maxCount);
RenderUtils.applyColorWithMultipy(Reference.COLOR_HOLO, 0.5f);
RenderUtils.drawPlane(0.35, 0.45, -0.1, 0.3, 0.3);
GlStateManager.popMatrix();
}
代码示例来源:origin: SleepyTrousers/EnderIO
@Override
public void attackEntityWithRangedAttack(@Nonnull EntityLivingBase entity, float rangeRatio) {
// the EntityPotion class validates if this potion is throwable, and if not it logs error "ThrownPotion entity {} has no item?!
if (attackTimer <= 0 && getHeldItem(EnumHand.MAIN_HAND).getItem() == Items.SPLASH_POTION && !isHealing) {
attackedWithPotion = entity;
double x = entity.posX + entity.motionX - posX;
double y = entity.posY + entity.getEyeHeight() - 1.100000023841858D - posY;
double z = entity.posZ + entity.motionZ - posZ;
float groundDistance = MathHelper.sqrt(x * x + z * z);
ItemStack potion = getHeldItem(EnumHand.MAIN_HAND);
attackTimer = getHeldItem(EnumHand.MAIN_HAND).getMaxItemUseDuration();
EntityPotion entitypotion = new EntityPotion(world, this, potion);
entitypotion.rotationPitch -= -20.0F;
entitypotion.shoot(x, y + groundDistance * 0.2F, z, 0.75F, 8.0F);
world.spawnEntity(entitypotion);
setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
}
}
代码示例来源:origin: Alex-the-666/Ice_and_Fire
@Override
public void notifyDataManagerChange(DataParameter<?> key) {
if (HAND_STATES.equals(key) && this.world.isRemote) {
if (this.isHandActive() && this.activeItemStack.isEmpty()) {
this.activeItemStack = this.getHeldItem(this.getActiveHand());
if (!this.activeItemStack.isEmpty()) {
this.activeItemStackUseCount = this.activeItemStack.getMaxItemUseDuration();
}
} else if (!this.isHandActive() && !this.activeItemStack.isEmpty()) {
this.activeItemStack = ItemStack.EMPTY;
this.activeItemStackUseCount = 0;
}
}
//field_184751_bv
if (BABY().equals(key)) {
this.setScaleForAge(this.isChild());
}
//field_184752_bw
}
代码示例来源:origin: Silentine/GrimoireOfGaia
this.potionUseTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
this.setDrinkingPotion(true);
this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
代码示例来源:origin: PrinceOfAmber/Cyclic
@SubscribeEvent
public void onPlayerUpdate(ArrowLooseEvent event) {
ItemStack stackBow = event.getBow();
int level = this.getCurrentLevelTool(stackBow);
if (level <= 0) {
return;
}
EntityPlayer player = event.getEntityPlayer();
World worldIn = player.world;
if (worldIn.isRemote == false) {
float charge = ItemBow.getArrowVelocity(stackBow.getMaxItemUseDuration() - event.getCharge());
//use cross product to push arrows out to left and right
Vec3d playerDirection = UtilEntity.lookVector(player.rotationYaw, player.rotationPitch);
Vec3d left = playerDirection.crossProduct(new Vec3d(0, 1, 0));
Vec3d right = playerDirection.crossProduct(new Vec3d(0, -1, 0));
spawnArrow(worldIn, player, stackBow, charge, left.normalize());
spawnArrow(worldIn, player, stackBow, charge, right.normalize());
}
}
代码示例来源:origin: SquidDev-CC/plethora
active.onPlayerStoppedUsing(player.getEntityWorld(), player, active.getMaxItemUseDuration() - duration);
内容来源于网络,如有侵权,请联系作者删除!