Skip to content

Commit

Permalink
Fix world create
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Feb 1, 2024
1 parent f8490b3 commit 7250fe5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
17 changes: 6 additions & 11 deletions patches/minecraft/net/minecraft/world/World.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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<World> field_73011_w;
Expand Down Expand Up @@ -99,7 +99,6 @@
+ public boolean populating;
+ public org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot
+ public static BlockPos lastPhysicsProblem; // Spigot
+ private int tileTickPosition;
+ public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
+ public boolean pehkuiExplosionFire = false; // Mohist - Fix Pehkui Startup (#1324)
+
Expand Down Expand Up @@ -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_() {
Expand All @@ -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_());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,14 @@
private final Set<PathNavigator> field_217495_I = Sets.newHashSet();
protected final RaidManager field_217494_c;
private final ObjectLinkedOpenHashSet<BlockEventData> 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_;
+ private net.minecraftforge.common.util.WorldCapabilityData capabilityData;
+ private final it.unimi.dsi.fastutil.ints.Int2ObjectMap<net.minecraftforge.entity.PartEntity<?>> 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;
Expand All @@ -147,10 +146,9 @@
+ public boolean dummyFreshEntitySpawn = false; // Mohist - Fix Pehkui Startup (#1324)
+
+ // Mohist start - Add option to ignore empty time
+ private static List<String> IGNORE_EMPTY_TIME_LIST;
+ private static List<String> 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(";")) {
Expand All @@ -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());
}

Expand All @@ -205,6 +206,7 @@
}
-
- }
+ this.craftWorld = new CraftWorld(this, generator, environment);
+ this.getCBServer().addWorld(this.getWorld()); // CraftBukkit
+ this.initCapabilities();
+ }
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/mohistmc/forge/ForgeInjectBukkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@

public class ForgeInjectBukkit {

public static BiMap<DimensionType, World.Environment> environment =
HashBiMap.create(ImmutableMap.<DimensionType, World.Environment>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<RegistryKey<DimensionType>, World.Environment> environment =
HashBiMap.create(ImmutableMap.<RegistryKey<DimensionType>, 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<World.Environment, RegistryKey<Dimension>> environment0 =
Expand Down Expand Up @@ -222,7 +222,6 @@ public static void addEnumEnvironment(Registry<Dimension> 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++;
Expand Down

0 comments on commit 7250fe5

Please sign in to comment.