本文整理汇总了Java中net.minecraft.item.EnumAction类的典型用法代码示例。如果您正苦于以下问题:Java EnumAction类的具体用法?Java EnumAction怎么用?Java EnumAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumAction类属于net.minecraft.item包,在下文中一共展示了EnumAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readNBT
import net.minecraft.item.EnumAction; //导入依赖的package包/类
@Override
public void readNBT(Capability<FoodStats> capability, FoodStats instance, EnumFacing side, NBTBase nbt) {
if (!(nbt instanceof NBTTagCompound))
return;
NBTTagCompound tagCompound = (NBTTagCompound) nbt;
instance.setAmount(tagCompound.getInteger("amount"))
.setSaturationModifier(tagCompound.getFloat("saturationModifier"))
.setMaxItemUseDuration(tagCompound.getInteger("maxItemUseDuration"))
.setAction(EnumAction.values()[tagCompound.getInteger("action")])
.setPotion(PotionEffect.readCustomPotionEffectFromNBT(tagCompound.getCompoundTag("potion")))
.setPotionEffectProbability(tagCompound.getFloat("potionEffectProbability"))
.setUnlocalizedName(tagCompound.getString("unlocalizedName"));
if (tagCompound.getBoolean("wolfFood"))
instance.setWolfFood();
if (tagCompound.getBoolean("alwaysEdible"))
instance.setAlwaysEdible();
}
示例2: getItemUseAction
import net.minecraft.item.EnumAction; //导入依赖的package包/类
@Override
public EnumAction getItemUseAction(ItemStack stack) {
switch (getSpell(stack).getCastingType()) {
case INSTANT:
return EnumAction.NONE;
case MELEE:
return EnumAction.NONE;
case CONTINUOUS:
return EnumAction.BOW;
case CHARGED:
return EnumAction.BOW;
}
return EnumAction.NONE;
}
示例3: setItemInUse
import net.minecraft.item.EnumAction; //导入依赖的package包/类
/**
* sets the itemInUse when the use item button is clicked. Args: itemstack, int maxItemUseDuration
*/
public void setItemInUse(ItemStack stack, int duration)
{
super.setItemInUse(stack, duration);
if (stack != null && stack.getItem() != null && stack.getItem().getItemUseAction(stack) == EnumAction.EAT)
{
this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(this, 3));
}
}
示例4: updateItemUse
import net.minecraft.item.EnumAction; //导入依赖的package包/类
/**
* Plays sounds and makes particles for item in use state
*/
protected void updateItemUse(ItemStack itemStackIn, int p_71010_2_)
{
if (itemStackIn.getItemUseAction() == EnumAction.DRINK)
{
this.playSound("random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (itemStackIn.getItemUseAction() == EnumAction.EAT)
{
for (int i = 0; i < p_71010_2_; ++i)
{
Vec3 vec3 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3 = vec3.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
vec3 = vec3.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
Vec3 vec31 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec31 = vec31.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
vec31 = vec31.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
if (itemStackIn.getHasSubtypes())
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(itemStackIn.getItem()), itemStackIn.getMetadata()});
}
else
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(itemStackIn.getItem())});
}
}
this.playSound("random.eat", 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
示例5: EnumActionDeserializer
import net.minecraft.item.EnumAction; //导入依赖的package包/类
public EnumActionDeserializer()
{
map.put("none", EnumAction.NONE);
map.put("eat", EnumAction.EAT);
map.put("drink", EnumAction.DRINK);
map.put("block", EnumAction.BLOCK);
map.put("bow", EnumAction.BOW);
}
示例6: getItemUseAction
import net.minecraft.item.EnumAction; //导入依赖的package包/类
@Override
public EnumAction getItemUseAction(ItemStack stack) {
if (stack.getItem() == UCItems.potionreverse)
return EnumAction.DRINK;
return EnumAction.EAT;
}
示例7: updateItemUse
import net.minecraft.item.EnumAction; //导入依赖的package包/类
/**
* Plays sounds and makes particles for item in use state
*/
protected void updateItemUse(ItemStack stack, int eatingParticleCount)
{
if (!stack.func_190926_b() && this.isHandActive())
{
if (stack.getItemUseAction() == EnumAction.DRINK)
{
this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
if (stack.getItemUseAction() == EnumAction.EAT)
{
for (int i = 0; i < eatingParticleCount; ++i)
{
Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
if (stack.getHasSubtypes())
{
this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()});
}
else
{
this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
}
}
this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
}
示例8: isActiveItemStackBlocking
import net.minecraft.item.EnumAction; //导入依赖的package包/类
public boolean isActiveItemStackBlocking()
{
if (this.isHandActive() && !this.activeItemStack.func_190926_b())
{
Item item = this.activeItemStack.getItem();
return item.getItemUseAction(this.activeItemStack) != EnumAction.BLOCK ? false : item.getMaxItemUseDuration(this.activeItemStack) - this.activeItemStackUseCount >= 5;
}
else
{
return false;
}
}
示例9: onItemUseFinish
import net.minecraft.item.EnumAction; //导入依赖的package包/类
protected void onItemUseFinish()
{
if (!this.activeItemStack.isEmpty() && this.isHandActive() && this.activeItemStack.getItemUseAction() == EnumAction.EAT)
{
this.heal(((ItemFood)this.refill.getStackInSlot(0).getItem()).getHealAmount(activeItemStack));
}
super.onItemUseFinish();
this.setHeldItem(EnumHand.OFF_HAND, ItemStack.EMPTY);
}
示例10: updateItemUse
import net.minecraft.item.EnumAction; //导入依赖的package包/类
/**
* Plays sounds and makes particles for item in use state
*/
protected void updateItemUse(@Nullable ItemStack stack, int eatingParticleCount)
{
if (stack != null && this.isHandActive())
{
if (stack.getItemUseAction() == EnumAction.DRINK)
{
this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (stack.getItemUseAction() == EnumAction.EAT)
{
for (int i = 0; i < eatingParticleCount; ++i)
{
Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
if (stack.getHasSubtypes())
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()});
}
else
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
}
}
this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
}
示例11: isActiveItemStackBlocking
import net.minecraft.item.EnumAction; //导入依赖的package包/类
public boolean isActiveItemStackBlocking()
{
if (this.isHandActive() && this.activeItemStack != null)
{
Item item = this.activeItemStack.getItem();
return item.getItemUseAction(this.activeItemStack) != EnumAction.BLOCK ? false : item.getMaxItemUseDuration(this.activeItemStack) - this.activeItemStackUseCount >= 5;
}
else
{
return false;
}
}
示例12: getItemUseAction
import net.minecraft.item.EnumAction; //导入依赖的package包/类
@Override
public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
if (par1ItemStack.getItemDamage() > 14 && par1ItemStack.getItemDamage() < 19)
{
return EnumAction.eat;
}
return super.getItemUseAction(par1ItemStack);
}
示例13: doRender
import net.minecraft.item.EnumAction; //导入依赖的package包/类
/**
* Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
* handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
* (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
*/
public void doRender(AbstractClientPlayer p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
{
if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Pre(p_76986_1_, this, p_76986_9_))) return;
GL11.glColor3f(1.0F, 1.0F, 1.0F);
ItemStack itemstack = p_76986_1_.inventory.getCurrentItem();
this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = itemstack != null ? 1 : 0;
if (itemstack != null && p_76986_1_.getItemInUseCount() > 0)
{
EnumAction enumaction = itemstack.getItemUseAction();
if (enumaction == EnumAction.block)
{
this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 3;
}
else if (enumaction == EnumAction.bow)
{
this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = true;
}
}
this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = p_76986_1_.isSneaking();
double d3 = p_76986_4_ - (double)p_76986_1_.yOffset;
if (p_76986_1_.isSneaking() && !(p_76986_1_ instanceof EntityPlayerSP))
{
d3 -= 0.125D;
}
super.doRender((EntityLivingBase)p_76986_1_, p_76986_2_, d3, p_76986_6_, p_76986_8_, p_76986_9_);
this.modelArmorChestplate.aimedBow = this.modelArmor.aimedBow = this.modelBipedMain.aimedBow = false;
this.modelArmorChestplate.isSneak = this.modelArmor.isSneak = this.modelBipedMain.isSneak = false;
this.modelArmorChestplate.heldItemRight = this.modelArmor.heldItemRight = this.modelBipedMain.heldItemRight = 0;
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.RenderPlayerEvent.Post(p_76986_1_, this, p_76986_9_));
}
示例14: getItemUseAction
import net.minecraft.item.EnumAction; //导入依赖的package包/类
@Nonnull
@Override
public EnumAction getItemUseAction(ItemStack stack) {
boolean anyNotContinuous = false;
for (Module module : SpellUtils.getModules(stack))
if (!(module instanceof IContinuousModule && module.getChargeupTime() <= 0)) {
anyNotContinuous = true;
break;
}
return anyNotContinuous ? EnumAction.NONE : EnumAction.BOW;
}
示例15: onItemRightClick
import net.minecraft.item.EnumAction; //导入依赖的package包/类
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (getItemUseAction(stack) == EnumAction.BOW) {
if (world.isRemote && (Minecraft.getMinecraft().currentScreen != null)) {
return new ActionResult<>(EnumActionResult.FAIL, stack);
} else {
player.setActiveHand(hand);
return new ActionResult<>(EnumActionResult.PASS, stack);
}
} else return new ActionResult<>(EnumActionResult.FAIL, stack);
}