mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 13:37:58 +01:00
Revert "Change ether to use type keys"
This reverts commit 2ca337a8b813e2bf4fe3bd4949338aa476c568e4.
This commit is contained in:
parent
d38a02dcd4
commit
9f407dfb76
1 changed files with 5 additions and 5 deletions
|
@ -25,7 +25,7 @@ public class Ether extends PersistentState {
|
|||
return WorldOverlay.getPersistableStorage(world, ID, Ether::new, Ether::new);
|
||||
}
|
||||
|
||||
private final Map<SpellType<?>, Map<UUID, Map<UUID, Entry<?>>>> endpoints;
|
||||
private final Map<Identifier, Map<UUID, Map<UUID, Entry<?>>>> endpoints;
|
||||
|
||||
private final Object locker = new Object();
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class Ether extends PersistentState {
|
|||
|
||||
Ether(World world, NbtCompound compound) {
|
||||
this.world = world;
|
||||
this.endpoints = NbtSerialisable.readMap(compound.getCompound("endpoints"), id -> SpellType.getKey(Identifier.tryParse(id)), typeNbt -> {
|
||||
this.endpoints = NbtSerialisable.readMap(compound.getCompound("endpoints"), Identifier::tryParse, typeNbt -> {
|
||||
return NbtSerialisable.readMap((NbtCompound)typeNbt, UUID::fromString, entityNbt -> {
|
||||
return NbtSerialisable.readMap((NbtCompound)entityNbt, UUID::fromString, Entry::new);
|
||||
});
|
||||
|
@ -49,7 +49,7 @@ public class Ether extends PersistentState {
|
|||
public NbtCompound writeNbt(NbtCompound compound) {
|
||||
synchronized (locker) {
|
||||
pruneNodes();
|
||||
compound.put("endpoints", NbtSerialisable.writeMap(endpoints, type -> type.getId().toString(), entities -> {
|
||||
compound.put("endpoints", NbtSerialisable.writeMap(endpoints, Identifier::toString, entities -> {
|
||||
return NbtSerialisable.writeMap(entities, UUID::toString, spells -> {
|
||||
return NbtSerialisable.writeMap(spells, UUID::toString, Entry::toNBT);
|
||||
});
|
||||
|
@ -62,7 +62,7 @@ public class Ether extends PersistentState {
|
|||
public <T extends Spell> Entry<T> getOrCreate(T spell, Caster<?> caster) {
|
||||
synchronized (locker) {
|
||||
Entry<T> entry = (Entry<T>)endpoints
|
||||
.computeIfAbsent(spell.getTypeAndTraits().type(), typeId -> new HashMap<>())
|
||||
.computeIfAbsent(spell.getTypeAndTraits().type().getId(), typeId -> new HashMap<>())
|
||||
.computeIfAbsent(caster.asEntity().getUuid(), entityId -> new HashMap<>())
|
||||
.computeIfAbsent(spell.getUuid(), spellid -> {
|
||||
markDirty();
|
||||
|
@ -82,7 +82,7 @@ public class Ether extends PersistentState {
|
|||
|
||||
public <T extends Spell> void remove(SpellType<T> spellType, UUID entityId) {
|
||||
synchronized (locker) {
|
||||
endpoints.computeIfPresent(spellType, (typeId, entries) -> {
|
||||
endpoints.computeIfPresent(spellType.getId(), (typeId, entries) -> {
|
||||
if (entries.remove(entityId) != null) {
|
||||
markDirty();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue