From f24679507bfe20ec5724f2b1d2699ce781344315 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Mon, 13 Sep 2021 17:39:49 -0500 Subject: [PATCH 01/27] fixed compat with JEID by running check for it --- .../biomes/ForgeBiomeRegistryManager.java | 48 ++++++++++------- .../gui/dimensions/OTGGuiDimensionList.java | 52 ++++++++++++------- .../packets/CreateDeleteDimensionPacket.java | 24 +++++---- 3 files changed, 74 insertions(+), 50 deletions(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index a3ee54c1b..3e84b7cab 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -29,10 +29,12 @@ import net.minecraft.world.biome.Biome; import net.minecraftforge.common.BiomeDictionary; import net.minecraftforge.common.BiomeDictionary.Type; +import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.registry.ForgeRegistries; public class ForgeBiomeRegistryManager { + public static final boolean JEID = Loader.isModLoaded("jeid"); private BiMap ids = null; private BiMap names = null; @@ -104,7 +106,7 @@ public static ForgeBiome getOrCreateBiome(BiomeConfig biomeConfig, BiomeIds biom // This can happen when an unloaded world is loaded, its biomes have already been registered biome = alreadyRegisteredBiome; } else { - + // No existing biome, create new one OTGBiome customBiome = new OTGBiome(biomeConfig, registryKey); @@ -144,12 +146,17 @@ else if(biomeIds.getSavedId() > -1) // only for biome -> id queries, any (saved)id -> biome query will return the ReplaceToBiomeName biome. Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); - - if (biomeIds.getSavedId() >= 256 || biomeIds.getSavedId() < 0) - { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); - } - + + if(JEID) { + if (biomeIds.getSavedId() >= Integer.MAX_VALUE || biomeIds.getSavedId() < 0) { + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under Integer.MAX_VALUE have been allocated\n" + ". Please report this to JEID issue tracker."); + } + } else { + if (biomeIds.getSavedId() >= 256 || biomeIds.getSavedId() < 0) { + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); + } + } + ForgeBiome forgeBiome = new ForgeBiome(biome, biomeConfig, biomeIds); ForgeBiomeRegistryManager.registerBiomeInBiomeDictionary(biome, existingBiome, biomeConfig, configProvider); @@ -595,17 +602,20 @@ public static List getDefaultBiomes() return standardBiomes; } - public int getAvailableBiomeIdsCount() - { - BitSet biomeRegistryAvailabiltyMap = getBiomeRegistryAvailabiltyMap(); - int availableIds = 0; - for(int i = 0; i < ForgeWorld.MAX_SAVED_BIOMES_COUNT; i++) - { - if(i >= biomeRegistryAvailabiltyMap.size() || !biomeRegistryAvailabiltyMap.get(i)) - { - availableIds++; - } - } - return availableIds; + public int getAvailableBiomeIdsCount() { + if (JEID) { + return Integer.MAX_VALUE; + } else { + BitSet biomeRegistryAvailabiltyMap = getBiomeRegistryAvailabiltyMap(); + int availableIds = 0; + + for (int i = 0; i < ForgeWorld.MAX_SAVED_BIOMES_COUNT; i++) { + if (i >= biomeRegistryAvailabiltyMap.size() || !biomeRegistryAvailabiltyMap.get(i)) { + availableIds++; + } + } + + return availableIds; + } } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java index 6fbfe301e..0aac5d3bd 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java @@ -46,6 +46,8 @@ import com.pg85.otg.forge.world.ForgeWorldSession; import com.pg85.otg.logging.LogMarker; +import static com.pg85.otg.forge.biomes.ForgeBiomeRegistryManager.JEID; + public class OTGGuiDimensionList extends GuiScreen implements GuiYesNoCallback { static @@ -485,12 +487,15 @@ protected void actionPerformed(GuiButton button) throws IOException { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Multiple dimensions are using the same portal color, each dimension's portal color must be unique.")); } - else if(!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) - { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); - } else { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); - } + else if (JEID) { + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); + } else { + if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); + } else { + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); + } + } } else { if(this.mc.isSingleplayer()) @@ -520,20 +525,27 @@ else if(!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) if(dimConfig.isNewConfig) { ArrayList presetNames = new ArrayList(); - presetNames.add(dimConfig.PresetName); - if(OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) - { - dimConfig.isNewConfig = false; - OTG.IsNewWorldBeingCreated = true; - if(!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) - { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Dimension id " + dimConfig.DimensionId + " was taken.")); - } - OTG.IsNewWorldBeingCreated = false; - } else { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); - break; - } + presetNames.add(dimConfig.PresetName); + if (JEID) { + dimConfig.isNewConfig = false; + OTG.IsNewWorldBeingCreated = true; + if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Dimension id " + dimConfig.DimensionId + " was taken.")); + } + OTG.IsNewWorldBeingCreated = false; + } else { + if (OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + dimConfig.isNewConfig = false; + OTG.IsNewWorldBeingCreated = true; + if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Dimension id " + dimConfig.DimensionId + " was taken.")); + } + OTG.IsNewWorldBeingCreated = false; + } else { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); + break; + } + } } } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java index 0bf2bc884..12974d6e0 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java @@ -29,6 +29,8 @@ import io.netty.buffer.ByteBuf; +import static com.pg85.otg.forge.biomes.ForgeBiomeRegistryManager.JEID; + /** * Sent from the client to the server when players use the ingame UI to create/delete dimensions */ @@ -107,17 +109,17 @@ public void run() // Ensure the portal color is unique (not already in use), otherwise correct it. PortalColors.correctPortalColor(dimConfig, OTG.getDimensionsConfig().getAllDimensions()); - - ArrayList presetNames = new ArrayList(); - presetNames.add(dimConfig.PresetName); - if(!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) - { - // Update the UI on the client - ServerPacketManager.sendDimensionSynchPacketToAllPlayers(player.getServer()); - OTG.log(LogMarker.INFO, "Warning: Client tried to create a dimension, but not enough biome id's are available."); - return; - } - + if(JEID) { + } else { + ArrayList presetNames = new ArrayList(); + presetNames.add(dimConfig.PresetName); + if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + // Update the UI on the client + ServerPacketManager.sendDimensionSynchPacketToAllPlayers(player.getServer()); + OTG.log(LogMarker.INFO, "Warning: Client tried to create a dimension, but not enough biome id's are available."); + return; + } + } long seed = (new Random()).nextLong(); String sSeed = dimConfig.Seed; if (sSeed != null && !StringUtils.isEmpty(sSeed)) From ef29ebc16ba4b342a05ea371c2e74d4b5f6cc743 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Mon, 13 Sep 2021 19:02:56 -0500 Subject: [PATCH 02/27] remove unnecessary part of a check and fixed spacing --- .../com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java | 2 +- .../com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index 3e84b7cab..418a6e327 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -148,7 +148,7 @@ else if(biomeIds.getSavedId() > -1) Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); if(JEID) { - if (biomeIds.getSavedId() >= Integer.MAX_VALUE || biomeIds.getSavedId() < 0) { + if (biomeIds.getSavedId() < 0) { throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under Integer.MAX_VALUE have been allocated\n" + ". Please report this to JEID issue tracker."); } } else { diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java index 0aac5d3bd..5a630cdb9 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java @@ -490,7 +490,7 @@ protected void actionPerformed(GuiButton button) throws IOException else if (JEID) { this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); } else { - if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); } else { this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); From 7de2afffe7a5d5f02e559f3f874c3145b4005611 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 01:07:50 -0500 Subject: [PATCH 03/27] virtual biomes not working yet but saving changes so far --- .../otg/network/ServerConfigProvider.java | 73 +++++++++---------- .../main/java/com/pg85/otg/util/BiomeIds.java | 2 +- .../biomes/ForgeBiomeRegistryManager.java | 2 +- .../com/pg85/otg/forge/world/ForgeWorld.java | 5 +- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 0b83a26f4..3163f5404 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -34,7 +34,6 @@ import com.pg85.otg.util.minecraft.defaults.DefaultBiome; import com.pg85.otg.worldsave.BiomeIdData; import com.pg85.otg.worldsave.WorldSaveData; -import org.apache.commons.lang3.StringUtils; /** * Holds the WorldConfig and all BiomeConfigs. @@ -53,7 +52,7 @@ public final class ServerConfigProvider implements ConfigProvider { private static final int MAX_INHERITANCE_DEPTH = 15; - private LocalWorld world; + private LocalWorld world; private File settingsDir; private WorldConfig worldConfig; @@ -469,7 +468,7 @@ private String indexSettings(Map worldBiomes, boolean isNewWorl new BiomeIdData( world.getName() + "_" + worldBiome.getKey(), worldBiome.getValue(), - worldBiome.getValue() > 255 || ( + worldBiome.getValue() > worldBiomes.size() || ( biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0 ) ? -1 : worldBiome.getValue() @@ -552,7 +551,7 @@ else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()) throw new RuntimeException("Error: OTG Biome id " + biomeIdData.otgBiomeId + " for biome " + biomeConfig.getName() + " was taken by " + OTG.getBiomeByOTGId(biomeIdData.otgBiomeId).getName()); } - if(biomeIdData.otgBiomeId > -1 && biomeIdData.otgBiomeId < 256) + if(biomeIdData.otgBiomeId > -1 && biomeIdData.otgBiomeId == getRequestedSavedId(biomeConfig.replaceToBiomeName)) { if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0) { @@ -560,7 +559,7 @@ else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()) } nonVirtualBiomesExisting.add(biomeConfig); } - else if(biomeIdData.otgBiomeId > 255) + else if(biomeIdData.otgBiomeId != getRequestedSavedId(biomeConfig.replaceToBiomeName)) { virtualBiomesExisting.add(biomeConfig); } @@ -573,16 +572,16 @@ else if(biomeIdData.otgBiomeId > 255) // Set OTG biome id's for biomes, make sure there is enough space to register all biomes. for (BiomeConfig biomeConfig : usedBiomes) - { + { // Statistics of the loaded biomes this.biomesCount++; loadedBiomeNames.append(biomeConfig.getName()); loadedBiomeNames.append(", "); BiomeConfig[] otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); - + int otgBiomeId = -1; - + // Exclude already registered biomes from loadedBiomeIdData / default biomes boolean bFound = false; for(int i = 0; i < otgIds2.length; i++) @@ -591,7 +590,7 @@ else if(biomeIdData.otgBiomeId > 255) if(biomeConfig == biomeConfig2) { bFound = true; - break; + break; } // Forge dimensions: If a world is being reloaded after being unloaded replace the existing biomeConfig else if( @@ -609,33 +608,28 @@ else if( { continue; // biome is from loadedBiomeIdData, already registered. } - - if(otgBiomeId == -1) - { - // Find the next available id - for(int i = (!biomeConfig.replaceToBiomeName.isEmpty() ? 256 : 0); i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 - { - if((biomeConfig.replaceToBiomeName.isEmpty() && i > 255) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) - { - OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); - throw new RuntimeException("Biome could not be registered, no free biome id's!"); - } - if(OTG.getEngine().isOTGBiomeIdAvailable(world.getName(), i)) - { - otgBiomeId = i; - OTG.getEngine().setOTGBiomeId(world.getName(), i, biomeConfig, false); - break; - } - } - if(otgBiomeId > -1 && otgBiomeId < 256) - { - nonVirtualBiomes.add(biomeConfig); - } - else if(otgBiomeId > 255) - { - virtualBiomes.add(biomeConfig); - } - } + + if(otgBiomeId == -1) { + // Find the next available id + + for (int i = (!biomeConfig.replaceToBiomeName.isEmpty() ? worldBiomes.size() : 0); i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 + { + if ((biomeConfig.replaceToBiomeName.isEmpty() && otgBiomeId > worldBiomes.size()) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); + throw new RuntimeException("Biome could not be registered, no free biome id's!"); + } + if (OTG.getEngine().isOTGBiomeIdAvailable(world.getName(), i)) { + otgBiomeId = i; + OTG.getEngine().setOTGBiomeId(world.getName(), i, biomeConfig, false); + break; + } + } + if (otgBiomeId > -1 && otgBiomeId == getRequestedSavedId(biomeConfig.replaceToBiomeName)) { + nonVirtualBiomes.add(biomeConfig); + } else if (otgBiomeId != getRequestedSavedId(biomeConfig.replaceToBiomeName)) { + virtualBiomes.add(biomeConfig); + } + } } // When loading an existing world load the existing biomes first, new biomes after so they don't claim reserved biome id's. @@ -802,7 +796,7 @@ private int findSavedBiomeId(BiomeConfig biomeConfig, BiomeConfig[] configArray, // Once we get here, the config doesn't exist // Try one last time, if that doesn't work, we throw an error int id = getRequestedSavedId(biomeConfig.replaceToBiomeName); - if (0 <= id && id <= 255) { + if (0 <= id) { // It has a valid ID, let's just return that return id; } @@ -821,8 +815,9 @@ public List getBiomeArrayLegacy() { // For backwards compatibility, sort the biomes by saved id and return default biomes as if they were custom biomes List nonDefaultbiomes = new ArrayList(); - LocalBiome[] defaultBiomes = new LocalBiome[256]; - for(LocalBiome biome : this.biomesByOTGId) + + LocalBiome[] defaultBiomes = new LocalBiome[world.getMaxBiomesCount()]; + for(LocalBiome biome : this.biomesByOTGId) { if(biome != null) { diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index 5b8335598..fdf3b2650 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -35,7 +35,7 @@ public BiomeIds(int otgBiomeId, int savedId) */ public boolean isVirtual() { - return otgBiomeId > 255; + return otgBiomeId != savedId; } /** diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index 418a6e327..0660b23ed 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -149,7 +149,7 @@ else if(biomeIds.getSavedId() > -1) if(JEID) { if (biomeIds.getSavedId() < 0) { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under Integer.MAX_VALUE have been allocated\n" + ". Please report this to JEID issue tracker."); + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); } } else { if (biomeIds.getSavedId() >= 256 || biomeIds.getSavedId() < 0) { diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java index 8661770b9..a0df71302 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java @@ -84,6 +84,8 @@ import java.util.List; import java.util.Random; +import static com.pg85.otg.forge.biomes.ForgeBiomeRegistryManager.JEID; + // TODO: Change localworld into abstract class and implement common logic there public class ForgeWorld implements LocalWorld { @@ -506,8 +508,7 @@ public void unRegisterBiomes() } @Override - public int getMaxBiomesCount() - { + public int getMaxBiomesCount() { return MAX_BIOMES_COUNT; } From 87e1c4fd96f2e91fa05b2c9a2e7f48ba112cc1a3 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 02:07:04 -0500 Subject: [PATCH 04/27] working with virtual biome now --- .../com/pg85/otg/network/ServerConfigProvider.java | 13 ++----------- .../src/main/java/com/pg85/otg/util/BiomeIds.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 3163f5404..d753eb351 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -1,15 +1,7 @@ package com.pg85.otg.network; import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Map.Entry; import com.pg85.otg.OTG; @@ -815,8 +807,7 @@ public List getBiomeArrayLegacy() { // For backwards compatibility, sort the biomes by saved id and return default biomes as if they were custom biomes List nonDefaultbiomes = new ArrayList(); - - LocalBiome[] defaultBiomes = new LocalBiome[world.getMaxBiomesCount()]; + LocalBiome[] defaultBiomes = new LocalBiome[99999]; for(LocalBiome biome : this.biomesByOTGId) { if(biome != null) diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index fdf3b2650..8b658c23d 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -1,5 +1,7 @@ package com.pg85.otg.util; +import java.util.Random; + /** * Immutable class to hold the biome ids of a biome. *

@@ -35,7 +37,7 @@ public BiomeIds(int otgBiomeId, int savedId) */ public boolean isVirtual() { - return otgBiomeId != savedId; + return otgBiomeId > savedId; } /** @@ -45,7 +47,12 @@ public boolean isVirtual() */ public int getSavedId() { - return savedId; + if (savedId == -1){ + Random random = new Random(); + return random.nextInt(99999); + } else { + return savedId; + } } /** From e338177a556d4eb082eeac8cc50285b5b85c3b3a Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 02:13:39 -0500 Subject: [PATCH 05/27] fixed id error with Dry Savannah --- common/src/main/java/com/pg85/otg/util/BiomeIds.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index 8b658c23d..0d94d2896 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -49,7 +49,7 @@ public int getSavedId() { if (savedId == -1){ Random random = new Random(); - return random.nextInt(99999); + return random.nextInt(255); } else { return savedId; } From 231f380e09ec8a646c2d4ca7efc589a5441cb56b Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 14:28:04 -0500 Subject: [PATCH 06/27] fixed more stuff with virtual biomes --- .../pg85/otg/network/ServerConfigProvider.java | 15 +++++++-------- .../src/main/java/com/pg85/otg/util/BiomeIds.java | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index d753eb351..09253e7c7 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -459,8 +459,7 @@ private String indexSettings(Map worldBiomes, boolean isNewWorl loadedBiomeIdData.add( new BiomeIdData( world.getName() + "_" + worldBiome.getKey(), - worldBiome.getValue(), - worldBiome.getValue() > worldBiomes.size() || ( + worldBiome.getValue(), ( biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0 ) ? -1 : worldBiome.getValue() @@ -543,7 +542,7 @@ else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()) throw new RuntimeException("Error: OTG Biome id " + biomeIdData.otgBiomeId + " for biome " + biomeConfig.getName() + " was taken by " + OTG.getBiomeByOTGId(biomeIdData.otgBiomeId).getName()); } - if(biomeIdData.otgBiomeId > -1 && biomeIdData.otgBiomeId == getRequestedSavedId(biomeConfig.replaceToBiomeName)) + if(biomeIdData.otgBiomeId > -1 && biomeIdData.otgBiomeId == biomeConfig.replaceToBiomeName.trim().length()) { if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0) { @@ -551,7 +550,7 @@ else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()) } nonVirtualBiomesExisting.add(biomeConfig); } - else if(biomeIdData.otgBiomeId != getRequestedSavedId(biomeConfig.replaceToBiomeName)) + else if(biomeIdData.otgBiomeId != biomeConfig.replaceToBiomeName.trim().length()) { virtualBiomesExisting.add(biomeConfig); } @@ -604,9 +603,9 @@ else if( if(otgBiomeId == -1) { // Find the next available id - for (int i = (!biomeConfig.replaceToBiomeName.isEmpty() ? worldBiomes.size() : 0); i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 + for (int i = (!biomeConfig.replaceToBiomeName.isEmpty() ? biomeConfig.replaceToBiomeName.trim().length() : 0); i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && otgBiomeId > worldBiomes.size()) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && otgBiomeId > biomeConfig.replaceToBiomeName.trim().length()) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -616,9 +615,9 @@ else if( break; } } - if (otgBiomeId > -1 && otgBiomeId == getRequestedSavedId(biomeConfig.replaceToBiomeName)) { + if (otgBiomeId > -1 && otgBiomeId < biomeConfig.replaceToBiomeName.trim().length()) { nonVirtualBiomes.add(biomeConfig); - } else if (otgBiomeId != getRequestedSavedId(biomeConfig.replaceToBiomeName)) { + } else if (otgBiomeId >= biomeConfig.replaceToBiomeName.trim().length()) { virtualBiomes.add(biomeConfig); } } diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index 0d94d2896..9d6cd91b1 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -37,7 +37,7 @@ public BiomeIds(int otgBiomeId, int savedId) */ public boolean isVirtual() { - return otgBiomeId > savedId; + return otgBiomeId != savedId; } /** From 670cb612b86de9077eb73a92b4bce3bcbe6c9a09 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 19:20:09 -0500 Subject: [PATCH 07/27] checking for errors --- .../otg/network/ServerConfigProvider.java | 19 ++++++++++--------- .../main/java/com/pg85/otg/util/BiomeIds.java | 9 +++------ .../biomes/ForgeBiomeRegistryManager.java | 6 +++--- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 09253e7c7..5d49a9e24 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -542,15 +542,15 @@ else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()) throw new RuntimeException("Error: OTG Biome id " + biomeIdData.otgBiomeId + " for biome " + biomeConfig.getName() + " was taken by " + OTG.getBiomeByOTGId(biomeIdData.otgBiomeId).getName()); } - if(biomeIdData.otgBiomeId > -1 && biomeIdData.otgBiomeId == biomeConfig.replaceToBiomeName.trim().length()) + if(biomeIdData.otgBiomeId > -1 && biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.length() > 0) { - if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0) + if(biomeConfig.replaceToBiomeName.trim().length() > 0) { throw new RuntimeException("Error: Biome \"" + biomeConfig.getName() + "\" has an id between 0-255 but uses replaceToBiomeName. Virtual biomes must have id's above 255, please check your WorldConfig's custom biomes setting."); } nonVirtualBiomesExisting.add(biomeConfig); } - else if(biomeIdData.otgBiomeId != biomeConfig.replaceToBiomeName.trim().length()) + else if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.length() > 0) { virtualBiomesExisting.add(biomeConfig); } @@ -603,9 +603,9 @@ else if( if(otgBiomeId == -1) { // Find the next available id - for (int i = (!biomeConfig.replaceToBiomeName.isEmpty() ? biomeConfig.replaceToBiomeName.trim().length() : 0); i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 + for (int i = 0; i < Integer.MAX_VALUE; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && otgBiomeId > biomeConfig.replaceToBiomeName.trim().length()) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && biomeConfig.replaceToBiomeName == null && biomeConfig.replaceToBiomeName.trim().length() < 0 ) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -615,9 +615,9 @@ else if( break; } } - if (otgBiomeId > -1 && otgBiomeId < biomeConfig.replaceToBiomeName.trim().length()) { + if (otgBiomeId > -1 && biomeConfig.replaceToBiomeName == null && biomeConfig.replaceToBiomeName.trim().length() < 0) { nonVirtualBiomes.add(biomeConfig); - } else if (otgBiomeId >= biomeConfig.replaceToBiomeName.trim().length()) { + } else if (biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() >= 0) { virtualBiomes.add(biomeConfig); } } @@ -786,8 +786,9 @@ private int findSavedBiomeId(BiomeConfig biomeConfig, BiomeConfig[] configArray, } // Once we get here, the config doesn't exist // Try one last time, if that doesn't work, we throw an error - int id = getRequestedSavedId(biomeConfig.replaceToBiomeName); - if (0 <= id) { + + int id = getRequestedSavedId(biomeConfig.replaceToBiomeName); + if (-1 < id || biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() >= 0) { // It has a valid ID, let's just return that return id; } diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index 9d6cd91b1..bc300e442 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -1,5 +1,7 @@ package com.pg85.otg.util; +import com.pg85.otg.configuration.biome.BiomeConfig; + import java.util.Random; /** @@ -47,12 +49,7 @@ public boolean isVirtual() */ public int getSavedId() { - if (savedId == -1){ - Random random = new Random(); - return random.nextInt(255); - } else { - return savedId; - } + return savedId; } /** diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index 0660b23ed..f2d9b70f6 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -111,9 +111,9 @@ public static ForgeBiome getOrCreateBiome(BiomeConfig biomeConfig, BiomeIds biom OTGBiome customBiome = new OTGBiome(biomeConfig, registryKey); ForgeEngine forgeEngine = ((ForgeEngine) OTG.getEngine()); - - if (biomeIds.isVirtual()) - //if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.length() > 0) // This biome uses ReplaceToBiomeName and should use the ReplaceToBiomeName biome's id. + + //if (biomeIds.isVirtual()) + if(biomeIds.getOTGBiomeId() > -1 && biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.length() > 0) // This biome uses ReplaceToBiomeName and should use the ReplaceToBiomeName biome's id. { // Only register by resourcelocation. // TODO: Make sure this is enough for Forge 1.12+ <- It looks like the server may not send the biomes to the client if they are not added to the registry. TODO: Check if only virtual biomes have this problem. From 699be3fb75148d891ed69dd048b24b60fefeea7c Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 20:26:41 -0500 Subject: [PATCH 08/27] fix the -1 bug once and for all --- .../java/com/pg85/otg/network/ClientConfigProvider.java | 2 +- .../java/com/pg85/otg/network/ServerConfigProvider.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index fe39a3805..dc609ceb2 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -135,7 +135,7 @@ public List getBiomeArrayLegacy() { // For backwards compatibility, sort the biomes by saved id and return default biomes as if they were custom biomes List nonDefaultbiomes = new ArrayList(); - LocalBiome[] defaultBiomes = new LocalBiome[256]; + LocalBiome[] defaultBiomes = new LocalBiome[99999]; for(LocalBiome biome : this.biomesByOTGId) { if(biome != null) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 5d49a9e24..c73f609c7 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -605,7 +605,7 @@ else if( for (int i = 0; i < Integer.MAX_VALUE; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && biomeConfig.replaceToBiomeName == null && biomeConfig.replaceToBiomeName.trim().length() < 0 ) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0 ) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -615,9 +615,9 @@ else if( break; } } - if (otgBiomeId > -1 && biomeConfig.replaceToBiomeName == null && biomeConfig.replaceToBiomeName.trim().length() < 0) { + if (otgBiomeId > -1 && !(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0)) { nonVirtualBiomes.add(biomeConfig); - } else if (biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() >= 0) { + } else if (biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0) { virtualBiomes.add(biomeConfig); } } From 977585a1868879262294bf95a27f50a4f1ffa410 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Tue, 14 Sep 2021 22:09:32 -0500 Subject: [PATCH 09/27] fixed quick error when loading biomes --- .../java/com/pg85/otg/network/ServerConfigProvider.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index c73f609c7..68e5b077f 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -542,15 +542,15 @@ else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()) throw new RuntimeException("Error: OTG Biome id " + biomeIdData.otgBiomeId + " for biome " + biomeConfig.getName() + " was taken by " + OTG.getBiomeByOTGId(biomeIdData.otgBiomeId).getName()); } - if(biomeIdData.otgBiomeId > -1 && biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.length() > 0) + if(biomeIdData.otgBiomeId > -1 && !(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0)) { - if(biomeConfig.replaceToBiomeName.trim().length() > 0) + if(biomeConfig.replaceToBiomeName != null &&biomeConfig.replaceToBiomeName.trim().length() > 0) { throw new RuntimeException("Error: Biome \"" + biomeConfig.getName() + "\" has an id between 0-255 but uses replaceToBiomeName. Virtual biomes must have id's above 255, please check your WorldConfig's custom biomes setting."); } nonVirtualBiomesExisting.add(biomeConfig); } - else if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.length() > 0) + else if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0) { virtualBiomesExisting.add(biomeConfig); } From ee21b16c8b5d65eb516d07dcb7c9974775fcd533 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 03:08:06 -0500 Subject: [PATCH 10/27] fix a check with empty and null in the same line --- .../main/java/com/pg85/otg/network/ServerConfigProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 68e5b077f..0d409ec12 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -605,7 +605,7 @@ else if( for (int i = 0; i < Integer.MAX_VALUE; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0 ) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0 ) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } From 84fbc1905b9b5d8555b0154c077e32ae841a44ee Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 03:48:35 -0500 Subject: [PATCH 11/27] fixed more checks and increased a couple of more values --- common/src/main/java/com/pg85/otg/OTGEngine.java | 4 ++-- .../main/java/com/pg85/otg/network/ServerConfigProvider.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/OTGEngine.java b/common/src/main/java/com/pg85/otg/OTGEngine.java index be79101df..f1baa82b0 100644 --- a/common/src/main/java/com/pg85/otg/OTGEngine.java +++ b/common/src/main/java/com/pg85/otg/OTGEngine.java @@ -304,7 +304,7 @@ public void setOTGBiomeId(String worldName, int i, BiomeConfig biomeConfig, bool { if(!otgBiomeIdsByWorld.containsKey(worldName)) { - otgBiomeIdsByWorld.put(worldName, new BiomeConfig[1024]); + otgBiomeIdsByWorld.put(worldName, new BiomeConfig[999999]); } if(replaceExisting || otgBiomeIdsByWorld.get(worldName)[i] == null) { @@ -316,7 +316,7 @@ public void setOTGBiomeId(String worldName, int i, BiomeConfig biomeConfig, bool public BiomeConfig[] getOTGBiomeIds(String worldName) { - return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new BiomeConfig[1024]; + return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new BiomeConfig[999999]; } public boolean isOTGBiomeIdAvailable(String worldName, int i) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 0d409ec12..697d36164 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -605,7 +605,7 @@ else if( for (int i = 0; i < Integer.MAX_VALUE; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0 ) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (Integer.MAX_VALUE - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -788,7 +788,7 @@ private int findSavedBiomeId(BiomeConfig biomeConfig, BiomeConfig[] configArray, // Try one last time, if that doesn't work, we throw an error int id = getRequestedSavedId(biomeConfig.replaceToBiomeName); - if (-1 < id || biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() >= 0) { + if (id > -1 && (biomeConfig.replaceToBiomeName == null || biomeConfig.replaceToBiomeName.trim().length() == 0)) { // It has a valid ID, let's just return that return id; } From e651f6c833ed25e6dfc36ebedd532cb61001f3db Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 04:25:29 -0500 Subject: [PATCH 12/27] ok fixed even more values and added some more checks for JEID --- .../com/pg85/otg/network/ClientConfigProvider.java | 2 +- .../com/pg85/otg/network/ServerConfigProvider.java | 6 +++--- .../java/com/pg85/otg/forge/world/ForgeWorld.java | 12 ++++++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index dc609ceb2..fe39a3805 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -135,7 +135,7 @@ public List getBiomeArrayLegacy() { // For backwards compatibility, sort the biomes by saved id and return default biomes as if they were custom biomes List nonDefaultbiomes = new ArrayList(); - LocalBiome[] defaultBiomes = new LocalBiome[99999]; + LocalBiome[] defaultBiomes = new LocalBiome[256]; for(LocalBiome biome : this.biomesByOTGId) { if(biome != null) diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 697d36164..6c26a404a 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -603,9 +603,9 @@ else if( if(otgBiomeId == -1) { // Find the next available id - for (int i = 0; i < Integer.MAX_VALUE; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 + for (int i = 0; i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (Integer.MAX_VALUE - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (otgIds2.length - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -807,7 +807,7 @@ public List getBiomeArrayLegacy() { // For backwards compatibility, sort the biomes by saved id and return default biomes as if they were custom biomes List nonDefaultbiomes = new ArrayList(); - LocalBiome[] defaultBiomes = new LocalBiome[99999]; + LocalBiome[] defaultBiomes = new LocalBiome[256]; for(LocalBiome biome : this.biomesByOTGId) { if(biome != null) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java index a0df71302..1295d8e06 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java @@ -509,13 +509,21 @@ public void unRegisterBiomes() @Override public int getMaxBiomesCount() { - return MAX_BIOMES_COUNT; + if(JEID){ + return 999999; + } else { + return MAX_BIOMES_COUNT; + } } @Override public int getMaxSavedBiomesCount() { - return MAX_SAVED_BIOMES_COUNT; + if(JEID){ + return Integer.MAX_VALUE; + } else { + return MAX_SAVED_BIOMES_COUNT; + } } // Chunks From 013f8e167e0a1af083f64002e43ad91a26078a28 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 13:08:41 -0500 Subject: [PATCH 13/27] added one last check for JEID --- .../src/main/java/com/pg85/otg/forge/ForgeEngine.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/ForgeEngine.java b/platforms/forge/src/main/java/com/pg85/otg/forge/ForgeEngine.java index 9ba1c5aa0..8c3c88ec2 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/ForgeEngine.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/ForgeEngine.java @@ -35,6 +35,8 @@ import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Loader; +import static com.pg85.otg.forge.biomes.ForgeBiomeRegistryManager.JEID; + public class ForgeEngine extends OTGEngine { private ForgeBiomeRegistryManager biomeRegistryManager; @@ -199,7 +201,10 @@ public boolean isModLoaded(String mod) @Override public boolean areEnoughBiomeIdsAvailableForPresets(ArrayList presetNames) { - if(presetNames == null) + if(JEID) { + return true; + } + if(presetNames == null) { return true; } From f2697348cfa28156084e6e4054f1fbd7fe9708c2 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 13:41:59 -0500 Subject: [PATCH 14/27] changed Integer.MAX_VALUE to 640000 int --- .../src/main/java/com/pg85/otg/forge/world/ForgeWorld.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java index 1295d8e06..31bf0f577 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java @@ -520,7 +520,7 @@ public int getMaxBiomesCount() { public int getMaxSavedBiomesCount() { if(JEID){ - return Integer.MAX_VALUE; + return 640000; } else { return MAX_SAVED_BIOMES_COUNT; } From 7f0bd579b46c608e1f7af5e8ae7c1ce5e85bf8b3 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 20:06:21 -0500 Subject: [PATCH 15/27] fixed more stuff - refactored duplicate code in some checks - replace empty if (JEID) check with if (!JEID) - change BiomeConfig[] to ArrayList() in a lot of places --- .../src/main/java/com/pg85/otg/OTGEngine.java | 18 ++++++++--------- .../otg/network/ServerConfigProvider.java | 20 +++++++++---------- .../biomes/ForgeBiomeRegistryManager.java | 7 ++++--- .../forge/events/client/ClientFogHandler.java | 2 +- .../gui/dimensions/OTGGuiDimensionList.java | 20 ++++++------------- .../packets/CreateDeleteDimensionPacket.java | 3 +-- 6 files changed, 31 insertions(+), 39 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/OTGEngine.java b/common/src/main/java/com/pg85/otg/OTGEngine.java index f1baa82b0..f045845de 100644 --- a/common/src/main/java/com/pg85/otg/OTGEngine.java +++ b/common/src/main/java/com/pg85/otg/OTGEngine.java @@ -34,7 +34,7 @@ public abstract class OTGEngine { - private HashMap otgBiomeIdsByWorld = new HashMap(); + private HashMap> otgBiomeIdsByWorld = new HashMap>(); private BiomeModeManager biomeManagers; private List cancelableEventHandlers = new ArrayList(5); private BiomeResourcesManager biomeResourcesManager; @@ -304,29 +304,29 @@ public void setOTGBiomeId(String worldName, int i, BiomeConfig biomeConfig, bool { if(!otgBiomeIdsByWorld.containsKey(worldName)) { - otgBiomeIdsByWorld.put(worldName, new BiomeConfig[999999]); + otgBiomeIdsByWorld.put(worldName, new ArrayList<>()); } - if(replaceExisting || otgBiomeIdsByWorld.get(worldName)[i] == null) + if(replaceExisting || otgBiomeIdsByWorld.get(worldName).get(i) == null) { - otgBiomeIdsByWorld.get(worldName)[i] = biomeConfig; + otgBiomeIdsByWorld.get(worldName).set(i, biomeConfig); } else { - throw new RuntimeException("Tried to register OTG biome " + biomeConfig.getName() + " with id " + i + " but the id is in use by biome " + otgBiomeIdsByWorld.get(worldName)[i].getName() + ". OTG 1.12.2 v7 and above use dynamic biome id's for new worlds, this avoids the problem completely."); + throw new RuntimeException("Tried to register OTG biome " + biomeConfig.getName() + " with id " + i + " but the id is in use by biome " + otgBiomeIdsByWorld.get(worldName).get(i).getName() + ". OTG 1.12.2 v7 and above use dynamic biome id's for new worlds, this avoids the problem completely."); } } - public BiomeConfig[] getOTGBiomeIds(String worldName) + public ArrayList getOTGBiomeIds(String worldName) { - return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new BiomeConfig[999999]; + return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new ArrayList(); } public boolean isOTGBiomeIdAvailable(String worldName, int i) { - return !otgBiomeIdsByWorld.containsKey(worldName) || otgBiomeIdsByWorld.get(worldName)[i] == null; + return !otgBiomeIdsByWorld.containsKey(worldName) || otgBiomeIdsByWorld.get(worldName).get(i) == null; } public void unregisterOTGBiomeId(String worldName, int i) { - otgBiomeIdsByWorld.get(worldName)[i] = null; + otgBiomeIdsByWorld.get(worldName).set(i, null); } // Materials diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 6c26a404a..350fa4b11 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -533,7 +533,7 @@ public int compare(BiomeConfig a, BiomeConfig b) { { OTG.getEngine().setOTGBiomeId(world.getName(), biomeIdData.otgBiomeId, biomeConfig, false); } - else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName())[biomeIdData.otgBiomeId].getName()).equals(biomeIdData.biomeName)) + else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()).get(biomeIdData.otgBiomeId).getName()).equals(biomeIdData.biomeName)) { OTG.getEngine().setOTGBiomeId(world.getName(), biomeIdData.otgBiomeId, biomeConfig, true); } else { @@ -569,15 +569,15 @@ else if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName loadedBiomeNames.append(biomeConfig.getName()); loadedBiomeNames.append(", "); - BiomeConfig[] otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); + ArrayList otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); int otgBiomeId = -1; // Exclude already registered biomes from loadedBiomeIdData / default biomes boolean bFound = false; - for(int i = 0; i < otgIds2.length; i++) + for(int i = 0; i < otgIds2.size(); i++) { - BiomeConfig biomeConfig2 = otgIds2[i]; + BiomeConfig biomeConfig2 = otgIds2.get(i); if(biomeConfig == biomeConfig2) { bFound = true; @@ -603,9 +603,9 @@ else if( if(otgBiomeId == -1) { // Find the next available id - for (int i = 0; i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 + for (int i = 0; i < otgIds2.size(); i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (otgIds2.length - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (otgIds2.size() - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).size())) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -685,10 +685,10 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi // Get the assigned OTG biome id int otgBiomeId = -1; - BiomeConfig[] otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); - for(int i = 0; i < otgIds2.length; i++) + ArrayList otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); + for(int i = 0; i < otgIds2.size(); i++) { - if(otgIds2[i] == biomeConfig) + if(otgIds2.get(i) == biomeConfig) { otgBiomeId = i; break; @@ -752,7 +752,7 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi * @param counter Simple recursion counter to make sure it doesn't endlessly recurse * @return The saved ID of a registered biome */ - private int findSavedBiomeId(BiomeConfig biomeConfig, BiomeConfig[] configArray, int counter) { + private int findSavedBiomeId(BiomeConfig biomeConfig, ArrayList configArray, int counter) { if (counter > 100) { OTG.log(LogMarker.FATAL, "Failed to replace, recursion went deeper than 100 layers. Did you create a replace loop at "+biomeConfig.replaceToBiomeName+"?"); throw new RuntimeException("Failed to replace, recursion went deeper than 100 layers. Did you create a replace loop at "+biomeConfig.replaceToBiomeName+"?"); diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index f2d9b70f6..b4680c7a1 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -145,15 +145,16 @@ else if(biomeIds.getSavedId() > -1) // Always try to register biomes and create Biome Configs. Biomes with id's > 255 are registered // only for biome -> id queries, any (saved)id -> biome query will return the ReplaceToBiomeName biome. - Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); + Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); + String errorText = "Could not allocate the requested id " + biomeIds.getSavedId() + " for biome "; if(JEID) { if (biomeIds.getSavedId() < 0) { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); + throw new RuntimeException(errorText + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); } } else { if (biomeIds.getSavedId() >= 256 || biomeIds.getSavedId() < 0) { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); + throw new RuntimeException(errorText + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java b/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java index f3abc8f5e..19d984560 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java @@ -404,7 +404,7 @@ private BiomeConfig getBiomeConfig(ForgeWorld world, int x, int z, MutableBlockP short cachedId = biomeCache[x][z]; if (cachedId != -1 && !hasMoved) { - return OTG.getEngine().getOTGBiomeIds(world.getName())[cachedId]; + return OTG.getEngine().getOTGBiomeIds(world.getName()).get(cachedId); } else { Biome biome = world.getBiomeFromChunk(blockPos.getX(), blockPos.getZ()); LocalBiome localBiome = biome != null ? world.getBiomeByNameOrNull(biome.getBiomeName()) : null; diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java index 5a630cdb9..d32e84df3 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java @@ -483,17 +483,18 @@ protected void actionPerformed(GuiButton button) throws IOException } } } + String preset = this.dimensions.get(0).PresetName; if(!bPortalColorsUnique) { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Multiple dimensions are using the same portal color, each dimension's portal color must be unique.")); } else if (JEID) { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, preset)); } else { if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); } else { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, preset)); } } } else { @@ -526,7 +527,7 @@ else if (JEID) { { ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); - if (JEID) { + if (OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames) || JEID) { dimConfig.isNewConfig = false; OTG.IsNewWorldBeingCreated = true; if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { @@ -534,17 +535,8 @@ else if (JEID) { } OTG.IsNewWorldBeingCreated = false; } else { - if (OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { - dimConfig.isNewConfig = false; - OTG.IsNewWorldBeingCreated = true; - if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Dimension id " + dimConfig.DimensionId + " was taken.")); - } - OTG.IsNewWorldBeingCreated = false; - } else { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); - break; - } + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); + break; } } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java index 12974d6e0..47c021893 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java @@ -109,8 +109,7 @@ public void run() // Ensure the portal color is unique (not already in use), otherwise correct it. PortalColors.correctPortalColor(dimConfig, OTG.getDimensionsConfig().getAllDimensions()); - if(JEID) { - } else { + if (!JEID) { ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { From eca392698fe4eca6cd7cd1ea270859d3a02b3741 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 22:39:47 -0500 Subject: [PATCH 16/27] Revert "fixed more stuff" This reverts commit 7f0bd579b46c608e1f7af5e8ae7c1ce5e85bf8b3. --- .../src/main/java/com/pg85/otg/OTGEngine.java | 18 ++++++++--------- .../otg/network/ServerConfigProvider.java | 20 +++++++++---------- .../biomes/ForgeBiomeRegistryManager.java | 7 +++---- .../forge/events/client/ClientFogHandler.java | 2 +- .../gui/dimensions/OTGGuiDimensionList.java | 20 +++++++++++++------ .../packets/CreateDeleteDimensionPacket.java | 3 ++- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/OTGEngine.java b/common/src/main/java/com/pg85/otg/OTGEngine.java index f045845de..f1baa82b0 100644 --- a/common/src/main/java/com/pg85/otg/OTGEngine.java +++ b/common/src/main/java/com/pg85/otg/OTGEngine.java @@ -34,7 +34,7 @@ public abstract class OTGEngine { - private HashMap> otgBiomeIdsByWorld = new HashMap>(); + private HashMap otgBiomeIdsByWorld = new HashMap(); private BiomeModeManager biomeManagers; private List cancelableEventHandlers = new ArrayList(5); private BiomeResourcesManager biomeResourcesManager; @@ -304,29 +304,29 @@ public void setOTGBiomeId(String worldName, int i, BiomeConfig biomeConfig, bool { if(!otgBiomeIdsByWorld.containsKey(worldName)) { - otgBiomeIdsByWorld.put(worldName, new ArrayList<>()); + otgBiomeIdsByWorld.put(worldName, new BiomeConfig[999999]); } - if(replaceExisting || otgBiomeIdsByWorld.get(worldName).get(i) == null) + if(replaceExisting || otgBiomeIdsByWorld.get(worldName)[i] == null) { - otgBiomeIdsByWorld.get(worldName).set(i, biomeConfig); + otgBiomeIdsByWorld.get(worldName)[i] = biomeConfig; } else { - throw new RuntimeException("Tried to register OTG biome " + biomeConfig.getName() + " with id " + i + " but the id is in use by biome " + otgBiomeIdsByWorld.get(worldName).get(i).getName() + ". OTG 1.12.2 v7 and above use dynamic biome id's for new worlds, this avoids the problem completely."); + throw new RuntimeException("Tried to register OTG biome " + biomeConfig.getName() + " with id " + i + " but the id is in use by biome " + otgBiomeIdsByWorld.get(worldName)[i].getName() + ". OTG 1.12.2 v7 and above use dynamic biome id's for new worlds, this avoids the problem completely."); } } - public ArrayList getOTGBiomeIds(String worldName) + public BiomeConfig[] getOTGBiomeIds(String worldName) { - return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new ArrayList(); + return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new BiomeConfig[999999]; } public boolean isOTGBiomeIdAvailable(String worldName, int i) { - return !otgBiomeIdsByWorld.containsKey(worldName) || otgBiomeIdsByWorld.get(worldName).get(i) == null; + return !otgBiomeIdsByWorld.containsKey(worldName) || otgBiomeIdsByWorld.get(worldName)[i] == null; } public void unregisterOTGBiomeId(String worldName, int i) { - otgBiomeIdsByWorld.get(worldName).set(i, null); + otgBiomeIdsByWorld.get(worldName)[i] = null; } // Materials diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 350fa4b11..6c26a404a 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -533,7 +533,7 @@ public int compare(BiomeConfig a, BiomeConfig b) { { OTG.getEngine().setOTGBiomeId(world.getName(), biomeIdData.otgBiomeId, biomeConfig, false); } - else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName()).get(biomeIdData.otgBiomeId).getName()).equals(biomeIdData.biomeName)) + else if((world.getName() + "_" + OTG.getEngine().getOTGBiomeIds(world.getName())[biomeIdData.otgBiomeId].getName()).equals(biomeIdData.biomeName)) { OTG.getEngine().setOTGBiomeId(world.getName(), biomeIdData.otgBiomeId, biomeConfig, true); } else { @@ -569,15 +569,15 @@ else if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName loadedBiomeNames.append(biomeConfig.getName()); loadedBiomeNames.append(", "); - ArrayList otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); + BiomeConfig[] otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); int otgBiomeId = -1; // Exclude already registered biomes from loadedBiomeIdData / default biomes boolean bFound = false; - for(int i = 0; i < otgIds2.size(); i++) + for(int i = 0; i < otgIds2.length; i++) { - BiomeConfig biomeConfig2 = otgIds2.get(i); + BiomeConfig biomeConfig2 = otgIds2[i]; if(biomeConfig == biomeConfig2) { bFound = true; @@ -603,9 +603,9 @@ else if( if(otgBiomeId == -1) { // Find the next available id - for (int i = 0; i < otgIds2.size(); i++) // Virtual (replacetobiomename) biomes can only have id's above 255 + for (int i = 0; i < otgIds2.length; i++) // Virtual (replacetobiomename) biomes can only have id's above 255 { - if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (otgIds2.size() - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).size())) { + if ((biomeConfig.replaceToBiomeName.isEmpty() && (i > (otgIds2.length - 1 ))) || (biomeConfig.replaceToBiomeName.isEmpty() && i >= OTG.getEngine().getOTGBiomeIds(world.getName()).length)) { OTG.log(LogMarker.FATAL, "Biome could not be registered, no free biome id's!"); throw new RuntimeException("Biome could not be registered, no free biome id's!"); } @@ -685,10 +685,10 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi // Get the assigned OTG biome id int otgBiomeId = -1; - ArrayList otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); - for(int i = 0; i < otgIds2.size(); i++) + BiomeConfig[] otgIds2 = OTG.getEngine().getOTGBiomeIds(world.getName()); + for(int i = 0; i < otgIds2.length; i++) { - if(otgIds2.get(i) == biomeConfig) + if(otgIds2[i] == biomeConfig) { otgBiomeId = i; break; @@ -752,7 +752,7 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi * @param counter Simple recursion counter to make sure it doesn't endlessly recurse * @return The saved ID of a registered biome */ - private int findSavedBiomeId(BiomeConfig biomeConfig, ArrayList configArray, int counter) { + private int findSavedBiomeId(BiomeConfig biomeConfig, BiomeConfig[] configArray, int counter) { if (counter > 100) { OTG.log(LogMarker.FATAL, "Failed to replace, recursion went deeper than 100 layers. Did you create a replace loop at "+biomeConfig.replaceToBiomeName+"?"); throw new RuntimeException("Failed to replace, recursion went deeper than 100 layers. Did you create a replace loop at "+biomeConfig.replaceToBiomeName+"?"); diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index b4680c7a1..f2d9b70f6 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -145,16 +145,15 @@ else if(biomeIds.getSavedId() > -1) // Always try to register biomes and create Biome Configs. Biomes with id's > 255 are registered // only for biome -> id queries, any (saved)id -> biome query will return the ReplaceToBiomeName biome. - Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); + Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); - String errorText = "Could not allocate the requested id " + biomeIds.getSavedId() + " for biome "; if(JEID) { if (biomeIds.getSavedId() < 0) { - throw new RuntimeException(errorText + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); } } else { if (biomeIds.getSavedId() >= 256 || biomeIds.getSavedId() < 0) { - throw new RuntimeException(errorText + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java b/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java index 19d984560..f3abc8f5e 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/events/client/ClientFogHandler.java @@ -404,7 +404,7 @@ private BiomeConfig getBiomeConfig(ForgeWorld world, int x, int z, MutableBlockP short cachedId = biomeCache[x][z]; if (cachedId != -1 && !hasMoved) { - return OTG.getEngine().getOTGBiomeIds(world.getName()).get(cachedId); + return OTG.getEngine().getOTGBiomeIds(world.getName())[cachedId]; } else { Biome biome = world.getBiomeFromChunk(blockPos.getX(), blockPos.getZ()); LocalBiome localBiome = biome != null ? world.getBiomeByNameOrNull(biome.getBiomeName()) : null; diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java index d32e84df3..5a630cdb9 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java @@ -483,18 +483,17 @@ protected void actionPerformed(GuiButton button) throws IOException } } } - String preset = this.dimensions.get(0).PresetName; if(!bPortalColorsUnique) { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Multiple dimensions are using the same portal color, each dimension's portal color must be unique.")); } else if (JEID) { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, preset)); + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); } else { if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); } else { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, preset)); + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); } } } else { @@ -527,7 +526,7 @@ else if (JEID) { { ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); - if (OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames) || JEID) { + if (JEID) { dimConfig.isNewConfig = false; OTG.IsNewWorldBeingCreated = true; if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { @@ -535,8 +534,17 @@ else if (JEID) { } OTG.IsNewWorldBeingCreated = false; } else { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); - break; + if (OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + dimConfig.isNewConfig = false; + OTG.IsNewWorldBeingCreated = true; + if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Dimension id " + dimConfig.DimensionId + " was taken.")); + } + OTG.IsNewWorldBeingCreated = false; + } else { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); + break; + } } } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java index 47c021893..12974d6e0 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java @@ -109,7 +109,8 @@ public void run() // Ensure the portal color is unique (not already in use), otherwise correct it. PortalColors.correctPortalColor(dimConfig, OTG.getDimensionsConfig().getAllDimensions()); - if (!JEID) { + if(JEID) { + } else { ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { From 56b524c51aa93b2d3ee991f3a3c011305cc46c5f Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 22:52:37 -0500 Subject: [PATCH 17/27] working correctly now --- .../src/main/java/com/pg85/otg/OTGEngine.java | 4 +-- .../biomes/ForgeBiomeRegistryManager.java | 13 ++++------ .../gui/dimensions/OTGGuiDimensionList.java | 25 +++++-------------- .../packets/CreateDeleteDimensionPacket.java | 7 +++--- .../com/pg85/otg/forge/world/ForgeWorld.java | 15 +++-------- 5 files changed, 20 insertions(+), 44 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/OTGEngine.java b/common/src/main/java/com/pg85/otg/OTGEngine.java index f1baa82b0..be79101df 100644 --- a/common/src/main/java/com/pg85/otg/OTGEngine.java +++ b/common/src/main/java/com/pg85/otg/OTGEngine.java @@ -304,7 +304,7 @@ public void setOTGBiomeId(String worldName, int i, BiomeConfig biomeConfig, bool { if(!otgBiomeIdsByWorld.containsKey(worldName)) { - otgBiomeIdsByWorld.put(worldName, new BiomeConfig[999999]); + otgBiomeIdsByWorld.put(worldName, new BiomeConfig[1024]); } if(replaceExisting || otgBiomeIdsByWorld.get(worldName)[i] == null) { @@ -316,7 +316,7 @@ public void setOTGBiomeId(String worldName, int i, BiomeConfig biomeConfig, bool public BiomeConfig[] getOTGBiomeIds(String worldName) { - return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new BiomeConfig[999999]; + return otgBiomeIdsByWorld.containsKey(worldName) ? otgBiomeIdsByWorld.get(worldName) : new BiomeConfig[1024]; } public boolean isOTGBiomeIdAvailable(String worldName, int i) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index f2d9b70f6..80dcfcce3 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -147,14 +147,11 @@ else if(biomeIds.getSavedId() > -1) Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); - if(JEID) { - if (biomeIds.getSavedId() < 0) { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); - } - } else { - if (biomeIds.getSavedId() >= 256 || biomeIds.getSavedId() < 0) { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); - } + if (JEID && biomeIds.getSavedId() < 0) { + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); + } + else if (biomeIds.getSavedId() >= 256) { + throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); } ForgeBiome forgeBiome = new ForgeBiome(biome, biomeConfig, biomeIds); diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java index 5a630cdb9..f78eacbcb 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/gui/dimensions/OTGGuiDimensionList.java @@ -487,14 +487,10 @@ protected void actionPerformed(GuiButton button) throws IOException { this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Multiple dimensions are using the same portal color, each dimension's portal color must be unique.")); } - else if (JEID) { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); + if (!JEID && !OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); } else { - if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); - } else { - this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); - } + this.mc.displayGuiScreen(new OTGGuiEnterWorldName(this, this.dimensions.get(0).PresetName)); } } else { @@ -526,7 +522,7 @@ else if (JEID) { { ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); - if (JEID) { + if (JEID || OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { dimConfig.isNewConfig = false; OTG.IsNewWorldBeingCreated = true; if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { @@ -534,17 +530,8 @@ else if (JEID) { } OTG.IsNewWorldBeingCreated = false; } else { - if (OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { - dimConfig.isNewConfig = false; - OTG.IsNewWorldBeingCreated = true; - if (!OTGDimensionManager.createNewDimensionSP(dimConfig, this.mc.getIntegratedServer())) { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Dimension id " + dimConfig.DimensionId + " was taken.")); - } - OTG.IsNewWorldBeingCreated = false; - } else { - this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); - break; - } + this.mc.displayGuiScreen(new GuiErrorScreen("Error", "Not enough biome id's available to add all dimensions.")); + break; } } } diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java index 12974d6e0..9768bb108 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java @@ -109,17 +109,16 @@ public void run() // Ensure the portal color is unique (not already in use), otherwise correct it. PortalColors.correctPortalColor(dimConfig, OTG.getDimensionsConfig().getAllDimensions()); - if(JEID) { - } else { + ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); - if (!OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + if (!JEID || !OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { // Update the UI on the client ServerPacketManager.sendDimensionSynchPacketToAllPlayers(player.getServer()); OTG.log(LogMarker.INFO, "Warning: Client tried to create a dimension, but not enough biome id's are available."); return; } - } + long seed = (new Random()).nextLong(); String sSeed = dimConfig.Seed; if (sSeed != null && !StringUtils.isEmpty(sSeed)) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java index 31bf0f577..720b60d6e 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/world/ForgeWorld.java @@ -508,22 +508,15 @@ public void unRegisterBiomes() } @Override - public int getMaxBiomesCount() { - if(JEID){ - return 999999; - } else { - return MAX_BIOMES_COUNT; - } + public int getMaxBiomesCount() + { + return MAX_BIOMES_COUNT; } @Override public int getMaxSavedBiomesCount() { - if(JEID){ - return 640000; - } else { - return MAX_SAVED_BIOMES_COUNT; - } + return MAX_SAVED_BIOMES_COUNT; } // Chunks From d35ffd316638de44f169212eb1210364fdd3590a Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 23:01:12 -0500 Subject: [PATCH 18/27] changed one JEID check --- .../pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index 80dcfcce3..c35e0d3b7 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -147,10 +147,9 @@ else if(biomeIds.getSavedId() > -1) Biome existingBiome = Biome.getBiome(biomeIds.getSavedId()); - if (JEID && biomeIds.getSavedId() < 0) { - throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". a biome id under 0 have been allocated\n" + ". Please report this to JEID issue tracker."); - } - else if (biomeIds.getSavedId() >= 256) { + + + if (!JEID && biomeIds.getSavedId() < 0 && biomeIds.getSavedId() >= 256) { throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); } From 4c211b164df76f85b35d43ae3dcdfa6c1a8b35f1 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 23:08:40 -0500 Subject: [PATCH 19/27] changed an || to a && in a JEID check --- .../network/client/packets/CreateDeleteDimensionPacket.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java index 9768bb108..2c06d490c 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/network/client/packets/CreateDeleteDimensionPacket.java @@ -112,7 +112,7 @@ public void run() ArrayList presetNames = new ArrayList(); presetNames.add(dimConfig.PresetName); - if (!JEID || !OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { + if (!JEID && !OTG.getEngine().areEnoughBiomeIdsAvailableForPresets(presetNames)) { // Update the UI on the client ServerPacketManager.sendDimensionSynchPacketToAllPlayers(player.getServer()); OTG.log(LogMarker.INFO, "Warning: Client tried to create a dimension, but not enough biome id's are available."); From 839e46ff285875bd6905cc7323c3658b0a247958 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Wed, 15 Sep 2021 23:22:38 -0500 Subject: [PATCH 20/27] fixed another check --- .../com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java index c35e0d3b7..713f6b8f0 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/biomes/ForgeBiomeRegistryManager.java @@ -149,7 +149,7 @@ else if(biomeIds.getSavedId() > -1) - if (!JEID && biomeIds.getSavedId() < 0 && biomeIds.getSavedId() >= 256) { + if (!JEID && (biomeIds.getSavedId() < 0 || biomeIds.getSavedId() >= 256)) { throw new RuntimeException("Could not allocate the requested id " + biomeIds.getSavedId() + " for biome " + biomeConfig.getName() + ". All available id's under 256 have been allocated\n" + ". To proceed, adjust your WorldConfig or use the ReplaceToBiomeName feature to make the biome virtual."); } From 42508e92f12ddccb3e35d01d5d1ad5d0787714bc Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Thu, 16 Sep 2021 20:45:17 -0500 Subject: [PATCH 21/27] fixed command stuff and add isVirtual to a few places --- .../java/com/pg85/otg/network/ClientConfigProvider.java | 2 +- .../java/com/pg85/otg/network/ServerConfigProvider.java | 2 +- common/src/main/java/com/pg85/otg/util/BiomeIds.java | 6 ++++-- .../main/java/com/pg85/otg/forge/commands/BiomeCommand.java | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index fe39a3805..aa7ef1dfc 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -90,7 +90,7 @@ public ClientConfigProvider(DataInputStream stream, LocalWorld world) throws IOE BiomeLoadInstruction instruction = new BiomeLoadInstruction(biomeName, defaultSettings); BiomeConfig config = new BiomeConfig(instruction, null, biomeReader, worldConfig); - LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId), this, false); + LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, !config.replaceToBiomeName.isEmpty()), this, false); biomesByOTGId[otgBiomeId] = biome; if(savedBiomeId == otgBiomeId || BiomeRegistryNames.getRegistryNameForDefaultBiome(biomeName) != null) // Non-virtual and default biomes only { diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 6c26a404a..bc4dd99ad 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -710,7 +710,7 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi } // Create biome - LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId), this, isReload); + LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()), this, isReload); this.biomesByOTGId[biome.getIds().getOTGBiomeId()] = biome; diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index bc300e442..9a526ce97 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -16,6 +16,7 @@ public class BiomeIds { private int otgBiomeId; private int savedId; + private boolean isVirtual; /** * Creates a new virtual biome id. @@ -24,10 +25,11 @@ public class BiomeIds * @param savedId The id used in the world save files (the .mca files in * the region directory). */ - public BiomeIds(int otgBiomeId, int savedId) + public BiomeIds(int otgBiomeId, int savedId, boolean isVirtual) { this.otgBiomeId = otgBiomeId; this.savedId = savedId; + this.isVirtual = isVirtual; } /** @@ -39,7 +41,7 @@ public BiomeIds(int otgBiomeId, int savedId) */ public boolean isVirtual() { - return otgBiomeId != savedId; + return this.isVirtual; } /** diff --git a/platforms/forge/src/main/java/com/pg85/otg/forge/commands/BiomeCommand.java b/platforms/forge/src/main/java/com/pg85/otg/forge/commands/BiomeCommand.java index f7fbeedc7..e4ed837fc 100644 --- a/platforms/forge/src/main/java/com/pg85/otg/forge/commands/BiomeCommand.java +++ b/platforms/forge/src/main/java/com/pg85/otg/forge/commands/BiomeCommand.java @@ -66,7 +66,7 @@ public boolean onCommand(ICommandSender sender, List args) { try { - String savedBiomeName = world.getSavedBiomeName(x, y); + String savedBiomeName = world.getSavedBiomeName(x, z); sender.sendMessage(new TextComponentString("")); sender.sendMessage( new TextComponentTranslation(MESSAGE_COLOR + "According to the world save files, you are in the " + VALUE_COLOR + savedBiomeName + MESSAGE_COLOR + " biome, with id " + VALUE_COLOR + biome.getIds().getSavedId())); From c8f4e7e3ef47b199f2f6fb61e0ac259451ea3fd8 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Thu, 16 Sep 2021 21:11:40 -0500 Subject: [PATCH 22/27] fixed a build error on bukkit's side --- .../src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java b/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java index a560ab09a..0e103f0b0 100644 --- a/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java +++ b/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java @@ -23,7 +23,7 @@ private BukkitBiome(BiomeConfig biomeConfig, BiomeBase biome) { this.biomeBase = biome; int savedBiomeId = BiomeBase.a(biomeBase); - this.biomeIds = new BiomeIds(WorldHelper.getOTGBiomeId(biomeBase), savedBiomeId); + this.biomeIds = new BiomeIds(WorldHelper.getOTGBiomeId(biomeBase), savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()); this.biomeConfig = biomeConfig; this.isCustom = biome instanceof OTGBiomeBase; } From 676757d503de5896172bb20ff253d50ce750170a Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Fri, 17 Sep 2021 03:14:59 -0500 Subject: [PATCH 23/27] added null checks for replaceToBiomeName --- .../otg/network/ClientConfigProvider.java | 15 +++-- .../otg/network/ServerConfigProvider.java | 55 ++++++++++--------- .../pg85/otg/bukkit/biomes/BukkitBiome.java | 6 +- 3 files changed, 42 insertions(+), 34 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index aa7ef1dfc..cf98eb900 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -89,12 +89,15 @@ public ClientConfigProvider(DataInputStream stream, LocalWorld world) throws IOE BiomeLoadInstruction instruction = new BiomeLoadInstruction(biomeName, defaultSettings); BiomeConfig config = new BiomeConfig(instruction, null, biomeReader, worldConfig); - - LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, !config.replaceToBiomeName.isEmpty()), this, false); - biomesByOTGId[otgBiomeId] = biome; - if(savedBiomeId == otgBiomeId || BiomeRegistryNames.getRegistryNameForDefaultBiome(biomeName) != null) // Non-virtual and default biomes only - { - biomesBySavedId[savedBiomeId] = biome; + if(config.replaceToBiomeName != null) { + LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, !config.replaceToBiomeName.isEmpty()), this, false); + biomesByOTGId[otgBiomeId] = biome; + if(savedBiomeId == otgBiomeId || BiomeRegistryNames.getRegistryNameForDefaultBiome(biomeName) != null) // Non-virtual and default biomes only + { + biomesBySavedId[savedBiomeId] = biome; + } + } else { + throw new IllegalStateException("biomeConfig.replaceToBiomeName was null"); } OTG.getEngine().setOTGBiomeId(world.getName(), otgBiomeId, config, true); diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index bc4dd99ad..9f6b0d2cd 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -710,41 +710,42 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi } // Create biome - LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()), this, isReload); - - this.biomesByOTGId[biome.getIds().getOTGBiomeId()] = biome; - - // Indexing ReplacedBlocks - if (!this.worldConfig.biomeConfigsHaveReplacement) - { - this.worldConfig.biomeConfigsHaveReplacement = biomeConfig.replacedBlocks.hasReplaceSettings(); - } - biomeConfig.replacedBlocks.parseForWorld(this.world); + if (biomeConfig.replaceToBiomeName != null) { + LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()), this, isReload); + this.biomesByOTGId[biome.getIds().getOTGBiomeId()] = biome; + // Indexing ReplacedBlocks + if (!this.worldConfig.biomeConfigsHaveReplacement) + { + this.worldConfig.biomeConfigsHaveReplacement = biomeConfig.replacedBlocks.hasReplaceSettings(); + } + biomeConfig.replacedBlocks.parseForWorld(this.world); - // Indexing MaxSmoothRadius - if (this.worldConfig.maxSmoothRadius < biomeConfig.smoothRadius) - { - this.worldConfig.maxSmoothRadius = biomeConfig.smoothRadius; - } + // Indexing MaxSmoothRadius + if (this.worldConfig.maxSmoothRadius < biomeConfig.smoothRadius) + { + this.worldConfig.maxSmoothRadius = biomeConfig.smoothRadius; + } - if (this.worldConfig.maxSmoothRadius < biomeConfig.CHCSmoothRadius) - { - this.worldConfig.maxSmoothRadius = biomeConfig.CHCSmoothRadius; - } + if (this.worldConfig.maxSmoothRadius < biomeConfig.CHCSmoothRadius) + { + this.worldConfig.maxSmoothRadius = biomeConfig.CHCSmoothRadius; + } // Indexing BiomeColor - if (this.worldConfig.biomeMode == OTG.getBiomeModeManager().FROM_IMAGE) - { - if (this.worldConfig.biomeColorMap == null) + if (this.worldConfig.biomeMode == OTG.getBiomeModeManager().FROM_IMAGE) { - this.worldConfig.biomeColorMap = new HashMap(); - } + if (this.worldConfig.biomeColorMap == null) + { + this.worldConfig.biomeColorMap = new HashMap(); + } - int color = biomeConfig.biomeColor; - this.worldConfig.biomeColorMap.put(color, biome.getIds().getOTGBiomeId()); + int color = biomeConfig.biomeColor; + this.worldConfig.biomeColorMap.put(color, biome.getIds().getOTGBiomeId()); + } + } else { + throw new IllegalStateException("biomeConfig.replaceToBiomeName was null"); } } - /** Recursive method to get saved ID from ReplaceToBiomeName, allows chain replacing to virtual biomes. * * @param biomeConfig The biomeconfig we want to find the saved ID for diff --git a/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java b/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java index 0e103f0b0..00ba333f9 100644 --- a/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java +++ b/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java @@ -23,7 +23,11 @@ private BukkitBiome(BiomeConfig biomeConfig, BiomeBase biome) { this.biomeBase = biome; int savedBiomeId = BiomeBase.a(biomeBase); - this.biomeIds = new BiomeIds(WorldHelper.getOTGBiomeId(biomeBase), savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()); + if(biomeConfig.replaceToBiomeName != null) { + this.biomeIds = new BiomeIds(WorldHelper.getOTGBiomeId(biomeBase), savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()); + } else { + throw new IllegalStateException("biomeConfig.replaceToBiomeName was null"); + } this.biomeConfig = biomeConfig; this.isCustom = biome instanceof OTGBiomeBase; } From 9d3a483979b068b7d701efb6af3981c449f0a36a Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Fri, 17 Sep 2021 03:43:51 -0500 Subject: [PATCH 24/27] fixed checks and made isVirtual static for a check --- .../otg/network/ClientConfigProvider.java | 16 ++++++---------- .../otg/network/ServerConfigProvider.java | 19 ++++++------------- .../main/java/com/pg85/otg/util/BiomeIds.java | 8 ++++---- .../pg85/otg/bukkit/biomes/BukkitBiome.java | 6 +----- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index cf98eb900..3ad10678e 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -89,17 +89,13 @@ public ClientConfigProvider(DataInputStream stream, LocalWorld world) throws IOE BiomeLoadInstruction instruction = new BiomeLoadInstruction(biomeName, defaultSettings); BiomeConfig config = new BiomeConfig(instruction, null, biomeReader, worldConfig); - if(config.replaceToBiomeName != null) { - LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, !config.replaceToBiomeName.isEmpty()), this, false); - biomesByOTGId[otgBiomeId] = biome; - if(savedBiomeId == otgBiomeId || BiomeRegistryNames.getRegistryNameForDefaultBiome(biomeName) != null) // Non-virtual and default biomes only - { - biomesBySavedId[savedBiomeId] = biome; - } - } else { - throw new IllegalStateException("biomeConfig.replaceToBiomeName was null"); + LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, config.replaceToBiomeName != null && !config.replaceToBiomeName.isEmpty()), this, false); + biomesByOTGId[otgBiomeId] = biome; + if (!BiomeIds.isVirtual()) // Non-virtual and default biomes only + { + biomesBySavedId[savedBiomeId] = biome; } - + OTG.getEngine().setOTGBiomeId(world.getName(), otgBiomeId, config, true); } } diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 9f6b0d2cd..232ca44ef 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -714,36 +714,29 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()), this, isReload); this.biomesByOTGId[biome.getIds().getOTGBiomeId()] = biome; // Indexing ReplacedBlocks - if (!this.worldConfig.biomeConfigsHaveReplacement) - { + if (!this.worldConfig.biomeConfigsHaveReplacement) { this.worldConfig.biomeConfigsHaveReplacement = biomeConfig.replacedBlocks.hasReplaceSettings(); } biomeConfig.replacedBlocks.parseForWorld(this.world); // Indexing MaxSmoothRadius - if (this.worldConfig.maxSmoothRadius < biomeConfig.smoothRadius) - { + if (this.worldConfig.maxSmoothRadius < biomeConfig.smoothRadius) { this.worldConfig.maxSmoothRadius = biomeConfig.smoothRadius; } - if (this.worldConfig.maxSmoothRadius < biomeConfig.CHCSmoothRadius) - { + if (this.worldConfig.maxSmoothRadius < biomeConfig.CHCSmoothRadius) { this.worldConfig.maxSmoothRadius = biomeConfig.CHCSmoothRadius; } - // Indexing BiomeColor - if (this.worldConfig.biomeMode == OTG.getBiomeModeManager().FROM_IMAGE) - { - if (this.worldConfig.biomeColorMap == null) - { + // Indexing BiomeColor + if (this.worldConfig.biomeMode == OTG.getBiomeModeManager().FROM_IMAGE) { + if (this.worldConfig.biomeColorMap == null) { this.worldConfig.biomeColorMap = new HashMap(); } int color = biomeConfig.biomeColor; this.worldConfig.biomeColorMap.put(color, biome.getIds().getOTGBiomeId()); } - } else { - throw new IllegalStateException("biomeConfig.replaceToBiomeName was null"); } } /** Recursive method to get saved ID from ReplaceToBiomeName, allows chain replacing to virtual biomes. diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index 9a526ce97..f326c57db 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -16,7 +16,7 @@ public class BiomeIds { private int otgBiomeId; private int savedId; - private boolean isVirtual; + private static boolean isVirtual; /** * Creates a new virtual biome id. @@ -29,7 +29,7 @@ public BiomeIds(int otgBiomeId, int savedId, boolean isVirtual) { this.otgBiomeId = otgBiomeId; this.savedId = savedId; - this.isVirtual = isVirtual; + BiomeIds.isVirtual = isVirtual; } /** @@ -39,9 +39,9 @@ public BiomeIds(int otgBiomeId, int savedId, boolean isVirtual) * * @return True if the biome is virtual, false otherwise. */ - public boolean isVirtual() + public static boolean isVirtual() { - return this.isVirtual; + return BiomeIds.isVirtual; } /** diff --git a/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java b/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java index 00ba333f9..c45d60daf 100644 --- a/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java +++ b/platforms/bukkit/src/main/java/com/pg85/otg/bukkit/biomes/BukkitBiome.java @@ -23,11 +23,7 @@ private BukkitBiome(BiomeConfig biomeConfig, BiomeBase biome) { this.biomeBase = biome; int savedBiomeId = BiomeBase.a(biomeBase); - if(biomeConfig.replaceToBiomeName != null) { - this.biomeIds = new BiomeIds(WorldHelper.getOTGBiomeId(biomeBase), savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()); - } else { - throw new IllegalStateException("biomeConfig.replaceToBiomeName was null"); - } + this.biomeIds = new BiomeIds(WorldHelper.getOTGBiomeId(biomeBase), savedBiomeId,biomeConfig.replaceToBiomeName != null && !biomeConfig.replaceToBiomeName.isEmpty()); this.biomeConfig = biomeConfig; this.isCustom = biome instanceof OTGBiomeBase; } From 3746e08d84365945123f9903f01cf9689910e482 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Fri, 17 Sep 2021 03:55:50 -0500 Subject: [PATCH 25/27] hopefully fixed a check --- .../java/com/pg85/otg/network/ClientConfigProvider.java | 2 +- common/src/main/java/com/pg85/otg/util/BiomeIds.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index 3ad10678e..e02c39d86 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -91,7 +91,7 @@ public ClientConfigProvider(DataInputStream stream, LocalWorld world) throws IOE BiomeConfig config = new BiomeConfig(instruction, null, biomeReader, worldConfig); LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, config.replaceToBiomeName != null && !config.replaceToBiomeName.isEmpty()), this, false); biomesByOTGId[otgBiomeId] = biome; - if (!BiomeIds.isVirtual()) // Non-virtual and default biomes only + if (!(config.replaceToBiomeName != null && config.replaceToBiomeName.trim().length() > 0)) // Non-virtual and default biomes only { biomesBySavedId[savedBiomeId] = biome; } diff --git a/common/src/main/java/com/pg85/otg/util/BiomeIds.java b/common/src/main/java/com/pg85/otg/util/BiomeIds.java index f326c57db..9a526ce97 100644 --- a/common/src/main/java/com/pg85/otg/util/BiomeIds.java +++ b/common/src/main/java/com/pg85/otg/util/BiomeIds.java @@ -16,7 +16,7 @@ public class BiomeIds { private int otgBiomeId; private int savedId; - private static boolean isVirtual; + private boolean isVirtual; /** * Creates a new virtual biome id. @@ -29,7 +29,7 @@ public BiomeIds(int otgBiomeId, int savedId, boolean isVirtual) { this.otgBiomeId = otgBiomeId; this.savedId = savedId; - BiomeIds.isVirtual = isVirtual; + this.isVirtual = isVirtual; } /** @@ -39,9 +39,9 @@ public BiomeIds(int otgBiomeId, int savedId, boolean isVirtual) * * @return True if the biome is virtual, false otherwise. */ - public static boolean isVirtual() + public boolean isVirtual() { - return BiomeIds.isVirtual; + return this.isVirtual; } /** From 1e889eff0f777a7e5eb081deb1414c290d23c0f3 Mon Sep 17 00:00:00 2001 From: Mysticpasta1 Date: Fri, 17 Sep 2021 04:29:11 -0500 Subject: [PATCH 26/27] fixed two more checks --- .../otg/network/ClientConfigProvider.java | 2 +- .../otg/network/ServerConfigProvider.java | 44 +++++++++---------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java index e02c39d86..890979786 100644 --- a/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ClientConfigProvider.java @@ -91,7 +91,7 @@ public ClientConfigProvider(DataInputStream stream, LocalWorld world) throws IOE BiomeConfig config = new BiomeConfig(instruction, null, biomeReader, worldConfig); LocalBiome biome = world.createBiomeFor(config, new BiomeIds(otgBiomeId, savedBiomeId, config.replaceToBiomeName != null && !config.replaceToBiomeName.isEmpty()), this, false); biomesByOTGId[otgBiomeId] = biome; - if (!(config.replaceToBiomeName != null && config.replaceToBiomeName.trim().length() > 0)) // Non-virtual and default biomes only + if (!(config.replaceToBiomeName != null && config.replaceToBiomeName.trim().length() > 0) || BiomeRegistryNames.getRegistryNameForDefaultBiome(biomeName) != null) // Non-virtual and default biomes only { biomesBySavedId[savedBiomeId] = biome; } diff --git a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java index 232ca44ef..17231d3d0 100644 --- a/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java +++ b/common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java @@ -710,33 +710,31 @@ private void createAndRegisterBiome(ArrayList loadedBiomeIdData, Bi } // Create biome - if (biomeConfig.replaceToBiomeName != null) { - LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId, !biomeConfig.replaceToBiomeName.isEmpty()), this, isReload); - this.biomesByOTGId[biome.getIds().getOTGBiomeId()] = biome; - // Indexing ReplacedBlocks - if (!this.worldConfig.biomeConfigsHaveReplacement) { - this.worldConfig.biomeConfigsHaveReplacement = biomeConfig.replacedBlocks.hasReplaceSettings(); - } - biomeConfig.replacedBlocks.parseForWorld(this.world); - - // Indexing MaxSmoothRadius - if (this.worldConfig.maxSmoothRadius < biomeConfig.smoothRadius) { - this.worldConfig.maxSmoothRadius = biomeConfig.smoothRadius; - } + LocalBiome biome = world.createBiomeFor(biomeConfig, new BiomeIds(otgBiomeId, savedBiomeId, biomeConfig.replaceToBiomeName != null && !biomeConfig.replaceToBiomeName.isEmpty()), this, isReload); + this.biomesByOTGId[biome.getIds().getOTGBiomeId()] = biome; + // Indexing ReplacedBlocks + if (!this.worldConfig.biomeConfigsHaveReplacement) { + this.worldConfig.biomeConfigsHaveReplacement = biomeConfig.replacedBlocks.hasReplaceSettings(); + } + biomeConfig.replacedBlocks.parseForWorld(this.world); - if (this.worldConfig.maxSmoothRadius < biomeConfig.CHCSmoothRadius) { - this.worldConfig.maxSmoothRadius = biomeConfig.CHCSmoothRadius; - } + // Indexing MaxSmoothRadius + if (this.worldConfig.maxSmoothRadius < biomeConfig.smoothRadius) { + this.worldConfig.maxSmoothRadius = biomeConfig.smoothRadius; + } - // Indexing BiomeColor - if (this.worldConfig.biomeMode == OTG.getBiomeModeManager().FROM_IMAGE) { - if (this.worldConfig.biomeColorMap == null) { - this.worldConfig.biomeColorMap = new HashMap(); - } + if (this.worldConfig.maxSmoothRadius < biomeConfig.CHCSmoothRadius) { + this.worldConfig.maxSmoothRadius = biomeConfig.CHCSmoothRadius; + } - int color = biomeConfig.biomeColor; - this.worldConfig.biomeColorMap.put(color, biome.getIds().getOTGBiomeId()); + // Indexing BiomeColor + if (this.worldConfig.biomeMode == OTG.getBiomeModeManager().FROM_IMAGE) { + if (this.worldConfig.biomeColorMap == null) { + this.worldConfig.biomeColorMap = new HashMap(); } + + int color = biomeConfig.biomeColor; + this.worldConfig.biomeColorMap.put(color, biome.getIds().getOTGBiomeId()); } } /** Recursive method to get saved ID from ReplaceToBiomeName, allows chain replacing to virtual biomes. From ebdc63cc764c44fffaa33f67b0159568a8692d15 Mon Sep 17 00:00:00 2001 From: SXRWahrheit Date: Mon, 14 Mar 2022 13:21:17 -0500 Subject: [PATCH 27/27] Create CONTRIBUTING.md --- CONTRIBUTING.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..8b5cf9e15 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,44 @@ +Contribution to OpenTerrainGenerator +----------------------- + +Please talk to us on Discord @ https://discord.gg/UXzdVTH prior to contributing. + +## Signing + +Please sign [the Contributor License Agreement](https://cla-assistant.io/PG85/OpenTerrainGenerator). + +## Pull Requests + +For pull requests: +- You MUST: own the code you submit OR it must be free/open/safe to use (like code in the public domain). Code gathered from within any open source OpenTerrainGenerator project is valid to include here as well. + - If your code is under any pre-existing license, you MUST note it in the pull request. + - It is preferred that you contribute code that you own the rights to (generally, original code that you have written) rather than code licensed from another project. +- Any and all code you submit is subject to the mini-license below. +- In general, you should confirm your PR is functional in any ways that it may vary. + - For example, if your code adds an NMS call, it should be tested for the version of the branch it is submitted to. +- USUALLY, your pull request should fix an open issue or feature request made in a Discord thread. + - If there is no issue or thread for it, please open a thread. +- Team OTG reserves the right to refuse Pull Requests for any reason, although reasonable efforts will be made to accommodate appropriate requests. + +## Code Style / Formatting + +Match the general format/style of existing code within the project. Additional details on conventions will be added to this document. + +## Mini-license pre-warning + +By contributing to the project, you give up all rights to your contribution\*. + +If you later decide you don't want us using your code - you may make a polite request and it will be treated as such, but that is the extent of your abilities. + +\* This does not include your rights to continue making use of any involved code yourself, which you of course may continue to do. You give up specifically your rights to the contribution *within this project*. Or to put it another way: your rights to the specific copy of the contribution that is now contained within this project, as specifically opposed to ideas and/or expressions thereof within the code or other work contributed, which you remain free to do with as you wish (excluding actions that conflict with our ownership of the copy given to us). + +### You agree by contributing: + +- That you have read and agree to this document. +- To not attempt to "revoke rights to your code" or any similar action. +- That you have the right to publicly contribute any assets/code given. No contributing someone else's code without their permission. +- That the code submitted is either your own work, dedicated now to this project, OR it is under a license specified directly in the contribution. + +### Contribution guidelines adaptation + +These contribution guidelines have been adapted from the [Denizen Contribution Guidelines](https://github.com/DenizenScript/Denizen/blob/release/CONTRIBUTING.md) and are provided under the [MIT License](https://github.com/DenizenScript/Denizen/tree/release) used by both Denizen and OpenTerrainGenerator.