Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster random generator Issue #183

Open
Potothingi opened this issue Dec 14, 2024 · 9 comments
Open

Faster random generator Issue #183

Potothingi opened this issue Dec 14, 2024 · 9 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@Potothingi
Copy link

What feature do you want to see added?

If all chunks within the world border were generated before using the faster-random-generator, the structure will not be found. For example, if I use eyes of ender, the eyes of ender don't work.

I need a configuration that allows me to use legacy random for seeds, like the use-legacy-random-for-slime-chunk option.

@Potothingi Potothingi added the enhancement New feature or request label Dec 14, 2024
@Potothingi
Copy link
Author

Current Options:

  faster-random-generator:
    enabled: true
    # Which random generator will be used?
    # See https://openjdk.org/jeps/356
    random-generator: Xoroshiro128PlusPlus
    # Enable faster random generator for world generation.
    # WARNING: This will affect world generation!!!
    enable-for-worldgen: false
    # Warn if you are not using legacy random source for slime chunk generation.
    warn-for-slime-chunk: true
    # Use legacy random source for slime chunk generation,
    # to follow vanilla behavior.
    use-legacy-random-for-slime-chunk: true

@Potothingi
Copy link
Author

@Dreeam-qwq

@HaHaWTH
Copy link
Member

HaHaWTH commented Dec 14, 2024

Cannot reproduce, and you should use bug report template to report bugs.

@HaHaWTH HaHaWTH added bug Something isn't working invalid This doesn't seem right and removed enhancement New feature or request labels Dec 14, 2024
@Potothingi
Copy link
Author

@HaHaWTH Thanks for the reply. But I can reproduce it. enable-for-worldgen: false affects world generation and structure finding. I don't know how to prove this to you.

I looked at the code and this looks suspicious.

+ super(org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));

super(org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));

super(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));

Shouldn't it be changed like this? Please check. Thank you.

@HaHaWTH
Copy link
Member

HaHaWTH commented Dec 14, 2024

@HaHaWTH Thanks for the reply. But I can reproduce it. enable-for-worldgen: false affects world generation and structure finding. I don't know how to prove this to you.

I looked at the code and this looks suspicious.

+ super(org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));

super(org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));

super(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L));
Shouldn't it be changed like this? Please check. Thank you.

This only works when secure-seed enabled, did you enable secure seed?

@Potothingi
Copy link
Author

I didn't enable it. :o

  # Once you enable secure seed, all ores and structures are generated with 1024-bit seed
  # instead of using 64-bit seed in vanilla, made seed cracker become impossible.
  secure-seed:
    enabled: false

@Potothingi
Copy link
Author

Potothingi commented Dec 14, 2024

Doesn't this affect seed?
This appears to only change Slime Seed to the Legacy RNG Seed. Other seeds will likely use the Fast RNG Seed.

static RandomSource create(long seed) {
- return new LegacyRandomSource(seed);
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
+ : new LegacyRandomSource(seed);
+ }
+
+ static RandomSource createForSlimeChunk(long seed) {
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled && !org.dreeam.leaf.config.modules.opt.FastRNG.useLegacyForSlimeChunk
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
+ : new LegacyRandomSource(seed);
}

public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long worldSeed, long scrambler) {
- return RandomSource.create(
+ return RandomSource.createForSlimeChunk(
worldSeed + (long)(chunkX * chunkX * 4987142) + (long)(chunkX * 5947611) + (long)(chunkZ * chunkZ) * 4392871L + (long)(chunkZ * 389711) ^ scrambler
- );
+ ); // Leaf - Faster RNG
}

@Potothingi
Copy link
Author

@HaHaWTH It seems to me that not only Slime Seeds but also Structure Seeds are affected by Fast RNG.

This issue is not invalid because it was created for a feature request to use legacy RNG for seeds that affect the game, not just slime seeds.

@HaHaWTH
Copy link
Member

HaHaWTH commented Dec 14, 2024

@HaHaWTH It seems to me that not only Slime Seeds but also Structure Seeds are affected by Fast RNG.

This issue is not invalid because it was created for a feature request to use legacy RNG for seeds that affect the game, not just slime seeds.

Structure generation uses WorldgenRandom, which is backed by LegacyRandomSource. Code above is unlikely to cause this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants