@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 save(GlowArrow entity, CompoundTag tag) { super.save(entity, tag); if (entity instanceof TippedArrow) { PotionData potion = ((TippedArrow) entity).getBasePotionData(); if (potion != null) { tag.putString(POTION, GlowMetaPotion.dataToString(potion)); } tag.putCompoundList(CUSTOM_POTION_EFFECTS, ((TippedArrow) entity).getCustomEffects() .stream() .map(GlowMetaPotion::toNbt) .collect(Collectors.toList())); } }
((TippedArrow) arrow).setBasePotionData(data); for (PotionEffect effect : ((PotionMeta) type.getItemMeta()).getCustomEffects()) { ((TippedArrow) arrow).addCustomEffect(effect, 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(); }
@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 MCPotionData getBasePotionData() { return new BukkitMCPotionData(ta.getBasePotionData()); }
@Override public List<MCLivingEntity.MCEffect> getCustomEffects() { List<MCLivingEntity.MCEffect> list = new ArrayList<>(); for(PotionEffect pe : ta.getCustomEffects()) { list.add(new MCLivingEntity.MCEffect(BukkitMCPotionEffectType.valueOfConcrete(pe.getType()), pe.getAmplifier(), pe.getDuration(), pe.isAmbient(), pe.hasParticles(), pe.hasIcon())); } return list; }
@Override public void setBasePotionData(MCPotionData pd) { ta.setBasePotionData((PotionData) pd.getHandle()); }
@Override public void clearCustomEffects() { ta.clearCustomEffects(); }
PotionEffectType baseEffect = tippedArrow.getBasePotionData().getType().getEffectType(); if (wcfg.blockPotions.contains(baseEffect)) { blockedEffect = baseEffect; } else { for (PotionEffect potionEffect : tippedArrow.getCustomEffects()) { if (wcfg.blockPotions.contains(potionEffect.getType())) { blockedEffect = potionEffect.getType();