From 6ed9becc30fcbf51d5f619fa37d25a49ed49f951 Mon Sep 17 00:00:00 2001 From: AViewFromTheTop <87103914+AViewFromTheTop@users.noreply.github.com> Date: Mon, 29 Jul 2024 22:53:51 -0400 Subject: [PATCH] fix wind seed --- .../net/frozenblock/lib/wind/api/WindManager.java | 11 ++++++++--- .../net/frozenblock/lib/wind/impl/WindStorage.java | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/frozenblock/lib/wind/api/WindManager.java b/src/main/java/net/frozenblock/lib/wind/api/WindManager.java index 96343c9b9..77d6bc373 100644 --- a/src/main/java/net/frozenblock/lib/wind/api/WindManager.java +++ b/src/main/java/net/frozenblock/lib/wind/api/WindManager.java @@ -62,15 +62,15 @@ public class WindManager { public double laggedWindX; public double laggedWindY; public double laggedWindZ; + public long seed; + private boolean seedSet = false; private final ServerLevel level; - private final long seed; - public final ImprovedNoise noise; + public ImprovedNoise noise; @SuppressWarnings("unchecked") public WindManager(@NotNull ServerLevel level) { this.level = level; - this.seed = level.getSeed(); this.noise = EasyNoiseSampler.createXoroNoise(this.seed); List extensions = new ObjectArrayList<>(); Map.Entry, Integer>[] extensionProviders = EXTENSION_PROVIDERS.entrySet().toArray(new Map.Entry[0]); @@ -144,6 +144,11 @@ public SavedData.Factory createData() { } public void tick(@NotNull ServerLevel level) { + if (!this.seedSet) { + this.seedSet = true; + this.seed = level.getSeed(); + this.noise = EasyNoiseSampler.createXoroNoise(this.seed); + } if (level.tickRateManager().runsNormally()) { this.runResetsIfNeeded(); diff --git a/src/main/java/net/frozenblock/lib/wind/impl/WindStorage.java b/src/main/java/net/frozenblock/lib/wind/impl/WindStorage.java index dfdab1ac3..4fed7596a 100644 --- a/src/main/java/net/frozenblock/lib/wind/impl/WindStorage.java +++ b/src/main/java/net/frozenblock/lib/wind/impl/WindStorage.java @@ -49,6 +49,7 @@ public WindStorage(WindManager windManager) { compoundTag.putDouble("laggedWindX", this.windManager.laggedWindX); compoundTag.putDouble("laggedWindY", this.windManager.laggedWindY); compoundTag.putDouble("laggedWindZ", this.windManager.laggedWindZ); + compoundTag.putLong("seed", this.windManager.seed); // EXTENSIONS for (WindManagerExtension extension : this.windManager.attachedExtensions) { @@ -74,6 +75,7 @@ public WindStorage(WindManager windManager) { windStorage.windManager.laggedWindX = compoundTag.getDouble("laggedWindX"); windStorage.windManager.laggedWindY = compoundTag.getDouble("laggedWindY"); windStorage.windManager.laggedWindZ = compoundTag.getDouble("laggedWindZ"); + windStorage.windManager.seed = compoundTag.getLong("seed"); // EXTENSIONS for (WindManagerExtension extension : windStorage.windManager.attachedExtensions) {