1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Added biome maps for existing resources

This commit is contained in:
TheBusyBiscuit 2021-12-08 18:36:53 +01:00
parent 074571ac22
commit 4ba36a7dab
9 changed files with 176 additions and 99 deletions

View File

@ -27,7 +27,7 @@ import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
* @author TheBusyBiscuit
*
*/
abstract class SlimefunResource implements GEOResource {
abstract class AbstractResource implements GEOResource {
private final NamespacedKey key;
private final String defaultName;
@ -36,7 +36,7 @@ abstract class SlimefunResource implements GEOResource {
private final boolean geoMiner;
@ParametersAreNonnullByDefault
SlimefunResource(String key, String defaultName, ItemStack item, int maxDeviation, boolean geoMiner) {
AbstractResource(String key, String defaultName, ItemStack item, int maxDeviation, boolean geoMiner) {
Validate.notNull(key, "NamespacedKey cannot be null!");
Validate.notNull(defaultName, "The default name cannot be null!");
Validate.notNull(item, "item cannot be null!");
@ -81,14 +81,14 @@ abstract class SlimefunResource implements GEOResource {
* a resource file.
*
* @param resource
* The {@link SlimefunResource} instance
* The {@link AbstractResource} instance
* @param path
* The path to our biome map file
*
* @return A {@link BiomeMap} for this resource
*/
@ParametersAreNonnullByDefault
static final @Nonnull BiomeMap<Integer> getBiomeMap(SlimefunResource resource, String path) {
static final @Nonnull BiomeMap<Integer> getBiomeMap(AbstractResource resource, String path) {
Validate.notNull(resource, "Resource cannot be null");
Validate.notNull(path, "Path cannot be null");

View File

@ -5,6 +5,7 @@ import org.bukkit.block.Biome;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
/**
* A {@link GEOResource} which consists of nether ice.
@ -13,15 +14,25 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
* @author TheBusyBiscuit
*
*/
class NetherIceResource extends SlimefunResource {
class NetherIceResource extends AbstractResource {
private static final int DEFAULT_NETHER_VALUE = 32;
private final BiomeMap<Integer> biomes;
NetherIceResource() {
super("nether_ice", "Nether Ice", SlimefunItems.NETHER_ICE, 6, true);
biomes = getBiomeMap(this, "/biome-maps/nether_ice.json");
}
@Override
public int getDefaultSupply(Environment environment, Biome biome) {
return environment == Environment.NETHER ? 32 : 0;
if (environment != Environment.NETHER) {
return 0;
} else {
return biomes.getOrDefault(biome, DEFAULT_NETHER_VALUE);
}
}
}

View File

@ -7,6 +7,7 @@ import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
/**
* A {@link GEOResource} which consists of buckets of Oil.
@ -18,70 +19,24 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
* @see OilPump
*
*/
class OilResource extends SlimefunResource {
class OilResource extends AbstractResource {
private static final int DEFAULT_OVERWORLD_VALUE = 10;
private final BiomeMap<Integer> biomes;
OilResource() {
super("oil", "Oil", SlimefunItems.OIL_BUCKET, 8, false);
biomes = getBiomeMap(this, "/biome-maps/oil.json");
}
@Override
public int getDefaultSupply(Environment environment, Biome biome) {
if (environment != Environment.NORMAL) {
return 0;
}
switch (biome) {
case SNOWY_BEACH:
case STONE_SHORE:
case BEACH:
return 6;
case DESERT:
case DESERT_HILLS:
case DESERT_LAKES:
return 45;
case MOUNTAINS:
case GRAVELLY_MOUNTAINS:
case MOUNTAIN_EDGE:
case RIVER:
return 17;
case SNOWY_MOUNTAINS:
case SNOWY_TUNDRA:
case ICE_SPIKES:
case FROZEN_OCEAN:
case FROZEN_RIVER:
return 14;
case BADLANDS:
case BADLANDS_PLATEAU:
case WOODED_BADLANDS_PLATEAU:
case ERODED_BADLANDS:
case MODIFIED_BADLANDS_PLATEAU:
case MODIFIED_WOODED_BADLANDS_PLATEAU:
case MUSHROOM_FIELDS:
case MUSHROOM_FIELD_SHORE:
return 24;
case DEEP_OCEAN:
case OCEAN:
case COLD_OCEAN:
case DEEP_COLD_OCEAN:
case DEEP_FROZEN_OCEAN:
case DEEP_LUKEWARM_OCEAN:
case DEEP_WARM_OCEAN:
case LUKEWARM_OCEAN:
case WARM_OCEAN:
return 62;
case SWAMP:
case SWAMP_HILLS:
return 20;
default:
return 10;
} else {
return biomes.getOrDefault(biome, DEFAULT_OVERWORLD_VALUE);
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.block.Biome;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
/**
* A {@link GEOResource} which consists of Salt.
@ -12,48 +13,28 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
* @author TheBusyBiscuit
*
*/
class SaltResource extends SlimefunResource {
class SaltResource extends AbstractResource {
private static final int DEFAULT_OVERWORLD_VALUE = 6;
private static final int DEFAULT_NETHER_VALUE = 8;
private final BiomeMap<Integer> biomes;
SaltResource() {
super("salt", "Salt", SlimefunItems.SALT, 18, true);
biomes = getBiomeMap(this, "/biome-maps/salt.json");
}
@Override
public int getDefaultSupply(Environment environment, Biome biome) {
if (environment != Environment.NORMAL) {
if (environment == Environment.NORMAL) {
return biomes.getOrDefault(biome, DEFAULT_OVERWORLD_VALUE);
} else if (environment == Environment.NETHER) {
return biomes.getOrDefault(biome, DEFAULT_NETHER_VALUE);
} else {
return 0;
}
switch (biome) {
case SNOWY_BEACH:
case STONE_SHORE:
case BEACH:
case DESERT_LAKES:
case RIVER:
case ICE_SPIKES:
case FROZEN_RIVER:
return 40;
case DEEP_OCEAN:
case OCEAN:
case COLD_OCEAN:
case DEEP_COLD_OCEAN:
case DEEP_FROZEN_OCEAN:
case DEEP_LUKEWARM_OCEAN:
case DEEP_WARM_OCEAN:
case FROZEN_OCEAN:
case LUKEWARM_OCEAN:
case WARM_OCEAN:
return 60;
case SWAMP:
case SWAMP_HILLS:
return 20;
default:
return 6;
}
}
}

View File

@ -5,6 +5,7 @@ import org.bukkit.block.Biome;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap;
/**
* A {@link GEOResource} which consists of small chunks of Uranium.
@ -12,19 +13,25 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
* @author TheBusyBiscuit
*
*/
class UraniumResource extends SlimefunResource {
class UraniumResource extends AbstractResource {
private static final int DEFAULT_OVERWORLD_VALUE = 4;
private final BiomeMap<Integer> biomes;
UraniumResource() {
super("uranium", "Small Chunks of Uranium", SlimefunItems.SMALL_URANIUM, 2, true);
biomes = getBiomeMap(this, "/biome-maps/uranium.json");
}
@Override
public int getDefaultSupply(Environment environment, Biome biome) {
if (environment == Environment.NORMAL) {
return 5;
if (environment != Environment.NORMAL) {
return 0;
} else {
return biomes.getOrDefault(biome, DEFAULT_OVERWORLD_VALUE);
}
return 0;
}
}

View File

@ -0,0 +1,2 @@
[
]

View File

@ -0,0 +1,89 @@
[
{
"value" : 6,
"biomes" : [
"minecraft:beach",
"minecraft:stone_shore"
]
},
{
"value" : 16,
"biomes" : [
"minecraft:river"
]
},
{
"value" : 20,
"biomes" : [
"minecraft:swamp",
"minecraft:swamp_hills"
]
},
{
"value" : 24,
"biomes" : [
"minecraft:ice_spikes",
"minecraft:frozen_ocean",
"minecraft:frozen_river"
]
},
{
"value" : 40,
"biomes" : [
"minecraft:badlands",
"minecraft:badlands_plateau",
"minecraft:wooded_badlands_plateau",
"minecraft:eroded_badlands",
"minecraft:modified_badlands_plateau",
"minecraft:modified_wooded_badlands_plateau"
]
},
{
"value" : 45,
"biomes" : [
"minecraft:desert",
"minecraft:desert_hills",
"minecraft:desert_lakes"
]
},
{
"value" : 64,
"biomes" : [
"minecraft:ocean",
"minecraft:cold_ocean",
"minecraft:warm_ocean",
"minecraft:lukewarm_ocean"
]
},
{
"value" : 72,
"biomes" : [
"minecraft:deep_ocean",
"minecraft:deep_cold_ocean",
"minecraft:deep_warm_ocean",
"minecraft:deep_lukewarm_ocean"
]
},
{
"value" : 20,
"biomes" : [
"minecraft:mountains",
"minecraft:gravelly_mountains",
"minecraft:mountain_edge"
]
},
{
"value" : 16,
"biomes" : [
"minecraft:snowy_mountains",
"minecraft:snowy_tundra"
]
},
{
"value" : 20,
"biomes" : [
"minecraft:mushroom_fields",
"minecraft:mushroom_field_shore"
]
}
]

View File

@ -0,0 +1,30 @@
[
{
"value" : 20,
"biomes" : [
"minecraft:swamp",
"minecraft:swamp_hills"
]
},
{
"value" : 40,
"biomes" : [
"minecraft:beach",
"minecraft:gravelly_mountains",
"minecraft:stone_shore"
]
},
{
"value" : 60,
"biomes" : [
"minecraft:ocean",
"minecraft:cold_ocean",
"minecraft:warm_ocean",
"minecraft:lukewarm_ocean",
"minecraft:deep_ocean",
"minecraft:deep_cold_ocean",
"minecraft:deep_warm_ocean",
"minecraft:deep_lukewarm_ocean"
]
}
]

View File

@ -0,0 +1,2 @@
[
]