Skip to content

Commit

Permalink
fix spawn chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
chochem committed Jun 13, 2023
1 parent fe8dc47 commit f0943ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/main/java/gregtech/common/GT_Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,11 @@ public void onServerStarted() {
if (world.getWorldInfo()
.getWorldTotalTime() == 0L) {
// The world has just been created
GT_Worldgenerator.useNewOregenPattern = true;
GT_Worldgenerator.useNewOregenPattern = 1;
}
if (GT_Worldgenerator.useNewOregenPattern == -1) {
// this is an old world that got updated
GT_Worldgenerator.useNewOregenPattern = 0;
}
GT_Worldgenerator.OregenPatternSavedData.loadData(world);
}
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/gregtech/common/GT_Worldgenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ public class GT_Worldgenerator implements IWorldGenerator {
public static final Object listLock = new Object();

/**
* {@code true} if ore-veins positions are evenly spaced, {@code false} if they are symmetrical to the X and Z axis.
* {@code 1} if ore-veins positions are evenly spaced, {@code 0} if they are symmetrical to the X and Z axis,
* {@code -1} if the state is unknown
*/
public static boolean useNewOregenPattern = false;
public static int useNewOregenPattern = -1;

public GT_Worldgenerator() {
endAsteroids = GregTech_API.sWorldgenFile.get("endasteroids", "GenerateAsteroids", true);
Expand Down Expand Up @@ -130,7 +131,7 @@ public void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvide
}

public static boolean isOreChunk(int chunkX, int chunkZ) {
if (useNewOregenPattern) {
if (useNewOregenPattern == 1 || useNewOregenPattern == -1) {
return Math.floorMod(chunkX, 3) == 1 && Math.floorMod(chunkZ, 3) == 1;
}
return Math.abs(chunkX) % 3 == 1 && Math.abs(chunkZ) % 3 == 1;
Expand Down Expand Up @@ -158,13 +159,22 @@ public static void loadData(World world) {
@Override
public void readFromNBT(NBTTagCompound p_76184_1_) {
if (p_76184_1_.hasKey(KEY)) {
useNewOregenPattern = p_76184_1_.getBoolean(KEY);
if (p_76184_1_.getBoolean(KEY)) {
useNewOregenPattern = 1;
} else {
useNewOregenPattern = 0;
}
}
}

@Override
public void writeToNBT(NBTTagCompound p_76187_1_) {
p_76187_1_.setBoolean(KEY, useNewOregenPattern);
if (useNewOregenPattern == 1) {
p_76187_1_.setBoolean(KEY, true);
}
if (useNewOregenPattern == 0) {
p_76187_1_.setBoolean(KEY, false);
}
}

}
Expand Down

0 comments on commit f0943ec

Please sign in to comment.