From 7250fe5b265120d5e1123f1fad5f4bd303343c5b Mon Sep 17 00:00:00 2001 From: Mgazul Date: Fri, 2 Feb 2024 00:15:00 +0700 Subject: [PATCH] Fix world create --- .../net/minecraft/world/World.java.patch | 17 ++++++----------- .../world/server/ServerWorld.java.patch | 16 +++++++++------- .../com/mohistmc/forge/ForgeInjectBukkit.java | 11 +++++------ 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/patches/minecraft/net/minecraft/world/World.java.patch b/patches/minecraft/net/minecraft/world/World.java.patch index 422aa3d889..afe5357997 100644 --- a/patches/minecraft/net/minecraft/world/World.java.patch +++ b/patches/minecraft/net/minecraft/world/World.java.patch @@ -71,7 +71,7 @@ public final Thread field_217407_c; private final boolean field_234916_c_; private int field_73008_k; -@@ -92,8 +_,69 @@ +@@ -92,8 +_,61 @@ private final WorldBorder field_175728_M; private final BiomeManager field_226689_w_; private final RegistryKey field_73011_w; @@ -99,7 +99,6 @@ + public boolean populating; + public org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot + public static BlockPos lastPhysicsProblem; // Spigot -+ private int tileTickPosition; + public final Map explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions + public boolean pehkuiExplosionFire = false; // Mohist - Fix Pehkui Startup (#1324) + @@ -130,18 +129,11 @@ + this.ticksPerWaterAmbientSpawns = this.getCBServer().getTicksPerWaterAmbientSpawns(); + this.ticksPerAmbientSpawns = this.getCBServer().getTicksPerAmbientSpawns(); + // CraftBukkit end -+ if (generator == null && p_i241925_1_ != null) { // Mohist - Fix Advanced Rocketry assembler crash -+ generator = getCBServer().getGenerator(((IServerWorldInfo) p_i241925_1_).func_76065_j()); -+ } -+ -+ if (environment == null) { -+ environment = ForgeInjectBukkit.environment.getOrDefault(p_i241925_3_, org.bukkit.World.Environment.CUSTOM); -+ } + this.field_72984_F = p_i241925_4_; this.field_72986_A = p_i241925_1_; this.field_234921_x_ = p_i241925_3_; -@@ -102,17 +_,18 @@ +@@ -102,17 +_,20 @@ if (p_i241925_3_.func_242724_f() != 1.0D) { this.field_175728_M = new WorldBorder() { public double func_230316_a_() { @@ -157,7 +149,10 @@ } else { this.field_175728_M = new WorldBorder(); } - +- ++ if (environment == null) { ++ environment = ForgeInjectBukkit.environment.getOrDefault(typeKey, org.bukkit.World.Environment.CUSTOM); ++ } + func_175723_af().world = this; // Mohist move form ServerWorld this.field_217407_c = Thread.currentThread(); this.field_226689_w_ = new BiomeManager(this, p_i241925_7_, p_i241925_3_.func_227176_e_()); diff --git a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch index cdacc1672b..1bc6e7b2e3 100644 --- a/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch +++ b/patches/minecraft/net/minecraft/world/server/ServerWorld.java.patch @@ -130,7 +130,7 @@ private final Set field_217495_I = Sets.newHashSet(); protected final RaidManager field_217494_c; private final ObjectLinkedOpenHashSet field_147490_S = new ObjectLinkedOpenHashSet<>(); -@@ -173,9 +_,60 @@ +@@ -173,9 +_,61 @@ private final DragonFightManager field_241105_O_; private final StructureManager field_241106_P_; private final boolean field_241107_Q_; @@ -138,7 +138,6 @@ + private final it.unimi.dsi.fastutil.ints.Int2ObjectMap> partEntities = new it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap<>(); + + // CraftBukkit start -+ private int tickPosition; + public ServerWorldInfo worldDataServer; + public final SaveFormat.LevelSave convertable; + public final UUID uuid; @@ -147,10 +146,9 @@ + public boolean dummyFreshEntitySpawn = false; // Mohist - Fix Pehkui Startup (#1324) + + // Mohist start - Add option to ignore empty time -+ private static List IGNORE_EMPTY_TIME_LIST; ++ private static List IGNORE_EMPTY_TIME_LIST = new ArrayList<>(); + + { -+ IGNORE_EMPTY_TIME_LIST = new ArrayList<>(); + String ignoreEmptyTime = MohistConfigUtil.sMohist("ignore_empty_time", "all_worlds"); + if (ignoreEmptyTime.contains(";")) { + for (String part : ignoreEmptyTime.split(";")) { @@ -176,22 +174,25 @@ + File worldFile = DimensionType.func_236031_a_(p_i241885_5_, p_i241885_3_.field_237279_c_.toFile()); + uuid = Level2LevelStem.bukkit != null ? WorldUUID.getUUID(Level2LevelStem.bukkit) : WorldUUID.getUUID(worldFile); + name = Level2LevelStem.bukkit != null ? Level2LevelStem.bukkit_name : worldFile.getName(); -+ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(name); // Spigot ++ + if (p_i241885_4_ instanceof ServerWorldInfo) { + this.worldDataServer = (ServerWorldInfo) p_i241885_4_; + } else if (p_i241885_4_ instanceof DerivedWorldInfo) { + this.worldDataServer = MohistDerivedWorldInfo.create((DerivedWorldInfo)p_i241885_4_); + } -+ this.craftWorld = new CraftWorld(this, generator, environment); ++ + if (generator != null) { + p_i241885_8_ = new org.bukkit.craftbukkit.v1_16_R3.generator.CustomChunkGenerator(this, p_i241885_8_, generator); ++ } else { ++ generator = getCBServer().getGenerator(p_i241885_4_.func_76065_j()); + } + worldDataServer.world = this; ++ this.spigotConfig = new org.spigotmc.SpigotWorldConfig(name); // Spigot + // CraftBukkit end this.field_241107_Q_ = p_i241885_13_; this.field_73061_a = p_i241885_1_; this.field_241104_N_ = p_i241885_12_; -@@ -194,14 +_,43 @@ +@@ -194,14 +_,44 @@ p_i241885_4_.func_230392_a_(p_i241885_1_.func_71265_f()); } @@ -205,6 +206,7 @@ } - - } ++ this.craftWorld = new CraftWorld(this, generator, environment); + this.getCBServer().addWorld(this.getWorld()); // CraftBukkit + this.initCapabilities(); + } diff --git a/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java b/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java index f65303d90a..8897f4b9ab 100644 --- a/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java +++ b/src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java @@ -72,11 +72,11 @@ public class ForgeInjectBukkit { - public static BiMap environment = - HashBiMap.create(ImmutableMap.builder() - .put(DimensionType.DEFAULT_OVERWORLD, World.Environment.NORMAL) - .put(DimensionType.DEFAULT_NETHER, World.Environment.NETHER) - .put(DimensionType.DEFAULT_END, World.Environment.THE_END) + public static BiMap, World.Environment> environment = + HashBiMap.create(ImmutableMap., World.Environment>builder() + .put(DimensionType.OVERWORLD_LOCATION, World.Environment.NORMAL) + .put(DimensionType.NETHER_LOCATION, World.Environment.NETHER) + .put(DimensionType.END_LOCATION, World.Environment.THE_END) .build()); public static BiMap> environment0 = @@ -222,7 +222,6 @@ public static void addEnumEnvironment(Registry registry) { String name = normalizeName(key.location().toString()); int id = i - 1; environment1 = MohistEnumHelper.addEnum(World.Environment.class, name, new Class[]{Integer.TYPE}, new Object[]{id}); - environment.put(dimensionType, environment1); environment0.put(environment1, key); MohistMC.LOGGER.debug("Registered forge DimensionType as environment {}", environment1); i++;