Skip to content

Commit

Permalink
fix wind seed
Browse files Browse the repository at this point in the history
  • Loading branch information
AViewFromTheTop committed Jul 30, 2024
1 parent df5573f commit 6ed9bec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/java/net/frozenblock/lib/wind/api/WindManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<WindManagerExtension> extensions = new ObjectArrayList<>();
Map.Entry<Function<WindManager, WindManagerExtension>, Integer>[] extensionProviders = EXTENSION_PROVIDERS.entrySet().toArray(new Map.Entry[0]);
Expand Down Expand Up @@ -144,6 +144,11 @@ public SavedData.Factory<WindStorage> 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();

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/frozenblock/lib/wind/impl/WindStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 6ed9bec

Please sign in to comment.