mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-29 22:23:50 +01:00
c09ee99f7e
Closes #257 Ports 2 patches from Purpur: Infinity-bow-settings & Allow-infinite-and-mending-enchantments-together Added an option for infinity with no arrows too. Option for custom locale has come! You can put a locale.json file in your server folder to change it. We've got the finest patches from Hydrinity ( Mykyta approved & allowed ) too. We have some amazing new options in yatopia.yml, we're gonna have documentation for them soon so stay tuned! Last but not least, chunk generation patches. We've tested them extensively so no weirdness happens. Thanks for using Yatopia as your production server software. Co-authored-by: Ivan Pekov <ivan@mrivanplays.com>
62 lines
4.0 KiB
Diff
62 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: dfsek <dfsek@protonmail.com>
|
|
Date: Wed, 16 Sep 2020 01:12:29 -0700
|
|
Subject: [PATCH] Add StructureLocateEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ChunkGenerator.java b/src/main/java/net/minecraft/server/ChunkGenerator.java
|
|
index 9a6fef215052f9c513b23024968995c97863a453..16a477f2a99a5c8d68f0d1468d4cd79650a5a05d 100644
|
|
--- a/src/main/java/net/minecraft/server/ChunkGenerator.java
|
|
+++ b/src/main/java/net/minecraft/server/ChunkGenerator.java
|
|
@@ -124,9 +124,27 @@ public abstract class ChunkGenerator {
|
|
|
|
@Nullable
|
|
public BlockPosition findNearestMapFeature(WorldServer worldserver, StructureGenerator<?> structuregenerator, BlockPosition blockposition, int i, boolean flag) {
|
|
- if (!this.b.a(structuregenerator)) {
|
|
+ // Paper start
|
|
+ org.bukkit.World world = worldserver.getWorld();
|
|
+ org.bukkit.Location originLocation = new org.bukkit.Location(world, blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
|
+ org.bukkit.event.world.StructureLocateEvent event = new org.bukkit.event.world.StructureLocateEvent(world, originLocation, org.bukkit.StructureType.getStructureTypes().get(structuregenerator.i()), i, flag);
|
|
+ if(!event.callEvent()) return null;
|
|
+ // If event call set a final location, skip structure finding and just return set result.
|
|
+ org.bukkit.Location finalLocation = event.getResult();
|
|
+ if(finalLocation != null) {
|
|
+ return new BlockPosition(finalLocation.getBlockX(), finalLocation.getBlockY(), finalLocation.getBlockZ());
|
|
+ }
|
|
+ // Get origin location (re)defined by event call.
|
|
+ org.bukkit.Location newOriginLocation = event.getOrigin();
|
|
+ BlockPosition newOriginPosition = new BlockPosition(newOriginLocation.getBlockX(), newOriginLocation.getBlockY(), newOriginLocation.getBlockZ());
|
|
+ // Get radius and whether to find unexplored structures (re)defined by event call.
|
|
+ int radius = event.getRadius();
|
|
+ boolean findUnexplored = event.shouldFindUnexplored();
|
|
+ StructureGenerator<?> newGenerator = StructureGenerator.a.get(event.getType().getName());
|
|
+ // Paper end
|
|
+ if(! this.b.a(newGenerator)) { // Paper
|
|
return null;
|
|
- } else if (structuregenerator == StructureGenerator.STRONGHOLD) {
|
|
+ } else if (newGenerator == StructureGenerator.STRONGHOLD) { // Paper
|
|
this.g();
|
|
BlockPosition blockposition1 = null;
|
|
double d0 = Double.MAX_VALUE;
|
|
@@ -137,7 +155,7 @@ public abstract class ChunkGenerator {
|
|
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair) iterator.next();
|
|
|
|
blockposition_mutableblockposition.d((chunkcoordintpair.x << 4) + 8, 32, (chunkcoordintpair.z << 4) + 8);
|
|
- double d1 = blockposition_mutableblockposition.j(blockposition);
|
|
+ double d1 = blockposition_mutableblockposition.j(newOriginPosition); // Paper
|
|
|
|
if (blockposition1 == null) {
|
|
blockposition1 = new BlockPosition(blockposition_mutableblockposition);
|
|
@@ -151,9 +169,9 @@ public abstract class ChunkGenerator {
|
|
return blockposition1;
|
|
} else {
|
|
updateStructureSettings(worldserver, structureSettings); // Spigot
|
|
- StructureSettingsFeature structuresettingsfeature = this.structureSettings.a(structuregenerator);
|
|
+ StructureSettingsFeature structuresettingsfeature = this.structureSettings.a(newGenerator); // Paper
|
|
|
|
- return structuresettingsfeature == null ? null : structuregenerator.getNearestGeneratedFeature(worldserver, worldserver.getStructureManager(), blockposition, i, flag, worldserver.getSeed(), structuresettingsfeature);
|
|
+ return structuresettingsfeature == null ? null : newGenerator.getNearestGeneratedFeature(worldserver, worldserver.getStructureManager(), newOriginPosition, radius, findUnexplored, worldserver.getSeed(), structuresettingsfeature); // Paper
|
|
}
|
|
}
|
|
|