mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
move seedhack into common
This commit is contained in:
1 parent
2a6d130d20
commit
2a24fa56d7
5 files changed
+6
-44
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package com.dfsek.terra.mod.util;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil.MultiNoiseSampler;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Holder for hacky biome source seed workaround
|
||||
*/
|
||||
public class SeedHack {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SeedHack.class);
|
||||
|
||||
private static final Object2LongMap<MultiNoiseSampler> seedMap = new Object2LongOpenHashMap<>();
|
||||
|
||||
public static long getSeed(MultiNoiseSampler sampler) {
|
||||
if(!seedMap.containsKey(sampler)) {
|
||||
throw new IllegalArgumentException("Sampler is not registered: " + sampler);
|
||||
}
|
||||
return seedMap.getLong(sampler);
|
||||
}
|
||||
|
||||
public static void register(MultiNoiseSampler sampler, long seed) {
|
||||
LOGGER.info("Registered seed {} to sampler {}", seed, sampler.hashCode());
|
||||
seedMap.put(sampler, seed);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user