mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed dismissing spells from the gui killing them without going through the normal removal process
This commit is contained in:
parent
4151b66e99
commit
0910ad72ca
5 changed files with 27 additions and 8 deletions
|
@ -39,6 +39,13 @@ public interface SpellContainer {
|
|||
*/
|
||||
void put(@Nullable Spell effect);
|
||||
|
||||
/**
|
||||
* Cleanly removes a spell from this spell container.
|
||||
*
|
||||
* @param spellid ID of the spell to remove.
|
||||
*/
|
||||
void remove(UUID spellid);
|
||||
|
||||
/**
|
||||
* Removes all active effects that match or contain a matching effect.
|
||||
*
|
||||
|
|
|
@ -76,14 +76,10 @@ class PortalFrameBuffer implements AutoCloseable {
|
|||
|
||||
private boolean pendingDraw;
|
||||
|
||||
private final UUID id;
|
||||
|
||||
@Nullable
|
||||
private Frustum frustum;
|
||||
|
||||
PortalFrameBuffer(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
PortalFrameBuffer(UUID id) { }
|
||||
|
||||
public void draw(MatrixStack matrices, VertexConsumerProvider vertices) {
|
||||
matrices.translate(0, -0.001, 0);
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.network.PacketByteBuf;
|
|||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
/**
|
||||
* Sent to the server when a player activates an ability.
|
||||
* Sent to the server when a player dismisses a spell from their dismiss spell screen
|
||||
*/
|
||||
public record MsgRemoveSpell (UUID id) implements HandledPacket<ServerPlayerEntity> {
|
||||
MsgRemoveSpell(PacketByteBuf buffer) {
|
||||
|
@ -30,7 +30,7 @@ public record MsgRemoveSpell (UUID id) implements HandledPacket<ServerPlayerEnti
|
|||
public void handle(ServerPlayerEntity sender) {
|
||||
Pony player = Pony.of(sender);
|
||||
if (player != null) {
|
||||
player.getSpellSlot().removeIf(spell -> spell.getUuid().equals(id), true);
|
||||
player.getSpellSlot().remove(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,16 @@ public class EffectSync implements SpellContainer, NbtSerialisable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(UUID id) {
|
||||
Spell spell = spells.getReference(id);
|
||||
spell.setDead();
|
||||
spell.tickDying(owner);
|
||||
if (spell.isDead()) {
|
||||
spells.removeReference(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeWhere(Predicate<Spell> test, boolean update) {
|
||||
return reduce(update, (initial, effect) -> {
|
||||
|
|
|
@ -83,7 +83,13 @@ public class NetworkedReferenceSet<T> {
|
|||
}
|
||||
}
|
||||
|
||||
private synchronized void removeReference(UUID id) {
|
||||
@Nullable
|
||||
synchronized T getReference(UUID id) {
|
||||
NetworkedReference<T> i = values.get(id);
|
||||
return i == null ? null : i.getReference().orElse(null);
|
||||
}
|
||||
|
||||
synchronized void removeReference(UUID id) {
|
||||
dirty |= ids.remove(id);
|
||||
NetworkedReference<T> i = values.remove(id);
|
||||
if (i != null) {
|
||||
|
|
Loading…
Reference in a new issue