net.minecraft.potion.PotionUtil Java Examples
The following examples show how to use
net.minecraft.potion.PotionUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PotionCmd.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private ListTag convertEffectsToNbt(ItemStack stack) { ListTag nbt = new ListTag(); List<StatusEffectInstance> effects = PotionUtil.getCustomPotionEffects(stack); for(StatusEffectInstance effect : effects) { CompoundTag tag = new CompoundTag(); int id = StatusEffect.getRawId(effect.getEffectType()); tag.putInt("Id", id); tag.putInt("Amplifier", effect.getAmplifier()); tag.putInt("Duration", effect.getDuration()); nbt.add(tag); } return nbt; }
Example #2
Source File: MixinPotionItems.java From patchwork-api with GNU Lesser General Public License v2.1 | 6 votes |
@Override public String getCreatorModId(ItemStack itemStack) { final Item item = itemStack.getItem(); Identifier defaultId = Registry.ITEM.getDefaultId(); Identifier id = Registry.ITEM.getId(item); if (defaultId.equals(id) && item != Registry.ITEM.get(defaultId)) { return null; } else { final String namespace = id.getNamespace(); if ("minecraft".equals(namespace)) { final Potion potion = PotionUtil.getPotion(itemStack); defaultId = Registry.POTION.getDefaultId(); id = Registry.POTION.getId(potion); if (defaultId.equals(id) && potion != Registry.POTION.get(defaultId)) { return namespace; } return id.getNamespace(); } return namespace; } }
Example #3
Source File: AutoPotionHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private boolean hasEffect(ItemStack stack, StatusEffect effect) { for(StatusEffectInstance effectInstance : PotionUtil .getPotionEffects(stack)) { if(effectInstance.getEffectType() != effect) continue; return true; } return false; }
Example #4
Source File: PotionCmd.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private void remove(ItemStack stack, String[] args) throws CmdSyntaxError { if(args.length != 2) throw new CmdSyntaxError(); int id = parseEffectId(args[1]); List<StatusEffectInstance> oldEffects = PotionUtil.getCustomPotionEffects(stack); ListTag newEffects = new ListTag(); for(StatusEffectInstance oldEffect : oldEffects) { int oldId = StatusEffect.getRawId(oldEffect.getEffectType()); if(oldId == id) continue; CompoundTag effect = new CompoundTag(); effect.putInt("Id", oldId); effect.putInt("Amplifier", oldEffect.getAmplifier()); effect.putInt("Duration", oldEffect.getDuration()); newEffects.add(effect); } CompoundTag nbt = new CompoundTag(); nbt.put("CustomPotionEffects", newEffects); stack.setTag(nbt); ChatUtils.message("Effect removed."); }