Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.12.2 jeid #1000

Open
wants to merge 30 commits into
base: 1.12-OTG+
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f246795
fixed compat with JEID by running check for it
Mysticpasta1 Sep 13, 2021
ef29ebc
remove unnecessary part of a check and fixed spacing
Mysticpasta1 Sep 14, 2021
7de2aff
virtual biomes not working yet but saving changes so far
Mysticpasta1 Sep 14, 2021
87e1c4f
working with virtual biome now
Mysticpasta1 Sep 14, 2021
e338177
fixed id error with Dry Savannah
Mysticpasta1 Sep 14, 2021
231f380
fixed more stuff with virtual biomes
Mysticpasta1 Sep 14, 2021
670cb61
checking for errors
Mysticpasta1 Sep 15, 2021
699be3f
fix the -1 bug once and for all
Mysticpasta1 Sep 15, 2021
977585a
fixed quick error when loading biomes
Mysticpasta1 Sep 15, 2021
ee21b16
fix a check with empty and null in the same line
Mysticpasta1 Sep 15, 2021
84fbc19
fixed more checks and increased a couple of more values
Mysticpasta1 Sep 15, 2021
e651f6c
ok fixed even more values and added some more checks for JEID
Mysticpasta1 Sep 15, 2021
013f8e1
added one last check for JEID
Mysticpasta1 Sep 15, 2021
f269734
changed Integer.MAX_VALUE to 640000 int
Mysticpasta1 Sep 15, 2021
7300fc6
Merge pull request #872 from Mysticpasta1/1.12-OTG+
PG85 Sep 15, 2021
7f0bd57
fixed more stuff
Mysticpasta1 Sep 16, 2021
eca3926
Revert "fixed more stuff"
Mysticpasta1 Sep 16, 2021
56b524c
working correctly now
Mysticpasta1 Sep 16, 2021
d35ffd3
changed one JEID check
Mysticpasta1 Sep 16, 2021
4c211b1
changed an || to a && in a JEID check
Mysticpasta1 Sep 16, 2021
839e46f
fixed another check
Mysticpasta1 Sep 16, 2021
c5c424d
Merge pull request #875 from Mysticpasta1/1.12-OTG+
PG85 Sep 16, 2021
42508e9
fixed command stuff and add isVirtual to a few places
Mysticpasta1 Sep 17, 2021
c8f4e7e
fixed a build error on bukkit's side
Mysticpasta1 Sep 17, 2021
676757d
added null checks for replaceToBiomeName
Mysticpasta1 Sep 17, 2021
9d3a483
fixed checks and made isVirtual static for a check
Mysticpasta1 Sep 17, 2021
3746e08
hopefully fixed a check
Mysticpasta1 Sep 17, 2021
1e889ef
fixed two more checks
Mysticpasta1 Sep 17, 2021
6a29aba
Merge pull request #876 from Mysticpasta1/1.12-OTG+
PG85 Sep 17, 2021
ebdc63c
Create CONTRIBUTING.md
SXRWahrheit Mar 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,13 @@ 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 != null && !config.replaceToBiomeName.isEmpty()), this, false);
biomesByOTGId[otgBiomeId] = biome;
if(savedBiomeId == otgBiomeId || BiomeRegistryNames.getRegistryNameForDefaultBiome(biomeName) != null) // 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;
biomesBySavedId[savedBiomeId] = biome;
}

OTG.getEngine().setOTGBiomeId(world.getName(), otgBiomeId, config, true);
}
}
Expand Down
112 changes: 45 additions & 67 deletions common/src/main/java/com/pg85/otg/network/ServerConfigProvider.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -34,7 +26,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.
Expand All @@ -53,7 +44,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;

Expand Down Expand Up @@ -468,8 +459,7 @@ private String indexSettings(Map<String, Integer> worldBiomes, boolean isNewWorl
loadedBiomeIdData.add(
new BiomeIdData(
world.getName() + "_" + worldBiome.getKey(),
worldBiome.getValue(),
worldBiome.getValue() > 255 || (
worldBiome.getValue(), (
biomeConfig.replaceToBiomeName != null &&
biomeConfig.replaceToBiomeName.trim().length() > 0
) ? -1 : worldBiome.getValue()
Expand Down Expand Up @@ -552,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 < 256)
if(biomeIdData.otgBiomeId > -1 && !(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0))
{
if(biomeConfig.replaceToBiomeName != null && 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(biomeIdData.otgBiomeId > 255)
else if(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0)
{
virtualBiomesExisting.add(biomeConfig);
}
Expand All @@ -573,16 +563,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++)
Expand All @@ -591,7 +581,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(
Expand All @@ -609,33 +599,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 = 0; i < otgIds2.length; 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)) {
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 && !(biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0)) {
nonVirtualBiomes.add(biomeConfig);
} else if (biomeConfig.replaceToBiomeName != null && biomeConfig.replaceToBiomeName.trim().length() > 0) {
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.
Expand Down Expand Up @@ -725,41 +710,33 @@ private void createAndRegisterBiome(ArrayList<BiomeIdData> 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 != null && !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)
{
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) {
if (this.worldConfig.biomeColorMap == null) {
this.worldConfig.biomeColorMap = new HashMap<Integer, Integer>();
}

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.
*
* @param biomeConfig The biomeconfig we want to find the saved ID for
Expand Down Expand Up @@ -801,8 +778,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 && id <= 255) {

int id = getRequestedSavedId(biomeConfig.replaceToBiomeName);
if (id > -1 && (biomeConfig.replaceToBiomeName == null || biomeConfig.replaceToBiomeName.trim().length() == 0)) {
// It has a valid ID, let's just return that
return id;
}
Expand All @@ -821,8 +799,8 @@ public List<LocalBiome> getBiomeArrayLegacy()
{
// For backwards compatibility, sort the biomes by saved id and return default biomes as if they were custom biomes
List<LocalBiome> nonDefaultbiomes = new ArrayList<LocalBiome>();
LocalBiome[] defaultBiomes = new LocalBiome[256];
for(LocalBiome biome : this.biomesByOTGId)
LocalBiome[] defaultBiomes = new LocalBiome[256];
for(LocalBiome biome : this.biomesByOTGId)
{
if(biome != null)
{
Expand Down
10 changes: 8 additions & 2 deletions common/src/main/java/com/pg85/otg/util/BiomeIds.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.pg85.otg.util;

import com.pg85.otg.configuration.biome.BiomeConfig;

import java.util.Random;

/**
* Immutable class to hold the biome ids of a biome.
* <p>
Expand All @@ -12,6 +16,7 @@ public class BiomeIds
{
private int otgBiomeId;
private int savedId;
private boolean isVirtual;

/**
* Creates a new virtual biome id.
Expand All @@ -20,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;
}

/**
Expand All @@ -35,7 +41,7 @@ public BiomeIds(int otgBiomeId, int savedId)
*/
public boolean isVirtual()
{
return otgBiomeId > 255;
return this.isVirtual;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 != null && !biomeConfig.replaceToBiomeName.isEmpty());
this.biomeConfig = biomeConfig;
this.isCustom = biome instanceof OTGBiomeBase;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -199,7 +201,10 @@ public boolean isModLoaded(String mod)
@Override
public boolean areEnoughBiomeIdsAvailableForPresets(ArrayList<String> presetNames)
{
if(presetNames == null)
if(JEID) {
return true;
}
if(presetNames == null)
{
return true;
}
Expand Down
Loading