@Override public void load(GlowArrow entity, CompoundTag tag) { super.load(entity, tag); if (entity instanceof TippedArrow) { TippedArrow tippedArrow = (TippedArrow) entity; tag.readInt(COLOR, rgb -> tippedArrow.setColor(Color.fromRGB(rgb))); // TODO: POTION tag.readCompoundList(CUSTOM_POTION_EFFECTS, list -> list .stream() .map(GlowMetaPotion::fromNbt) .forEach(effect -> tippedArrow.addCustomEffect(effect, false))); } }
@Override public void addCustomEffect(MCLivingEntity.MCEffect effect) { PotionEffect pe = new PotionEffect((PotionEffectType) effect.getPotionEffectType().getConcrete(), effect.getTicksRemaining(), effect.getStrength(), effect.isAmbient(), effect.hasParticles(), effect.showIcon()); ta.addCustomEffect(pe, true); }
@Override public PowerResult<Void> rightClick(Player player, ItemStack stack, PlayerInteractEvent event) { if (!checkCooldown(this, player, cooldown, true, true)) return PowerResult.cd(); if (!getItem().consumeDurability(stack, cost)) return PowerResult.cost(); player.playSound(player.getLocation(), Sound.ENTITY_ARROW_SHOOT, 1.0f, 1.0f); Events.registerRPGProjectile(this.getItem(), stack, player); TippedArrow arrow = player.launchProjectile(TippedArrow.class); arrow.addCustomEffect(new PotionEffect(type, duration, amplifier), true); Events.autoRemoveProjectile(arrow.getEntityId()); return PowerResult.ok(); }
((TippedArrow) arrow).setBasePotionData(data); for (PotionEffect effect : ((PotionMeta) type.getItemMeta()).getCustomEffects()) { ((TippedArrow) arrow).addCustomEffect(effect, true);