use of net.glowstone.inventory.GlowMetaPotion in project Glowstone by GlowstoneMC.
the class AreaEffectCloudStore method save.
@Override
public void save(GlowAreaEffectCloud entity, CompoundTag tag) {
super.save(entity, tag);
tag.putInt("Age", entity.getTicksLived());
Color color = entity.getColor();
if (color != null) {
tag.putInt(COLOR, color.asRGB());
}
tag.putInt(DURATION, entity.getDuration());
tag.putInt(REAPPLICATION_DELAY, entity.getReapplicationDelay());
tag.putInt(WAIT_TIME, entity.getWaitTime());
ProjectileSource source = entity.getSource();
if (source instanceof Entity) {
UUID uuid = ((Entity) source).getUniqueId();
tag.putLong(OWNER_UUID_LEAST, uuid.getLeastSignificantBits());
tag.putLong(OWNER_UUID_MOST, uuid.getMostSignificantBits());
}
tag.putInt(DURATION_ON_USE, entity.getDurationOnUse());
tag.putFloat(RADIUS, entity.getRadius());
tag.putFloat(RADIUS_ON_USE, entity.getRadiusOnUse());
tag.putFloat(RADIUS_PER_TICK, entity.getRadiusPerTick());
Particle particle = entity.getParticle();
if (particle != null) {
tag.putString(PARTICLE, particle.toString());
}
PotionData potion = entity.getBasePotionData();
if (potion != null) {
tag.putString(POTION, GlowMetaPotion.dataToString(potion));
}
tag.putCompoundList(EFFECTS, entity.getCustomEffects().stream().map(GlowMetaPotion::toNbt).collect(Collectors.toList()));
// TODO: Are ParticleParam1 and ParticleParam2 unused?
}
use of net.glowstone.inventory.GlowMetaPotion in project Glowstone by GlowstoneMC.
the class ItemBowTest method testTippedArrow.
@Test
public void testTippedArrow() {
ItemStack arrow = new ItemStack(Material.TIPPED_ARROW, 1);
GlowMetaPotion potion = new GlowMetaPotion(arrow.getItemMeta());
potion.setColor(Color.PURPLE);
final PotionData potionData = new PotionData(PotionType.FIRE_RESISTANCE);
potion.setBasePotionData(potionData);
final PotionEffect effect = new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 10, 1);
potion.addCustomEffect(effect, false);
assertTrue(arrow.setItemMeta(potion));
inventory.addItem(arrow);
// Should now be able to start shooting
bow.startUse(player, bowItemStack);
verify(player, times(1)).setUsageItem(bowItemStack);
verify(player, times(1)).setUsageTime(anyInt());
when(player.getUsageTime()).thenReturn(10);
// Finish shooting
bow.endUse(player, bowItemStack);
verify(player, times(1)).launchProjectile(TippedArrow.class);
verify(launchedTippedArrow, times(1)).setColor(Color.PURPLE);
verify(launchedTippedArrow, times(1)).setBasePotionData(potionData);
verify(launchedTippedArrow, times(1)).addCustomEffect(eq(effect), anyBoolean());
verify(player, times(1)).setUsageItem(null);
verify(player, times(1)).setUsageTime(0);
checkInventory(inventory, 1, BOW_WITH_DAMAGE_1);
checkInventory(inventory, 0, BOW_WITH_DAMAGE_NOT_1);
checkInventory(inventory, 0, item -> ARROW_TYPES.contains(item.getType()));
}
use of net.glowstone.inventory.GlowMetaPotion in project Glowstone by GlowstoneMC.
the class NormalTippedArrowStore method save.
@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()));
}
}
use of net.glowstone.inventory.GlowMetaPotion in project Glowstone by GlowstoneMC.
the class NormalTippedArrowStore method load.
@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)));
}
}
Aggregations