Fixed placed spells breaking when reloading a world

This commit is contained in:
Sollace 2024-01-20 15:42:26 +00:00
parent ab3ac8cb0d
commit 69985e50f9
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 17 additions and 13 deletions

View file

@ -219,6 +219,9 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
position.ifPresent(pos -> { position.ifPresent(pos -> {
compound.put("position", NbtSerialisable.writeVector(pos)); compound.put("position", NbtSerialisable.writeVector(pos));
}); });
if (placedSpellId != null) {
compound.putUuid("placedSpellId", placedSpellId);
}
if (dimension != null) { if (dimension != null) {
compound.putString("dimension", dimension.getValue().toString()); compound.putString("dimension", dimension.getValue().toString());
} }
@ -232,6 +235,7 @@ public class PlaceableSpell extends AbstractDelegatingSpell implements OrientedS
pitch = compound.getFloat("pitch"); pitch = compound.getFloat("pitch");
yaw = compound.getFloat("yaw"); yaw = compound.getFloat("yaw");
position = compound.contains("position") ? Optional.of(NbtSerialisable.readVector(compound.getList("position", NbtElement.FLOAT_TYPE))) : Optional.empty(); position = compound.contains("position") ? Optional.of(NbtSerialisable.readVector(compound.getList("position", NbtElement.FLOAT_TYPE))) : Optional.empty();
placedSpellId = compound.containsUuid("placedSpellId") ? compound.getUuid("placedSpellId") : null;
if (compound.contains("dimension", NbtElement.STRING_TYPE)) { if (compound.contains("dimension", NbtElement.STRING_TYPE)) {
Identifier id = Identifier.tryParse(compound.getString("dimension")); Identifier id = Identifier.tryParse(compound.getString("dimension"));
if (id != null) { if (id != null) {

View file

@ -2,13 +2,13 @@
"parent": "unicopia:unicopia/earth/born_on_a_rock_farm", "parent": "unicopia:unicopia/earth/born_on_a_rock_farm",
"display": { "display": {
"icon": { "icon": {
"item": "unicopia:rock" "item": "unicopia:iron_horseshoe"
}, },
"title": { "title": {
"translate": "advancements.unicopia.sticks_and_stones.title" "translate": "advancements.unicopia.dead_ringer.title"
}, },
"description": { "description": {
"translate": "advancements.unicopia.sticks_and_stones.description" "translate": "advancements.unicopia.dead_ringer.description"
}, },
"frame": "task", "frame": "task",
"show_toast": true, "show_toast": true,
@ -16,13 +16,13 @@
"hidden": true "hidden": true
}, },
"criteria": { "criteria": {
"killed_entity_with_rock": { "killed_entity_with_horseshoe": {
"trigger": "minecraft:player_killed_entity", "trigger": "minecraft:player_killed_entity",
"conditions": { "conditions": {
"killing_blow": { "killing_blow": {
"tags": [ "tags": [
{ {
"id": "unicopia:from_rocks", "id": "unicopia:from_horseshoes",
"expected": true "expected": true
} }
] ]
@ -31,6 +31,6 @@
} }
}, },
"requirements": [ "requirements": [
[ "killed_entity_with_rock" ] [ "killed_entity_with_horseshoe" ]
] ]
} }

View file

@ -2,13 +2,13 @@
"parent": "unicopia:unicopia/earth/born_on_a_rock_farm", "parent": "unicopia:unicopia/earth/born_on_a_rock_farm",
"display": { "display": {
"icon": { "icon": {
"item": "unicopia:horseshoe" "item": "unicopia:rock"
}, },
"title": { "title": {
"translate": "advancements.unicopia.dead_ringer.title" "translate": "advancements.unicopia.sticks_and_stones.title"
}, },
"description": { "description": {
"translate": "advancements.unicopia.dead_ringer.description" "translate": "advancements.unicopia.sticks_and_stones.description"
}, },
"frame": "task", "frame": "task",
"show_toast": true, "show_toast": true,
@ -16,13 +16,13 @@
"hidden": true "hidden": true
}, },
"criteria": { "criteria": {
"killed_entity_with_horseshoe": { "killed_entity_with_rock": {
"trigger": "minecraft:player_killed_entity", "trigger": "minecraft:player_killed_entity",
"conditions": { "conditions": {
"killing_blow": { "killing_blow": {
"tags": [ "tags": [
{ {
"id": "unicopia:from_horseshoes", "id": "unicopia:from_rocks",
"expected": true "expected": true
} }
] ]
@ -31,6 +31,6 @@
} }
}, },
"requirements": [ "requirements": [
[ "killed_entity_with_horseshoe" ] [ "killed_entity_with_rock" ]
] ]
} }