mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
132 lines
7.1 KiB
Diff
132 lines
7.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Wed, 15 Jul 2020 11:49:36 -0500
|
|
Subject: [PATCH] Configurable feature seed settings
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
index 74a0adf4adf2b701126724e08bb72fa4e8e8560a..464a416069a87c390df3a0842fb34bc1049e9c6f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
|
@@ -26,6 +26,7 @@ import net.minecraft.world.level.material.FluidState;
|
|
|
|
public class GeodeFeature extends Feature<GeodeConfiguration> {
|
|
private static final Direction[] DIRECTIONS = Direction.values();
|
|
+ private Random rnd; // Purpur
|
|
|
|
public GeodeFeature(Codec<GeodeConfiguration> configCodec) {
|
|
super(configCodec);
|
|
@@ -33,8 +34,14 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
|
|
|
@Override
|
|
public boolean place(FeaturePlaceContext<GeodeConfiguration> context) {
|
|
+ // Purpur start
|
|
+ if (this.rnd == null) {
|
|
+ int seed = net.pl3x.purpur.PurpurConfig.geodeSeed;
|
|
+ this.rnd = seed == -1 ? context.random() : new Random(seed);
|
|
+ }
|
|
+ // Purpur end
|
|
GeodeConfiguration geodeConfiguration = context.config();
|
|
- Random random = context.random();
|
|
+ Random random = this.rnd; // Purpur
|
|
BlockPos blockPos = context.origin();
|
|
WorldGenLevel worldGenLevel = context.level();
|
|
int i = geodeConfiguration.minGenOffset;
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java
|
|
index d36b6208077254af5f0ebed8e8ce20fd45cbb79d..612bc6e4a759df96bade4c322aad0b3e8753e0ee 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/MonsterRoomFeature.java
|
|
@@ -25,6 +25,7 @@ public class MonsterRoomFeature extends Feature<NoneFeatureConfiguration> {
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
private static final EntityType<?>[] MOBS = new EntityType[]{EntityType.SKELETON, EntityType.ZOMBIE, EntityType.ZOMBIE, EntityType.SPIDER};
|
|
private static final BlockState AIR = Blocks.CAVE_AIR.defaultBlockState();
|
|
+ private Random rnd; // Purpur
|
|
|
|
public MonsterRoomFeature(Codec<NoneFeatureConfiguration> configCodec) {
|
|
super(configCodec);
|
|
@@ -32,9 +33,15 @@ public class MonsterRoomFeature extends Feature<NoneFeatureConfiguration> {
|
|
|
|
@Override
|
|
public boolean place(FeaturePlaceContext<NoneFeatureConfiguration> context) {
|
|
+ // Purpur start
|
|
+ if (this.rnd == null) {
|
|
+ int seed = net.pl3x.purpur.PurpurConfig.dungeonSeed;
|
|
+ this.rnd = seed == -1 ? context.random() : new Random(seed);
|
|
+ }
|
|
+ // Purpur end
|
|
Predicate<BlockState> predicate = Feature.isReplaceable(BlockTags.FEATURES_CANNOT_REPLACE.getName());
|
|
BlockPos blockPos = context.origin();
|
|
- Random random = context.random();
|
|
+ Random random = this.rnd; // Purpur
|
|
WorldGenLevel worldGenLevel = context.level();
|
|
int i = 3;
|
|
int j = random.nextInt(2) + 2;
|
|
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
|
|
index c03bf5bdb67b00c75f9fcfead882c4d944282244..1f71cd40b9fe5aeb118b698c9932c8a43d5ca4a5 100644
|
|
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
|
|
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
|
|
@@ -30,22 +30,30 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
|
|
public static final int NUMBER_OF_SPIKES = 10;
|
|
private static final int SPIKE_DISTANCE = 42;
|
|
private static final LoadingCache<Long, List<SpikeFeature.EndSpike>> SPIKE_CACHE = CacheBuilder.newBuilder().expireAfterWrite(5L, TimeUnit.MINUTES).build(new SpikeFeature.SpikeCacheLoader());
|
|
+ private Random rnd; // Purpur
|
|
|
|
public SpikeFeature(Codec<SpikeConfiguration> configCodec) {
|
|
super(configCodec);
|
|
}
|
|
|
|
public static List<SpikeFeature.EndSpike> getSpikesForLevel(WorldGenLevel world) {
|
|
- Random random = new Random(world.getSeed());
|
|
+ int seed = net.pl3x.purpur.PurpurConfig.endSpikeSeed; // Purpur
|
|
+ Random random = new Random(seed == -1 ? world.getSeed() : seed); // Purpur
|
|
long l = random.nextLong() & 65535L;
|
|
return SPIKE_CACHE.getUnchecked(l);
|
|
}
|
|
|
|
@Override
|
|
public boolean place(FeaturePlaceContext<SpikeConfiguration> context) {
|
|
+ // Purpur start
|
|
+ if (this.rnd == null) {
|
|
+ int seed = net.pl3x.purpur.PurpurConfig.endSpikeSeed;
|
|
+ this.rnd = seed == -1 ? context.random() : new Random(seed);
|
|
+ }
|
|
+ // Purpur end
|
|
SpikeConfiguration spikeConfiguration = context.config();
|
|
WorldGenLevel worldGenLevel = context.level();
|
|
- Random random = context.random();
|
|
+ Random random = this.rnd; // Purpur
|
|
BlockPos blockPos = context.origin();
|
|
List<SpikeFeature.EndSpike> list = spikeConfiguration.getSpikes();
|
|
if (list.isEmpty()) {
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index fa1af3c9da4fee4c529113b30f652c3243e73635..4102856324b9f5bd683175c0662309366fe9e3c8 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -1,5 +1,6 @@
|
|
package net.pl3x.purpur;
|
|
|
|
+import co.aikar.timings.TimingsManager;
|
|
import com.google.common.base.Throwables;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.pl3x.purpur.command.PurpurCommand;
|
|
@@ -147,6 +148,19 @@ public class PurpurConfig {
|
|
pingCommandOutput = getString("settings.messages.ping-command-output", pingCommandOutput);
|
|
}
|
|
|
|
+ public static int dungeonSeed = -1;
|
|
+ public static int endSpikeSeed = -1;
|
|
+ public static int geodeSeed = -1;
|
|
+ private static void seedSettings() {
|
|
+ dungeonSeed = getInt("settings.seed.dungeon", dungeonSeed);
|
|
+ endSpikeSeed = getInt("settings.seed.end-spike", endSpikeSeed);
|
|
+ geodeSeed = getInt("settings.seed.geode", geodeSeed);
|
|
+ if (!TimingsManager.hiddenConfigs.contains("settings.seed")) TimingsManager.hiddenConfigs.add("settings.seed");
|
|
+ if (!TimingsManager.hiddenConfigs.contains("settings.seed.dungeon")) TimingsManager.hiddenConfigs.add("settings.seed.dungeon");
|
|
+ if (!TimingsManager.hiddenConfigs.contains("settings.seed.end-spike")) TimingsManager.hiddenConfigs.add("settings.seed.end-spike");
|
|
+ if (!TimingsManager.hiddenConfigs.contains("settings.seed.geode")) TimingsManager.hiddenConfigs.add("settings.seed.geode");
|
|
+ }
|
|
+
|
|
public static String serverModName = "Purpur";
|
|
private static void serverModName() {
|
|
serverModName = getString("settings.server-mod-name", serverModName);
|