Skip to content

Commit

Permalink
Replaces testing Spawner Transformation script with completed script.…
Browse files Browse the repository at this point in the history
… Stops desync in certain situations with spawners
  • Loading branch information
Darkosto committed Dec 27, 2024
1 parent 7914b70 commit 277395f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/minecraft/scripts/spawner_transformation.zs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import crafttweaker.forge.api.event.interact.RightClickBlockEvent;
import crafttweaker.api.block.entity.BlockEntity;
import crafttweaker.api.data.IData;

events.register<RightClickBlockEvent>((event) => {
val level = event.entity.level;
Expand All @@ -17,13 +18,15 @@ events.register<RightClickBlockEvent>((event) => {
val toSpawn = heldItem.tag["BlockEntityTag"]["entity"];

val data = blockEntity.data;
if !("SpawnData" in data) {
data["SpawnData"] = {};
}
if !("entity" in data["SpawnData"]) {
data["SpawnData"]["entity"] = {};
}
data["SpawnData"]["entity"]["id"] = toSpawn;

val spawnData = {
entity: {
id: toSpawn
}
} as IData;
data["SpawnData"] = spawnData;
data["SpawnPotentials"] = [];
data["SpawnPotentials"].add({data: spawnData});
blockEntity.updateData(data);

event.cancel();
Expand Down

0 comments on commit 277395f

Please sign in to comment.