mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Remove the update argument when interacting with spell slots
This commit is contained in:
parent
b9015c9220
commit
4bac633a23
34 changed files with 80 additions and 80 deletions
|
@ -51,7 +51,7 @@ public class ChangelingDisguiseAbility extends ChangelingFeedAbility {
|
||||||
|
|
||||||
player.getEntityWorld().playSound(null, player.getBlockPos(), USounds.ENTITY_PLAYER_CHANGELING_TRANSFORM, SoundCategory.PLAYERS, 1.4F, 0.4F);
|
player.getEntityWorld().playSound(null, player.getBlockPos(), USounds.ENTITY_PLAYER_CHANGELING_TRANSFORM, SoundCategory.PLAYERS, 1.4F, 0.4F);
|
||||||
|
|
||||||
Disguise currentDisguise = iplayer.getSpellSlot().get(SpellType.CHANGELING_DISGUISE, true)
|
Disguise currentDisguise = iplayer.getSpellSlot().get(SpellType.CHANGELING_DISGUISE)
|
||||||
.orElseGet(() -> SpellType.CHANGELING_DISGUISE.withTraits().apply(iplayer, CastingMethod.INNATE));
|
.orElseGet(() -> SpellType.CHANGELING_DISGUISE.withTraits().apply(iplayer, CastingMethod.INNATE));
|
||||||
|
|
||||||
if (currentDisguise.isOf(looked)) {
|
if (currentDisguise.isOf(looked)) {
|
||||||
|
|
|
@ -57,9 +57,7 @@ public class TimeChangeAbility implements Ability<Rot> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.getSpellSlot().contains(SpellType.TIME_CONTROL)) {
|
if (!player.getSpellSlot().removeWhere(SpellType.TIME_CONTROL)) {
|
||||||
player.getSpellSlot().removeWhere(SpellType.TIME_CONTROL, true);
|
|
||||||
} else {
|
|
||||||
SpellType.TIME_CONTROL.withTraits().apply(player, CastingMethod.INNATE).update(player, data.applyTo(player));
|
SpellType.TIME_CONTROL.withTraits().apply(player, CastingMethod.INNATE).update(player, data.applyTo(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class UnicornCastingAbility extends AbstractSpellCastingAbility {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasExact = !spell.isStackable() && player.getSpellSlot().contains(s -> !s.getTypeAndTraits().isStackable() && spell.test(s));
|
boolean hasExact = !spell.isStackable() && player.getSpellSlot().contains(s -> !s.getTypeAndTraits().isStackable() && spell.test(s));
|
||||||
boolean removed = !spell.isStackable() && player.getSpellSlot().removeWhere(s -> !s.getTypeAndTraits().isStackable() && s.findMatches(spell.type()).findAny().isPresent(), true);
|
boolean removed = !spell.isStackable() && player.getSpellSlot().removeWhere(s -> !s.getTypeAndTraits().isStackable() && s.findMatches(spell.type()).findAny().isPresent());
|
||||||
player.subtractEnergyCost(removed ? 2 : 4);
|
player.subtractEnergyCost(removed ? 2 : 4);
|
||||||
if (!hasExact && !spell.isEmpty()) {
|
if (!hasExact && !spell.isEmpty()) {
|
||||||
Spell s = spell.apply(player, CastingMethod.DIRECT);
|
Spell s = spell.apply(player, CastingMethod.DIRECT);
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class UnicornDispellAbility implements Ability<Pos> {
|
||||||
spell.setDead();
|
spell.setDead();
|
||||||
spell.tickDying(target);
|
spell.tickDying(target);
|
||||||
return Operation.ofBoolean(!spell.isDead());
|
return Operation.ofBoolean(!spell.isDead());
|
||||||
}, true);
|
});
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,20 +19,20 @@ public interface SpellContainer {
|
||||||
* Checks if any matching spells are active.
|
* Checks if any matching spells are active.
|
||||||
*/
|
*/
|
||||||
default boolean contains(@Nullable SpellPredicate<?> type) {
|
default boolean contains(@Nullable SpellPredicate<?> type) {
|
||||||
return get(type, true).isPresent();
|
return get(type).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the active effect for this caster updating it if needed.
|
* Gets the active effect for this caster updating it if needed.
|
||||||
*/
|
*/
|
||||||
default <T extends Spell> Optional<T> get(boolean update) {
|
default <T extends Spell> Optional<T> get() {
|
||||||
return get(null, update);
|
return get(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the active effect for this caster updating it if needed.
|
* Gets the active effect for this caster updating it if needed.
|
||||||
*/
|
*/
|
||||||
<T extends Spell> Optional<T> get(@Nullable SpellPredicate<T> type, boolean update);
|
<T extends Spell> Optional<T> get(@Nullable SpellPredicate<T> type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the active effect.
|
* Sets the active effect.
|
||||||
|
@ -51,8 +51,8 @@ public interface SpellContainer {
|
||||||
*
|
*
|
||||||
* @return True if the collection was changed
|
* @return True if the collection was changed
|
||||||
*/
|
*/
|
||||||
default boolean removeIf(Predicate<Spell> test, boolean update) {
|
default boolean removeIf(Predicate<Spell> test) {
|
||||||
return removeWhere(spell -> spell.findMatches(test).findFirst().isPresent(), update);
|
return removeWhere(spell -> spell.findMatches(test).findFirst().isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,25 +60,25 @@ public interface SpellContainer {
|
||||||
*
|
*
|
||||||
* @return True if the collection was changed
|
* @return True if the collection was changed
|
||||||
*/
|
*/
|
||||||
boolean removeWhere(Predicate<Spell> test, boolean update);
|
boolean removeWhere(Predicate<Spell> test);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates active spells and optionally removes matching ones.
|
* Iterates active spells and optionally removes matching ones.
|
||||||
*
|
*
|
||||||
* @return True if any matching spells remain active
|
* @return True if any matching spells remain active
|
||||||
*/
|
*/
|
||||||
boolean forEach(Function<Spell, Operation> action, boolean update);
|
boolean forEach(Function<Spell, Operation> action);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all active effects for this caster updating it if needed.
|
* Gets all active effects for this caster updating it if needed.
|
||||||
*/
|
*/
|
||||||
Stream<Spell> stream(boolean update);
|
Stream<Spell> stream();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all active effects for this caster that match the given type updating it if needed.
|
* Gets all active effects for this caster that match the given type updating it if needed.
|
||||||
*/
|
*/
|
||||||
<T extends Spell> Stream<T> stream(@Nullable SpellPredicate<T> type, boolean update);
|
<T extends Spell> Stream<T> stream(@Nullable SpellPredicate<T> type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all effects currently active in this slot.
|
* Removes all effects currently active in this slot.
|
||||||
|
|
|
@ -71,7 +71,7 @@ public abstract class AbstractDisguiseSpell extends AbstractSpell implements Dis
|
||||||
public static Entity getAppearance(Entity e) {
|
public static Entity getAppearance(Entity e) {
|
||||||
return e instanceof PlayerEntity ? Pony.of((PlayerEntity)e)
|
return e instanceof PlayerEntity ? Pony.of((PlayerEntity)e)
|
||||||
.getSpellSlot()
|
.getSpellSlot()
|
||||||
.get(SpellPredicate.IS_DISGUISE, true)
|
.get(SpellPredicate.IS_DISGUISE)
|
||||||
.map(AbstractDisguiseSpell::getDisguise)
|
.map(AbstractDisguiseSpell::getDisguise)
|
||||||
.map(EntityAppearance::getAppearance)
|
.map(EntityAppearance::getAppearance)
|
||||||
.orElse(e) : e;
|
.orElse(e) : e;
|
||||||
|
|
|
@ -71,8 +71,7 @@ public class BubbleSpell extends AbstractSpell implements TimedSpell,
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Caster<?> source) {
|
public boolean apply(Caster<?> source) {
|
||||||
|
|
||||||
if (getType().isOn(source)) {
|
if (source.getSpellSlot().removeWhere(getType())) {
|
||||||
source.getSpellSlot().removeWhere(getType(), true);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DisperseIllusionSpell extends AbstractAreaEffectSpell {
|
||||||
}
|
}
|
||||||
|
|
||||||
source.findAllSpellsInRange(range).forEach(e -> {
|
source.findAllSpellsInRange(range).forEach(e -> {
|
||||||
e.getSpellSlot().get(SpellPredicate.CAN_SUPPRESS, false)
|
e.getSpellSlot().get(SpellPredicate.CAN_SUPPRESS)
|
||||||
.filter(spell -> spell.isVulnerable(source, this))
|
.filter(spell -> spell.isVulnerable(source, this))
|
||||||
.ifPresent(spell -> {
|
.ifPresent(spell -> {
|
||||||
spell.onSuppressed(source, 1 + getTraits().get(Trait.STRENGTH));
|
spell.onSuppressed(source, 1 + getTraits().get(Trait.STRENGTH));
|
||||||
|
|
|
@ -60,8 +60,8 @@ public class MindSwapSpell extends MimicSpell implements ProjectileDelegate.Enti
|
||||||
LivingEntity master = caster.getMaster();
|
LivingEntity master = caster.getMaster();
|
||||||
Caster<?> other = Caster.of(e).get();
|
Caster<?> other = Caster.of(e).get();
|
||||||
|
|
||||||
other.getSpellSlot().removeIf(SpellType.MIMIC, true);
|
other.getSpellSlot().removeIf(SpellType.MIMIC);
|
||||||
caster.getSpellSlot().removeIf(getType(), true);
|
caster.getSpellSlot().removeIf(getType());
|
||||||
|
|
||||||
if (!isValidTarget(master) || !isValidTarget(e)) {
|
if (!isValidTarget(master) || !isValidTarget(e)) {
|
||||||
master.damage(caster.asWorld().getDamageSources().magic(), Float.MAX_VALUE);
|
master.damage(caster.asWorld().getDamageSources().magic(), Float.MAX_VALUE);
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class DismissSpellScreen extends GameGui {
|
||||||
|
|
||||||
List<PlaceableSpell> placeableSpells = new ArrayList<>();
|
List<PlaceableSpell> placeableSpells = new ArrayList<>();
|
||||||
|
|
||||||
for (Spell spell : pony.getSpellSlot().stream(true).filter(SpellPredicate.IS_VISIBLE).toList()) {
|
for (Spell spell : pony.getSpellSlot().stream().filter(SpellPredicate.IS_VISIBLE).toList()) {
|
||||||
|
|
||||||
if (spell instanceof PlaceableSpell placeable) {
|
if (spell instanceof PlaceableSpell placeable) {
|
||||||
if (placeable.getPosition().isPresent()) {
|
if (placeable.getPosition().isPresent()) {
|
||||||
|
@ -147,7 +147,7 @@ public class DismissSpellScreen extends GameGui {
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (isMouseOver(relativeMouseX, relativeMouseY)) {
|
if (isMouseOver(relativeMouseX, relativeMouseY)) {
|
||||||
remove(this);
|
remove(this);
|
||||||
pony.getSpellSlot().removeIf(spell -> spell == this.spell, true);
|
pony.getSpellSlot().removeIf(spell -> spell == this.spell);
|
||||||
Channel.REMOVE_SPELL.sendToServer(new MsgRemoveSpell(spell));
|
Channel.REMOVE_SPELL.sendToServer(new MsgRemoveSpell(spell));
|
||||||
playClickEffect();
|
playClickEffect();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -35,11 +35,11 @@ public interface SpellIconRenderer {
|
||||||
|
|
||||||
DrawableUtil.drawArc(modelStack, radius, radius + 3, 0, DrawableUtil.TAU, color & 0xFFFFFF2F, false);
|
DrawableUtil.drawArc(modelStack, radius, radius + 3, 0, DrawableUtil.TAU, color & 0xFFFFFF2F, false);
|
||||||
DrawableUtil.drawArc(modelStack, radius + 3, radius + 4, 0, DrawableUtil.TAU, color & 0xFFFFFFAF, false);
|
DrawableUtil.drawArc(modelStack, radius + 3, radius + 4, 0, DrawableUtil.TAU, color & 0xFFFFFFAF, false);
|
||||||
pony.getSpellSlot().get(spell.and(SpellPredicate.IS_TIMED), false).map(TimedSpell::getTimer).ifPresent(timer -> {
|
pony.getSpellSlot().get(spell.and(SpellPredicate.IS_TIMED)).map(TimedSpell::getTimer).ifPresent(timer -> {
|
||||||
DrawableUtil.drawArc(modelStack, radius, radius + 3, 0, DrawableUtil.TAU * timer.getPercentTimeRemaining(client.getTickDelta()), 0xFFFFFFFF, false);
|
DrawableUtil.drawArc(modelStack, radius, radius + 3, 0, DrawableUtil.TAU * timer.getPercentTimeRemaining(client.getTickDelta()), 0xFFFFFFFF, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
long count = pony.getSpellSlot().stream(spell, false).count();
|
long count = pony.getSpellSlot().stream(spell).count();
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
modelStack.push();
|
modelStack.push();
|
||||||
modelStack.translate(1, 1, 900);
|
modelStack.translate(1, 1, 900);
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class SpellbookProfilePageContent implements SpellbookChapterList.Content
|
||||||
int color = 0x10404000 | alpha;
|
int color = 0x10404000 | alpha;
|
||||||
int xpColor = 0xAA0040FF | ((int)((0.3F + 0.7F * xpPercentage) * 0xFF) & 0xFF) << 16;
|
int xpColor = 0xAA0040FF | ((int)((0.3F + 0.7F * xpPercentage) * 0xFF) & 0xFF) << 16;
|
||||||
int manaColor = 0xFF00F040;
|
int manaColor = 0xFF00F040;
|
||||||
if (pony.getSpellSlot().get(SpellPredicate.IS_CORRUPTING, false).isPresent()) {
|
if (pony.getSpellSlot().get(SpellPredicate.IS_CORRUPTING).isPresent()) {
|
||||||
manaColor = ColorHelper.lerp(Math.abs(MathHelper.sin(pony.asEntity().age / 15F)), manaColor, 0xFF0030F0);
|
manaColor = ColorHelper.lerp(Math.abs(MathHelper.sin(pony.asEntity().age / 15F)), manaColor, 0xFF0030F0);
|
||||||
}
|
}
|
||||||
manaColor |= (int)((0.3F + 0.7F * alphaF) * 0x40) << 16;
|
manaColor |= (int)((0.3F + 0.7F * alphaF) * 0x40) << 16;
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class DisguisedArmsFeatureRenderer<E extends LivingEntity> implements Acc
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entity getAppearance(E entity) {
|
private Entity getAppearance(E entity) {
|
||||||
return Caster.of(entity).flatMap(caster -> caster.getSpellSlot().get(SpellPredicate.IS_DISGUISE, false)).map(Disguise.class::cast)
|
return Caster.of(entity).flatMap(caster -> caster.getSpellSlot().get(SpellPredicate.IS_DISGUISE)).map(Disguise.class::cast)
|
||||||
.flatMap(Disguise::getAppearance)
|
.flatMap(Disguise::getAppearance)
|
||||||
.map(EntityAppearance::getAppearance)
|
.map(EntityAppearance::getAppearance)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class EntityReplacementManager implements Disguise {
|
||||||
return Optional.of(this);
|
return Optional.of(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return caster.getSpellSlot().get(SpellPredicate.IS_DISGUISE, false).map(Disguise.class::cast);
|
return caster.getSpellSlot().get(SpellPredicate.IS_DISGUISE).map(Disguise.class::cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EntityType<?>> getMobTypePool(EntityType<?> type) {
|
private List<EntityType<?>> getMobTypePool(EntityType<?> type) {
|
||||||
|
|
|
@ -55,7 +55,9 @@ public class HornFeatureRenderer<E extends LivingEntity> implements AccessoryFea
|
||||||
return pony.getAbilities().getActiveStat()
|
return pony.getAbilities().getActiveStat()
|
||||||
.flatMap(Stat::getActiveAbility)
|
.flatMap(Stat::getActiveAbility)
|
||||||
.map(ability -> ability.getColor(pony))
|
.map(ability -> ability.getColor(pony))
|
||||||
.filter(i -> i != -1).or(() -> pony.getSpellSlot().get(SpellPredicate.IS_NOT_PLACED, false).map(spell -> spell.getTypeAndTraits().type().getColor()));
|
.filter(i -> i != -1).or(() -> pony.getSpellSlot()
|
||||||
|
.get(SpellPredicate.IS_NOT_PLACED)
|
||||||
|
.map(spell -> spell.getTypeAndTraits().type().getColor()));
|
||||||
}).ifPresent(color -> {
|
}).ifPresent(color -> {
|
||||||
model.setState(true);
|
model.setState(true);
|
||||||
model.render(stack, ItemRenderer.getArmorGlintConsumer(renderContext, RenderLayers.getMagicColored((0x99 << 24) | color), false, false), lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
model.render(stack, ItemRenderer.getArmorGlintConsumer(renderContext, RenderLayers.getMagicColored((0x99 << 24) | color), false, false), lightUv, OverlayTexture.DEFAULT_UV, 1, 1, 1, 1);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class MagicBeamEntityRenderer extends EntityRenderer<MagicBeamEntity> {
|
||||||
-entity.getPitch(tickDelta) * MathHelper.RADIANS_PER_DEGREE
|
-entity.getPitch(tickDelta) * MathHelper.RADIANS_PER_DEGREE
|
||||||
);
|
);
|
||||||
|
|
||||||
RenderLayer layer = entity.getSpellSlot().get(true)
|
RenderLayer layer = entity.getSpellSlot().get()
|
||||||
.map(spell -> (0x99 << 24) | spell.getTypeAndTraits().type().getColor())
|
.map(spell -> (0x99 << 24) | spell.getTypeAndTraits().type().getColor())
|
||||||
.map(RenderLayers::getMagicColored)
|
.map(RenderLayers::getMagicColored)
|
||||||
.orElseGet(RenderLayers::getMagicColored);
|
.orElseGet(RenderLayers::getMagicColored);
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class SpellEffectsRenderDispatcher implements SynchronousResourceReloader
|
||||||
caster.getSpellSlot().forEach(spell -> {
|
caster.getSpellSlot().forEach(spell -> {
|
||||||
render(matrices, vertices, spell, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
|
render(matrices, vertices, spell, caster, light, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch);
|
||||||
return Operation.SKIP;
|
return Operation.SKIP;
|
||||||
}, false);
|
});
|
||||||
|
|
||||||
if (client.getEntityRenderDispatcher().shouldRenderHitboxes()
|
if (client.getEntityRenderDispatcher().shouldRenderHitboxes()
|
||||||
&& !client.hasReducedDebugInfo()
|
&& !client.hasReducedDebugInfo()
|
||||||
|
@ -125,7 +125,7 @@ public class SpellEffectsRenderDispatcher implements SynchronousResourceReloader
|
||||||
caster.asEntity().getDisplayName().copy().append(" (" + Registries.ENTITY_TYPE.getId(caster.asEntity().getType()) + ")"),
|
caster.asEntity().getDisplayName().copy().append(" (" + Registries.ENTITY_TYPE.getId(caster.asEntity().getType()) + ")"),
|
||||||
caster.getMaster() != null ? Text.literal("Master: ").append(caster.getMaster().getDisplayName()) : Text.empty()
|
caster.getMaster() != null ? Text.literal("Master: ").append(caster.getMaster().getDisplayName()) : Text.empty()
|
||||||
),
|
),
|
||||||
caster.getSpellSlot().stream(SpellPredicate.ALL, false).flatMap(spell ->
|
caster.getSpellSlot().stream(SpellPredicate.ALL).flatMap(spell ->
|
||||||
Stream.of(
|
Stream.of(
|
||||||
Text.literal("UUID: " + spell.getUuid()),
|
Text.literal("UUID: " + spell.getUuid()),
|
||||||
Text.literal("|>Type: ").append(Text.literal(spell.getTypeAndTraits().type().getId().toString()).styled(s -> s.withColor(spell.getTypeAndTraits().type().getColor()))),
|
Text.literal("|>Type: ").append(Text.literal(spell.getTypeAndTraits().type().getId().toString()).styled(s -> s.withColor(spell.getTypeAndTraits().type().getColor()))),
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class DisguiseCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
Pony iplayer = Pony.of(player);
|
Pony iplayer = Pony.of(player);
|
||||||
iplayer.getSpellSlot().get(SpellType.CHANGELING_DISGUISE, true)
|
iplayer.getSpellSlot().get(SpellType.CHANGELING_DISGUISE)
|
||||||
.orElseGet(() -> SpellType.CHANGELING_DISGUISE.withTraits().apply(iplayer, CastingMethod.INNATE))
|
.orElseGet(() -> SpellType.CHANGELING_DISGUISE.withTraits().apply(iplayer, CastingMethod.INNATE))
|
||||||
.setDisguise(entity);
|
.setDisguise(entity);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public class DisguiseCommand {
|
||||||
|
|
||||||
static int reveal(ServerCommandSource source, PlayerEntity player) {
|
static int reveal(ServerCommandSource source, PlayerEntity player) {
|
||||||
Pony iplayer = Pony.of(player);
|
Pony iplayer = Pony.of(player);
|
||||||
iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE, true);
|
iplayer.getSpellSlot().removeIf(SpellPredicate.IS_DISGUISE);
|
||||||
|
|
||||||
if (source.getEntity() == player) {
|
if (source.getEntity() == player) {
|
||||||
source.sendFeedback(() -> Text.translatable("commands.disguise.removed.self"), true);
|
source.sendFeedback(() -> Text.translatable("commands.disguise.removed.self"), true);
|
||||||
|
|
|
@ -311,7 +311,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
@Override
|
@Override
|
||||||
public void toNBT(NbtCompound compound) {
|
public void toNBT(NbtCompound compound) {
|
||||||
super.toNBT(compound);
|
super.toNBT(compound);
|
||||||
getSpellSlot().get(true).ifPresent(effect -> {
|
getSpellSlot().get().ifPresent(effect -> {
|
||||||
compound.put("effect", Spell.writeNbt(effect));
|
compound.put("effect", Spell.writeNbt(effect));
|
||||||
});
|
});
|
||||||
compound.put("master", getMasterReference().toNBT());
|
compound.put("master", getMasterReference().toNBT());
|
||||||
|
|
|
@ -290,7 +290,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
public boolean canBeSeenBy(Entity entity) {
|
public boolean canBeSeenBy(Entity entity) {
|
||||||
return !isInvisible()
|
return !isInvisible()
|
||||||
&& getSpellSlot()
|
&& getSpellSlot()
|
||||||
.get(SpellPredicate.IS_DISGUISE, true)
|
.get(SpellPredicate.IS_DISGUISE)
|
||||||
.filter(spell -> spell.getDisguise().getAppearance() == entity)
|
.filter(spell -> spell.getDisguise().getAppearance() == entity)
|
||||||
.isEmpty();
|
.isEmpty();
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<BlockPos> chooseClimbingPos() {
|
public Optional<BlockPos> chooseClimbingPos() {
|
||||||
return getSpellSlot().get(SpellPredicate.IS_DISGUISE, false)
|
return getSpellSlot().get(SpellPredicate.IS_DISGUISE)
|
||||||
.map(AbstractDisguiseSpell::getDisguise)
|
.map(AbstractDisguiseSpell::getDisguise)
|
||||||
.filter(EntityAppearance::canClimbWalls)
|
.filter(EntityAppearance::canClimbWalls)
|
||||||
.map(v -> entity.getBlockPos());
|
.map(v -> entity.getBlockPos());
|
||||||
|
@ -459,7 +459,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onProjectileImpact(ProjectileEntity projectile) {
|
public boolean onProjectileImpact(ProjectileEntity projectile) {
|
||||||
return getSpellSlot().get(true)
|
return getSpellSlot().get()
|
||||||
.filter(effect -> !effect.isDead()
|
.filter(effect -> !effect.isDead()
|
||||||
&& effect instanceof ProjectileImpactListener
|
&& effect instanceof ProjectileImpactListener
|
||||||
&& ((ProjectileImpactListener)effect).onProjectileImpact(projectile))
|
&& ((ProjectileImpactListener)effect).onProjectileImpact(projectile))
|
||||||
|
@ -469,7 +469,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
public float onImpact(float distance, float damageMultiplier, DamageSource cause) {
|
public float onImpact(float distance, float damageMultiplier, DamageSource cause) {
|
||||||
float fallDistance = landEvent.fire(getEffectiveFallDistance(distance));
|
float fallDistance = landEvent.fire(getEffectiveFallDistance(distance));
|
||||||
|
|
||||||
getSpellSlot().get(SpellPredicate.IS_DISGUISE, false).ifPresent(spell -> {
|
getSpellSlot().get(SpellPredicate.IS_DISGUISE).ifPresent(spell -> {
|
||||||
spell.getDisguise().onImpact(this, fallDistance, damageMultiplier, cause);
|
spell.getDisguise().onImpact(this, fallDistance, damageMultiplier, cause);
|
||||||
});
|
});
|
||||||
return fallDistance;
|
return fallDistance;
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class EntityCollisions {
|
||||||
ShapeContext ctx = entity == null ? ShapeContext.absent() : ShapeContext.of(entity);
|
ShapeContext ctx = entity == null ? ShapeContext.absent() : ShapeContext.of(entity);
|
||||||
return collectCollisionBoxes(box, collector -> {
|
return collectCollisionBoxes(box, collector -> {
|
||||||
world.getOtherEntities(entity, box.expand(50), e -> {
|
world.getOtherEntities(entity, box.expand(50), e -> {
|
||||||
Caster.of(e).flatMap(c -> c.getSpellSlot().get(SpellPredicate.IS_DISGUISE, false)).ifPresent(p -> {
|
Caster.of(e).flatMap(c -> c.getSpellSlot().get(SpellPredicate.IS_DISGUISE)).ifPresent(p -> {
|
||||||
p.getDisguise().getCollissionShapes(ctx, collector);
|
p.getDisguise().getCollissionShapes(ctx, collector);
|
||||||
});
|
});
|
||||||
if (e instanceof ComplexCollidable collidable) {
|
if (e instanceof ComplexCollidable collidable) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityDimensions getDimensions(EntityPose pose) {
|
public EntityDimensions getDimensions(EntityPose pose) {
|
||||||
return super.getDimensions(pose).scaled(getSpellSlot().get(SpellType.IS_PLACED, false).map(spell -> spell.getScale(1)).orElse(1F));
|
return super.getDimensions(pose).scaled(getSpellSlot().get(SpellType.IS_PLACED).map(spell -> spell.getScale(1)).orElse(1F));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,7 +108,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Affinity getAffinity() {
|
public Affinity getAffinity() {
|
||||||
return getSpellSlot().get(true).map(Spell::getAffinity).orElse(Affinity.NEUTRAL);
|
return getSpellSlot().get().map(Spell::getAffinity).orElse(Affinity.NEUTRAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -142,7 +142,7 @@ public class CastSpellEntity extends LightEmittingEntity implements Caster<CastS
|
||||||
tag.put("owner", owner.toNBT());
|
tag.put("owner", owner.toNBT());
|
||||||
tag.put("level", level.toNbt());
|
tag.put("level", level.toNbt());
|
||||||
tag.put("corruption", corruption.toNbt());
|
tag.put("corruption", corruption.toNbt());
|
||||||
getSpellSlot().get(true).ifPresent(effect -> {
|
getSpellSlot().get().ifPresent(effect -> {
|
||||||
tag.put("effect", Spell.writeNbt(effect));
|
tag.put("effect", Spell.writeNbt(effect));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class CorruptionHandler implements Tickable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCorruptingMagic() {
|
public boolean hasCorruptingMagic() {
|
||||||
return pony.getSpellSlot().get(SpellPredicate.IS_CORRUPTING, false).isPresent() || UItems.ALICORN_AMULET.isApplicable(pony.asEntity());
|
return pony.getSpellSlot().get(SpellPredicate.IS_CORRUPTING).isPresent() || UItems.ALICORN_AMULET.isApplicable(pony.asEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class PlayerCamera extends MotionCompositor {
|
||||||
|
|
||||||
public Optional<Double> calculateDistance(double distance) {
|
public Optional<Double> calculateDistance(double distance) {
|
||||||
return player.getSpellSlot()
|
return player.getSpellSlot()
|
||||||
.get(SpellPredicate.IS_DISGUISE, false)
|
.get(SpellPredicate.IS_DISGUISE)
|
||||||
.map(AbstractDisguiseSpell::getDisguise)
|
.map(AbstractDisguiseSpell::getDisguise)
|
||||||
.flatMap(d -> d.getDistance(player))
|
.flatMap(d -> d.getDistance(player))
|
||||||
.map(d -> distance * d);
|
.map(d -> distance * d);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public final class PlayerDimensions {
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Provider> getPredicate() {
|
Optional<Provider> getPredicate() {
|
||||||
return pony.getSpellSlot().get(true)
|
return pony.getSpellSlot().get()
|
||||||
.filter(effect -> !effect.isDead() && effect instanceof Provider)
|
.filter(effect -> !effect.isDead() && effect instanceof Provider)
|
||||||
.map(effect -> (Provider)effect);
|
.map(effect -> (Provider)effect);
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
return FlightType.ARTIFICIAL;
|
return FlightType.ARTIFICIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pony.getSpellSlot().get(true)
|
return pony.getSpellSlot().get()
|
||||||
.filter(effect -> !effect.isDead() && effect instanceof FlightType.Provider)
|
.filter(effect -> !effect.isDead() && effect instanceof FlightType.Provider)
|
||||||
.map(effect -> ((FlightType.Provider)effect).getFlightType())
|
.map(effect -> ((FlightType.Provider)effect).getFlightType())
|
||||||
.filter(FlightType::isPresent)
|
.filter(FlightType::isPresent)
|
||||||
|
|
|
@ -479,7 +479,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
Race intrinsicRace = getSpecies();
|
Race intrinsicRace = getSpecies();
|
||||||
Race suppressedRace = getSuppressedRace();
|
Race suppressedRace = getSuppressedRace();
|
||||||
compositeRace = MetamorphosisStatusEffect.getEffectiveRace(entity, getSpellSlot()
|
compositeRace = MetamorphosisStatusEffect.getEffectiveRace(entity, getSpellSlot()
|
||||||
.get(SpellPredicate.IS_MIMIC, true)
|
.get(SpellPredicate.IS_MIMIC)
|
||||||
.map(AbstractDisguiseSpell::getDisguise)
|
.map(AbstractDisguiseSpell::getDisguise)
|
||||||
.map(EntityAppearance::getAppearance)
|
.map(EntityAppearance::getAppearance)
|
||||||
.flatMap(Pony::of)
|
.flatMap(Pony::of)
|
||||||
|
@ -495,7 +495,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<BlockPos> chooseClimbingPos() {
|
public Optional<BlockPos> chooseClimbingPos() {
|
||||||
if (getObservedSpecies() == Race.CHANGELING && getSpellSlot().get(SpellPredicate.IS_DISGUISE, false).isEmpty()) {
|
if (getObservedSpecies() == Race.CHANGELING && getSpellSlot().get(SpellPredicate.IS_DISGUISE).isEmpty()) {
|
||||||
if (acrobatics.isFaceClimbable(entity.getWorld(), entity.getBlockPos(), entity.getHorizontalFacing()) || acrobatics.canHangAt(entity.getBlockPos())) {
|
if (acrobatics.isFaceClimbable(entity.getWorld(), entity.getBlockPos(), entity.getHorizontalFacing()) || acrobatics.canHangAt(entity.getBlockPos())) {
|
||||||
return Optional.of(entity.getBlockPos());
|
return Optional.of(entity.getBlockPos());
|
||||||
}
|
}
|
||||||
|
@ -718,7 +718,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected float getEffectiveFallDistance(float distance) {
|
protected float getEffectiveFallDistance(float distance) {
|
||||||
boolean extraProtection = getSpellSlot().get(SpellType.SHIELD, false).isPresent();
|
boolean extraProtection = getSpellSlot().get(SpellType.SHIELD).isPresent();
|
||||||
|
|
||||||
if (!entity.isCreative() && !entity.isSpectator()) {
|
if (!entity.isCreative() && !entity.isSpectator()) {
|
||||||
|
|
||||||
|
@ -745,7 +745,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
if (getObservedSpecies() == Race.KIRIN
|
if (getObservedSpecies() == Race.KIRIN
|
||||||
&& (stack.isIn(UTags.Items.COOLS_OFF_KIRINS) || PotionUtil.getPotion(stack) == Potions.WATER)) {
|
&& (stack.isIn(UTags.Items.COOLS_OFF_KIRINS) || PotionUtil.getPotion(stack) == Potions.WATER)) {
|
||||||
getMagicalReserves().getCharge().multiply(0.5F);
|
getMagicalReserves().getCharge().multiply(0.5F);
|
||||||
getSpellSlot().get(SpellType.RAGE, false).ifPresent(RageAbilitySpell::setExtenguishing);
|
getSpellSlot().get(SpellType.RAGE).ifPresent(RageAbilitySpell::setExtenguishing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,7 +758,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
@Override
|
@Override
|
||||||
public boolean subtractEnergyCost(double foodSubtract) {
|
public boolean subtractEnergyCost(double foodSubtract) {
|
||||||
|
|
||||||
if (getSpellSlot().get(SpellPredicate.IS_CORRUPTING, false).isPresent()) {
|
if (getSpellSlot().get(SpellPredicate.IS_CORRUPTING).isPresent()) {
|
||||||
int corruptionTaken = (int)(foodSubtract * (AmuletSelectors.ALICORN_AMULET.test(entity) ? 0.9F : 0.5F));
|
int corruptionTaken = (int)(foodSubtract * (AmuletSelectors.ALICORN_AMULET.test(entity) ? 0.9F : 0.5F));
|
||||||
foodSubtract -= corruptionTaken;
|
foodSubtract -= corruptionTaken;
|
||||||
getCorruption().add(corruptionTaken);
|
getCorruption().add(corruptionTaken);
|
||||||
|
@ -888,13 +888,13 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
Race oldSuppressedRace = oldPlayer.getSuppressedRace();
|
Race oldSuppressedRace = oldPlayer.getSuppressedRace();
|
||||||
|
|
||||||
if (alive) {
|
if (alive) {
|
||||||
oldPlayer.getSpellSlot().stream(true).forEach(getSpellSlot()::put);
|
oldPlayer.getSpellSlot().stream().forEach(getSpellSlot()::put);
|
||||||
} else {
|
} else {
|
||||||
if (forcedSwap) {
|
if (forcedSwap) {
|
||||||
oldSuppressedRace = Race.UNSET;
|
oldSuppressedRace = Race.UNSET;
|
||||||
Channel.SERVER_SELECT_TRIBE.sendToPlayer(new MsgTribeSelect(Race.allPermitted(entity), "gui.unicopia.tribe_selection.respawn"), (ServerPlayerEntity)entity);
|
Channel.SERVER_SELECT_TRIBE.sendToPlayer(new MsgTribeSelect(Race.allPermitted(entity), "gui.unicopia.tribe_selection.respawn"), (ServerPlayerEntity)entity);
|
||||||
} else {
|
} else {
|
||||||
oldPlayer.getSpellSlot().stream(true).filter(SpellPredicate.IS_PLACED).forEach(getSpellSlot()::put);
|
oldPlayer.getSpellSlot().stream().filter(SpellPredicate.IS_PLACED).forEach(getSpellSlot()::put);
|
||||||
}
|
}
|
||||||
|
|
||||||
// putting it here instead of adding another injection point into ServerPlayerEntity.copyFrom()
|
// putting it here instead of adding another injection point into ServerPlayerEntity.copyFrom()
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class EnchantedStaffItem extends StaffItem implements EnchantableItem, Ch
|
||||||
|
|
||||||
public static SpellType<?> getSpellType(Entity entity, boolean remove) {
|
public static SpellType<?> getSpellType(Entity entity, boolean remove) {
|
||||||
if (entity instanceof CastSpellEntity cast) {
|
if (entity instanceof CastSpellEntity cast) {
|
||||||
return cast.getSpellSlot().get(c -> !SpellPredicate.IS_PLACED.test(c), true)
|
return cast.getSpellSlot().get(c -> !SpellPredicate.IS_PLACED.test(c))
|
||||||
.map(Spell::getTypeAndTraits)
|
.map(Spell::getTypeAndTraits)
|
||||||
.map(CustomisedSpellType::type)
|
.map(CustomisedSpellType::type)
|
||||||
.orElse(SpellType.empty());
|
.orElse(SpellType.empty());
|
||||||
|
|
|
@ -108,7 +108,7 @@ abstract class MixinLivingEntity extends Entity implements LivingEntityDuck, Equ
|
||||||
@Inject(method = "isPushable()Z", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "isPushable()Z", at = @At("HEAD"), cancellable = true)
|
||||||
private void onIsPushable(CallbackInfoReturnable<Boolean> info) {
|
private void onIsPushable(CallbackInfoReturnable<Boolean> info) {
|
||||||
Caster.of(this)
|
Caster.of(this)
|
||||||
.flatMap(c -> c.getSpellSlot().get(SpellPredicate.IS_DISGUISE, false))
|
.flatMap(c -> c.getSpellSlot().get(SpellPredicate.IS_DISGUISE))
|
||||||
.map(AbstractDisguiseSpell::getDisguise)
|
.map(AbstractDisguiseSpell::getDisguise)
|
||||||
.map(EntityAppearance::getAppearance)
|
.map(EntityAppearance::getAppearance)
|
||||||
.filter(Entity::isPushable)
|
.filter(Entity::isPushable)
|
||||||
|
|
|
@ -24,7 +24,7 @@ abstract class MixinClientPlayNetworkHandler {
|
||||||
Living<?> living = Living.living(packet.getEntity(world));
|
Living<?> living = Living.living(packet.getEntity(world));
|
||||||
if (living != null) {
|
if (living != null) {
|
||||||
living.getSpellSlot()
|
living.getSpellSlot()
|
||||||
.get(SpellPredicate.IS_DISGUISE, false)
|
.get(SpellPredicate.IS_DISGUISE)
|
||||||
.map(Disguise::getDisguise)
|
.map(Disguise::getDisguise)
|
||||||
.map(EntityAppearance::getAppearance)
|
.map(EntityAppearance::getAppearance)
|
||||||
.ifPresent(appearance -> {
|
.ifPresent(appearance -> {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public record MsgCasterLookRequest (UUID spellId) implements Packet<PlayerEntity
|
||||||
@Override
|
@Override
|
||||||
public void handle(ServerPlayerEntity sender) {
|
public void handle(ServerPlayerEntity sender) {
|
||||||
Pony.of(sender).getSpellSlot()
|
Pony.of(sender).getSpellSlot()
|
||||||
.get(SpellPredicate.IS_ORIENTED.withId(spellId), false)
|
.get(SpellPredicate.IS_ORIENTED.withId(spellId))
|
||||||
.ifPresent(spell -> {
|
.ifPresent(spell -> {
|
||||||
spell.setOrientation(rotation);
|
spell.setOrientation(rotation);
|
||||||
});
|
});
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", owner, t);
|
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", owner, t);
|
||||||
}
|
}
|
||||||
return Operation.REMOVE;
|
return Operation.REMOVE;
|
||||||
}, owner.isClient());
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", owner.asEntity(), e);
|
Unicopia.LOGGER.error("Error whilst ticking spell on entity {}", owner.asEntity(), e);
|
||||||
}
|
}
|
||||||
|
@ -80,12 +80,12 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(@Nullable SpellPredicate<?> type) {
|
public boolean contains(@Nullable SpellPredicate<?> type) {
|
||||||
return read(type, true, false).findFirst().isPresent();
|
return read(type).findFirst().isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Spell> Optional<T> get(@Nullable SpellPredicate<T> type, boolean update) {
|
public <T extends Spell> Optional<T> get(@Nullable SpellPredicate<T> type) {
|
||||||
return read(type, update, true).findFirst();
|
return read(type).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,8 +108,8 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeWhere(Predicate<Spell> test, boolean update) {
|
public boolean removeWhere(Predicate<Spell> test) {
|
||||||
return reduce(update, (initial, spell) -> {
|
return reduce((initial, spell) -> {
|
||||||
if (!test.test(spell)) {
|
if (!test.test(spell)) {
|
||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
|
@ -123,8 +123,8 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean forEach(Function<Spell, Operation> test, boolean update) {
|
public boolean forEach(Function<Spell, Operation> test) {
|
||||||
return reduce(update, (initial, effect) -> {
|
return reduce((initial, effect) -> {
|
||||||
Operation op = test.apply(effect);
|
Operation op = test.apply(effect);
|
||||||
if (op == Operation.REMOVE) {
|
if (op == Operation.REMOVE) {
|
||||||
spells.removeReference(effect);
|
spells.removeReference(effect);
|
||||||
|
@ -136,13 +136,13 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Stream<Spell> stream(boolean update) {
|
public Stream<Spell> stream() {
|
||||||
return stream(null, update);
|
return stream(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Spell> Stream<T> stream(@Nullable SpellPredicate<T> type, boolean update) {
|
public <T extends Spell> Stream<T> stream(@Nullable SpellPredicate<T> type) {
|
||||||
return read(type, update, true);
|
return read(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -158,10 +158,11 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T extends Spell> Stream<T> read(@Nullable SpellPredicate<T> type, boolean synchronize, boolean sendUpdate) {
|
private <T extends Spell> Stream<T> read(@Nullable SpellPredicate<T> type) {
|
||||||
if (synchronize && spells.fromNbt(owner.asEntity().getDataTracker().get(param)) && sendUpdate) {
|
if (owner.isClient()) {
|
||||||
write();
|
spells.fromNbt(owner.asEntity().getDataTracker().get(param));
|
||||||
}
|
}
|
||||||
|
write();
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return (Stream<T>)spells.getReferences();
|
return (Stream<T>)spells.getReferences();
|
||||||
|
@ -169,9 +170,9 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
return (Stream<T>)spells.getReferences().flatMap(s -> s.findMatches(type));
|
return (Stream<T>)spells.getReferences().flatMap(s -> s.findMatches(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean reduce(boolean update, Alteration alteration) {
|
private boolean reduce(Alteration alteration) {
|
||||||
boolean initial = false;
|
boolean initial = false;
|
||||||
for (Spell i : read(null, update, false).toList()) {
|
for (Spell i : read(null).toList()) {
|
||||||
initial = alteration.apply(initial, i);
|
initial = alteration.apply(initial, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write() {
|
private void write() {
|
||||||
if (spells.isDirty()) {
|
if (spells.isDirty() && !owner.isClient()) {
|
||||||
owner.asEntity().getDataTracker().set(param, spells.toNbt());
|
owner.asEntity().getDataTracker().set(param, spells.toNbt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Affinity getAffinity() {
|
public Affinity getAffinity() {
|
||||||
return getSpellSlot().get(true).map(Affine::getAffinity).orElse(Affinity.NEUTRAL);
|
return getSpellSlot().get().map(Affine::getAffinity).orElse(Affinity.NEUTRAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -163,7 +163,7 @@ public class MagicBeamEntity extends MagicProjectileEntity implements Caster<Mag
|
||||||
super.writeCustomDataToNbt(compound);
|
super.writeCustomDataToNbt(compound);
|
||||||
compound.putBoolean("hydrophobic", getHydrophobic());
|
compound.putBoolean("hydrophobic", getHydrophobic());
|
||||||
physics.toNBT(compound);
|
physics.toNBT(compound);
|
||||||
getSpellSlot().get(true).ifPresent(effect -> {
|
getSpellSlot().get().ifPresent(effect -> {
|
||||||
compound.put("effect", Spell.writeNbt(effect));
|
compound.put("effect", Spell.writeNbt(effect));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class Ether extends PersistentState {
|
||||||
spell = entity
|
spell = entity
|
||||||
.getOrEmpty(world)
|
.getOrEmpty(world)
|
||||||
.flatMap(Caster::of)
|
.flatMap(Caster::of)
|
||||||
.flatMap(caster -> caster.getSpellSlot().<T>get(s -> s.getUuid().equals(spellId), true))
|
.flatMap(caster -> caster.getSpellSlot().<T>get(s -> s.getUuid().equals(spellId)))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
if (spell != null) {
|
if (spell != null) {
|
||||||
|
|
Loading…
Reference in a new issue