本文整理汇总了Java中net.minecraft.item.ItemPotion类的典型用法代码示例。如果您正苦于以下问题:Java ItemPotion类的具体用法?Java ItemPotion怎么用?Java ItemPotion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemPotion类属于net.minecraft.item包,在下文中一共展示了ItemPotion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isHealthPot
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
public static boolean isHealthPot(ItemStack item) {
try {
if (item == null) return false;
Item pot = getItemFromStack(item);
if (pot == null) return false;
ItemPotion potion = (ItemPotion) pot;
if (potion != null && potion.func_77832_l(item) != null) {
for (Object obj : potion.func_77832_l(item)) {
if (obj == null || !(obj instanceof PotionEffect)) continue;
PotionEffect effect = (PotionEffect) obj;
if ((effect.func_76456_a() == Potion.field_76432_h.func_76396_c()) && ItemPotion.func_77831_g((Integer) ReflectionUtil.getFieldValue("field_77991_e", item)))
return true;
}
}
return false;
} catch (Exception e) {
return false;
}
}
示例2: getPotionFromInventory
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
private int getPotionFromInventory() {
int pot = -1;
int counter = 0;
int i = 1;
while (i < 45) {
ItemStack is;
ItemPotion potion;
Item item;
if (this.mc.thePlayer.inventoryContainer.getSlot(i).getHasStack() && (item = (is = this.mc.thePlayer.inventoryContainer.getSlot(i).getStack()).getItem()) instanceof ItemPotion && (potion = (ItemPotion)item).getEffects(is) != null) {
for (Object o : potion.getEffects(is)) {
PotionEffect effect = (PotionEffect)o;
if (effect.getPotionID() != Potion.heal.id || !ItemPotion.isSplash((int)is.getItemDamage())) continue;
++counter;
pot = i;
}
}
++i;
}
Character colorFormatCharacter = new Character('\u00a7');
this.suffix = OptionManager.getOption((String)"Hyphen", (Module)ModuleManager.getModule(HUD.class)).value ? colorFormatCharacter + "7 - " + counter : colorFormatCharacter + "7 " + counter;
return pot;
}
示例3: instanceOf
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
public boolean instanceOf(IItemType type) {
if (type.equals(IItemType.ItemFishingRod)) {
return item instanceof ItemFishingRod;
} else if (type.equals(IItemType.ItemPotion)) {
return item instanceof ItemPotion;
} else if (type.equals(IItemType.ItemFood)) {
return item instanceof ItemFood;
} else if (type.equals(IItemType.ItemSword)) {
return item instanceof ItemSword;
} else if (type.equals(IItemType.ItemTool)) {
return item instanceof ItemTool;
} else if (type.equals(IItemType.ItemNameTag)) {
return item instanceof ItemNameTag;
} else if (type.equals(IItemType.ItemBlock)) {
return item instanceof ItemBlock;
} else if (type.equals(IItemType.ItemHoe)) {
return item instanceof ItemHoe;
}
return false;
}
示例4: consumeItem
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
public static ItemStack consumeItem(ItemStack stack) {
if (stack.getItem() instanceof ItemPotion) {
if (stack.stackSize == 1) {
return new ItemStack(Items.glass_bottle);
} else {
stack.splitStack(1);
return stack;
}
}
if (stack.stackSize == 1) {
if (stack.getItem().hasContainerItem(stack)) {
return stack.getItem().getContainerItem(stack);
} else {
return null;
}
} else {
stack.splitStack(1);
return stack;
}
}
示例5: getCraftingResult
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult( InventoryCrafting inv )
{
ItemStack item = doCheck( inv );
if ( item == null )
{
return null;
}
int id = ItemPotion.isSplash( item.getItemDamage() ) ? CondensedPotions.condensedSplashItem.itemID : CondensedPotions.condensedNormalItem.itemID;
ItemStack pot = new ItemStack( id, 1, 1 );
NBTTagCompound potTag = new NBTTagCompound();
item.writeToNBT( potTag );
NBTTagCompound comp = new NBTTagCompound();
comp.setTag( "Potion", potTag );
pot.setTagCompound( comp );
return pot;
}
示例6: doCheck
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
private ItemStack doCheck( InventoryCrafting inv )
{
ItemStack item = null;
int count = 0;
for ( int i = 0; i < inv.getSizeInventory(); ++i, ++count )
{
ItemStack stack = inv.getStackInSlot( i );
if ( stack == null )
{
return null;
}
if ( item == null )
{
item = stack;
}
else if ( stack.itemID != item.itemID || stack.getItemDamage() != item.getItemDamage() || !check( stack.getTagCompound(), item.getTagCompound() ) )
{
return null;
}
}
return ( count >= 9 && ( item.getItem() instanceof ItemPotion ) ) ? item : null;
}
示例7: addToWhiteList
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
public final static boolean addToWhiteList(String id){
String[] parts = id.split(":", 4);
if(parts.length < 1)
return false;
ItemStack stack = GameRegistry.findItemStack(parts.length==1 ? "minecraft" : parts[0], parts.length==1 ? parts[0] : parts[1], 1);
if(stack == null)
return false;
if((stack.getItem() instanceof ItemBlock) || (stack.getItem() instanceof ItemPotion) || (stack.getItem() instanceof ItemArmor) || (stack.getItem() instanceof ItemBucket))
return false;
int meta=OreDictionary.WILDCARD_VALUE;
if(parts.length >= 3){
try{
meta=Integer.parseInt(parts[2]);
}catch(NumberFormatException e){
meta=OreDictionary.WILDCARD_VALUE;
}
}
return addToWhiteList(new ItemData(stack.getItem(), meta));
}
示例8: getMeta
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
@Override
public Object getMeta(ItemPotion target, ItemStack stack) {
final Map<String, Object> results = Maps.newHashMap();
results.put("splash", ItemPotion.isSplash(stack.getItemDamage()));
final List<Map<String, Object>> effectsInfo = Lists.newArrayList();
@SuppressWarnings("unchecked")
final List<PotionEffect> effects = target.getEffects(stack);
if (effects != null) {
for (PotionEffect effect : effects) {
final Map<String, Object> entry = Maps.newHashMap();
entry.put("duration", effect.getDuration() / 20); // ticks!
entry.put("amplifier", effect.getAmplifier());
entry.put("effect", getPotionInfo(effect.getPotionID()));
effectsInfo.add(entry);
}
}
results.put("effects", effectsInfo);
return results;
}
示例9: addInformation
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List list,
boolean par4) {
super.addInformation(stack, player, list, par4);
list.add(StatCollector.translateToLocal("lore.ammo"));
ItemPotion p = new ItemPotion();
if (NBTUtil.hasNBT(stack)) {
list.add("");
HashMap<EnumModifierType, Integer> modifiers = readFromNBT(stack
.getTagCompound());
for (EnumModifierType modifier : modifiers.keySet()) {
list.add(modifiers.get(modifier) + "x "
+ modifier.getItemStack().getDisplayName());
}
}
}
示例10: onUpdate
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
@Override
public void onUpdate(EntityPlayer player, Side side) {
if (side == Side.SERVER) {
if (player.worldObj.getTotalWorldTime() % 10 == 0) {
if (player.isInWater() || (player.worldObj.isRaining() && player.worldObj.canBlockSeeTheSky((int) player.posX, (int) player.posY, (int) player.posZ))) {
player.attackEntityFrom(DamageSource.drown, 1);
this.playerCount.add(player.getCommandSenderName(), 10);
}
if (player.getCurrentEquippedItem() != null && (player.getCurrentEquippedItem().getItem() instanceof ItemPotion || player.getCurrentEquippedItem().getItem() == Items.water_bucket)) {
player.dropOneItem(true);
player.attackEntityFrom(DamageSource.drown, 1);
this.playerCount.add(player.getCommandSenderName(), 10);
player.addChatComponentMessage(new ChatComponentText("The condensation from the bottle burns your hands, causing you to drop it.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));
}
}
this.playerCount.add(player.getCommandSenderName());
}
}
示例11: func_76986_a
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
public void func_76986_a(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) {
Icon var10 = this.field_94151_a.func_77617_a(this.field_94150_f);
if(var10 != null) {
GL11.glPushMatrix();
GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
GL11.glEnable('\u803a');
GL11.glScalef(0.5F, 0.5F, 0.5F);
this.func_110777_b(p_76986_1_);
Tessellator var11 = Tessellator.field_78398_a;
if(var10 == ItemPotion.func_94589_d("bottle_splash")) {
int var12 = PotionHelper.func_77915_a(((EntityPotion)p_76986_1_).func_70196_i(), false);
float var13 = (float)(var12 >> 16 & 255) / 255.0F;
float var14 = (float)(var12 >> 8 & 255) / 255.0F;
float var15 = (float)(var12 & 255) / 255.0F;
GL11.glColor3f(var13, var14, var15);
GL11.glPushMatrix();
this.func_77026_a(var11, ItemPotion.func_94589_d("overlay"));
GL11.glPopMatrix();
GL11.glColor3f(1.0F, 1.0F, 1.0F);
}
this.func_77026_a(var11, var10);
GL11.glDisable('\u803a');
GL11.glPopMatrix();
}
}
示例12: onTryToPotion
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
@SubscribeEvent
public void onTryToPotion(PlayerUseItemEvent.Start e) {
if (e.entity.dimension == IaSFlags.dim_nyx_id && !e.entityPlayer.capabilities.isCreativeMode) {
final ItemStack ite = e.item;
boolean stopped = false;
if (ite == null)
return;
else if (ite.getItem() instanceof ItemPotion) {
IaSPlayerHelper.messagePlayer(e.entityPlayer, "The contents of the bottle have frozen solid.");
stopped = true;
} else if (ite.getItem() == Items.milk_bucket) {
IaSPlayerHelper.messagePlayer(e.entityPlayer, "The milk has frozen solid.");
stopped = true;
} else if (ite.getItem() instanceof ItemFood && !(ite.getItem() instanceof IaSItemFood)) {
IaSPlayerHelper.messagePlayer(e.entityPlayer,
"It's been frozen solid. Eating it would be dangerous.");
stopped = true;
}
if(stopped) {
e.setCanceled(true);
e.entityPlayer.stopUsingItem();
}
}
}
示例13: onPickupFromSlot
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
@Override
public void onPickupFromSlot(EntityPlayer player, ItemStack stack) {
if (stack.getItem() instanceof ItemPotion && stack.getItemDamage() > 0)
player.addStat(AchievementList.potion, 1);
super.onPickupFromSlot(player, stack);
}
示例14: canBrew
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
private boolean canBrew() {
if (fuel > 0 && inventory[3] != null && inventory[3].stackSize > 0) {
ItemStack itemstack = inventory[3];
if (!itemstack.getItem().isPotionIngredient(itemstack))
return false;
else if (itemstack.getItem() == ModItems.dragon_breath) {
for (int i = 0; i < 3; i++)
if (inventory[i] != null && inventory[i].getItem() == Items.potionitem)
if (ItemPotion.isSplash(inventory[i].getItemDamage()))
return true;
return false;
} else {
boolean flag = false;
for (int i = 0; i < 3; i++)
if (inventory[i] != null && inventory[i].getItem() instanceof ItemPotion) {
int j = inventory[i].getItemDamage();
int k = applyIngredient(j, itemstack);
if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k)) {
flag = true;
break;
}
List<?> list = Items.potionitem.getEffects(j);
List<?> list1 = Items.potionitem.getEffects(k);
if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && j != k) {
flag = true;
break;
}
}
return flag;
}
} else
return false;
}
示例15: brewPotions
import net.minecraft.item.ItemPotion; //导入依赖的package包/类
private void brewPotions() {
if (ForgeEventFactory.onPotionAttemptBreaw(new ItemStack[] { inventory[0], inventory[1], inventory[2], inventory[3] }))
return;
if (canBrew()) {
for (int i = 0; i < 3; i++)
if (inventory[i] != null && inventory[i].getItem() instanceof ItemPotion) {
int j = inventory[i].getItemDamage();
if (ItemPotion.isSplash(j) && inventory[3].getItem() == ModItems.dragon_breath)
inventory[i] = new ItemStack(ModItems.lingering_potion, inventory[i].stackSize, inventory[i].getItemDamage());
else {
int k = applyIngredient(j, inventory[3]);
List<?> list = Items.potionitem.getEffects(j);
List<?> list1 = Items.potionitem.getEffects(k);
if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) {
if (j != k)
inventory[i].setItemDamage(k);
} else if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
inventory[i].setItemDamage(k);
}
}
boolean hasContainerItem = inventory[3].getItem().hasContainerItem(inventory[3]);
if (--inventory[3].stackSize <= 0)
inventory[3] = hasContainerItem ? inventory[3].getItem().getContainerItem(inventory[3]) : null;
else if (hasContainerItem && !worldObj.isRemote) {
float f = 0.7F;
double x = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
double y = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
double z = worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
EntityItem entityitem = new EntityItem(worldObj, xCoord + x, yCoord + y, zCoord + z, inventory[3].getItem().getContainerItem(inventory[3]));
entityitem.delayBeforeCanPickup = 10;
worldObj.spawnEntityInWorld(entityitem);
}
fuel--;
ForgeEventFactory.onPotionBrewed(new ItemStack[] { inventory[0], inventory[1], inventory[2], inventory[3] });
worldObj.playSound(xCoord, yCoord, zCoord, Reference.MOD_ID + ":block.brewing_stand.brew", 1.0F, 1.0F, true);
}
}