本文整理汇总了Java中net.minecraft.potion.PotionUtils.getPotionFromItem方法的典型用法代码示例。如果您正苦于以下问题:Java PotionUtils.getPotionFromItem方法的具体用法?Java PotionUtils.getPotionFromItem怎么用?Java PotionUtils.getPotionFromItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.potion.PotionUtils
的用法示例。
在下文中一共展示了PotionUtils.getPotionFromItem方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: colorCoke
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@SubscribeEvent
public void colorCoke(PotionBrewEvent.Post event){
for(int i=0;i<event.getLength();i++){
if(PotionUtils.getPotionFromItem(event.getItem(i))==COKE_COLA||
PotionUtils.getPotionFromItem(event.getItem(i))==COKE_COLA_LONG||
PotionUtils.getPotionFromItem(event.getItem(i))==COKE_COLA_STRONG){
ItemStack brew=event.getItem(i).copy();
brew.getTagCompound().setInteger("CustomPotionColor", 4738376);
event.setItem(i, brew);
}
}
}
示例2: setPotionEffect
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public void setPotionEffect(ItemStack stack)
{
if (stack.getItem() == Items.TIPPED_ARROW)
{
this.potion = PotionUtils.getPotionFromItem(stack);
Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack);
if (!collection.isEmpty())
{
for (PotionEffect potioneffect : collection)
{
this.customPotionEffects.add(new PotionEffect(potioneffect));
}
}
int i = func_191508_b(stack);
if (i == -1)
{
this.func_190548_o();
}
else
{
this.func_191507_d(i);
}
}
else if (stack.getItem() == Items.ARROW)
{
this.potion = PotionTypes.EMPTY;
this.customPotionEffects.clear();
this.dataManager.set(COLOR, Integer.valueOf(-1));
}
}
示例3: func_190901_a
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public ItemStack func_190901_a(EntityPlayer p_190901_1_, ItemStack p_190901_2_)
{
PotionType potiontype = PotionUtils.getPotionFromItem(p_190901_2_);
if (potiontype != PotionTypes.WATER && potiontype != PotionTypes.EMPTY)
{
this.player.addStat(AchievementList.POTION);
}
super.func_190901_a(p_190901_1_, p_190901_2_);
return p_190901_2_;
}
示例4: onPickupFromSlot
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
if (PotionUtils.getPotionFromItem(stack) != PotionTypes.WATER)
{
net.minecraftforge.event.ForgeEventFactory.onPlayerBrewedPotion(playerIn, stack);
this.player.addStat(AchievementList.POTION);
}
super.onPickupFromSlot(playerIn, stack);
}
示例5: setPotionEffect
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public void setPotionEffect(ItemStack stack)
{
if (stack.hasTagCompound() && ItemNBTHelper.verifyExistance(stack, "Potion"))
{
this.potion = PotionUtils.getPotionFromItem(stack);
Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack);
if (!collection.isEmpty())
{
for (PotionEffect potioneffect : collection)
{
this.customPotionEffects.add(new PotionEffect(potioneffect));
}
}
int i = getCustomColor(stack);
if (i == -1)
{
this.refreshColor();
}
else
{
this.setCustomColor(i);
}
}
else
{
this.potion = PotionTypes.EMPTY;
this.customPotionEffects.clear();
this.dataManager.set(COLOR, Integer.valueOf(-1));
}
}
示例6: onProjectileImpact
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void onProjectileImpact(ProjectileImpactEvent.Throwable event) {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
if (event.getThrowable() instanceof EntityPotion) {
EntityPotion entityPotion = (EntityPotion) event.getThrowable();
PotionType potionType = PotionUtils.getPotionFromItem(entityPotion.getPotion());
if (potionType == GSPotion.PURIFICATION_TYPE) {
PotionPurification.applyPotionOnBlocks(entityPotion);
}
}
}
}
示例7: getNewPotions
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
private List<ItemStack> getNewPotions(ArrayList<ItemStack> knownPotions, ArrayList<ItemStack> potionIngredients, ArrayList<DrawableRecipe> recipes) {
List<ItemStack> newPotions = new ArrayList<ItemStack>();
for (ItemStack potionInput : knownPotions) {
for (ItemStack potionIngredient : potionIngredients) {
ItemStack potionOutput = PotionHelper.doReaction(potionIngredient, potionInput.copy());
if (potionOutput == null) {
continue;
}
if (potionInput.getItem() == potionOutput.getItem()) {
PotionType potionOutputType = PotionUtils.getPotionFromItem(potionOutput);
if (potionOutputType == PotionTypes.WATER)
{
continue;
}
PotionType potionInputType = PotionUtils.getPotionFromItem(potionInput);
int inputId = PotionType.REGISTRY.getIDForObject(potionInputType);
int outputId = PotionType.REGISTRY.getIDForObject(potionOutputType);
if (inputId == outputId)
{
continue;
}
}
DrawableRecipeBrewing recipe = new DrawableRecipeBrewing(potionInput, potionIngredient, potionOutput);
if (!containsRecipe(recipe, recipes)) {
recipes.add(recipe);
newPotions.add(potionOutput);
}
}
}
return newPotions;
}
示例8: onPickupFromSlot
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
if (PotionUtils.getPotionFromItem(stack) != PotionTypes.WATER)
{
this.player.addStat(AchievementList.POTION);
}
super.onPickupFromSlot(playerIn, stack);
}
示例9: onImpact
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(RayTraceResult result)
{
if (!this.world.isRemote)
{
ItemStack itemstack = this.getPotion();
PotionType potiontype = PotionUtils.getPotionFromItem(itemstack);
List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
boolean flag = potiontype == PotionTypes.WATER && list.isEmpty();
if (result.typeOfHit == RayTraceResult.Type.BLOCK && flag)
{
BlockPos blockpos = result.getBlockPos().offset(result.sideHit);
this.extinguishFires(blockpos);
for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
{
this.extinguishFires(blockpos.offset(enumfacing));
}
}
if (flag)
{
this.func_190545_n();
}
else if (!list.isEmpty())
{
if (this.isLingering())
{
this.func_190542_a(itemstack, potiontype);
}
else
{
this.func_190543_a(result, list);
}
}
int i = potiontype.hasInstantEffect() ? 2007 : 2002;
this.world.playEvent(i, new BlockPos(this), PotionUtils.func_190932_c(itemstack));
this.setDead();
}
}
示例10: onBlockActivated
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
TileEntity tile = world.getTileEntity(pos);
if(tile == null || !(tile instanceof TileJar)) return false;
TileJar jar = (TileJar)tile;
ItemStack held = player.getHeldItem(hand);
if(ItemStackTools.isValid(held)){
if(held.getItem() == Items.SHULKER_SHELL && !jar.isShulkerLamp()){
jar.setShulkerLamp(true);
world.checkLightFor(EnumSkyBlock.BLOCK, pos);
BlockUtil.markBlockForUpdate(world, pos);
return true;
}
else if(held.getItem() == Items.ITEM_FRAME && facing.getAxis().isHorizontal()){
if(!jar.hasLabel(facing)){
jar.setHasLabel(facing, true);
if(!player.capabilities.isCreativeMode){
player.setHeldItem(hand, ItemUtil.consumeItem(held));
}
BlockUtil.markBlockForUpdate(world, pos);
return true;
}
}
else if(held.getItem() == Items.POTIONITEM){
PotionType type = PotionUtils.getPotionFromItem(held);
if(type.getEffects().size() > 0 && (jar.getPotion() == type || jar.getPotion() == PotionTypes.EMPTY)){
if(jar.getPotionCount() < 3){
if(jar.getPotion() == PotionTypes.EMPTY){
jar.setPotionType(type);
}
jar.setPotionCount(jar.getPotionCount()+1);
player.setHeldItem(hand, new ItemStack(Items.GLASS_BOTTLE));
BlockUtil.markBlockForUpdate(world, pos);
return true;
}
}
} else if(held.getItem() == Items.GLASS_BOTTLE){
if(jar.getPotion() !=PotionTypes.EMPTY && jar.getPotionCount() > 0){
player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), jar.getPotion()));
jar.setPotionCount(jar.getPotionCount()-1);
if(jar.getPotionCount() <= 0){
jar.setPotionType(PotionTypes.EMPTY);
}
BlockUtil.markBlockForUpdate(world, pos);
return true;
}
}
}
return false;
}
示例11: isInput
import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@Override
default boolean isInput(ItemStack input) {
return input.getItem() == Items.POTIONITEM && PotionUtils.getPotionFromItem(input) == PotionTypes.AWKWARD;
}