Code style changes, entities fixes

This commit is contained in:
paulevsGitch 2021-07-08 00:21:47 +03:00
parent 9d604b2d25
commit 44962e18b6
377 changed files with 5038 additions and 4914 deletions

View file

@ -1,17 +1,10 @@
package ru.betterend.registry;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
import net.fabricmc.fabric.impl.biome.WeightedBiomePicker;
import net.minecraft.core.Registry;
@ -60,26 +53,32 @@ import ru.betterend.world.biome.land.UmbrellaJungleBiome;
import ru.betterend.world.generator.BiomeType;
import ru.betterend.world.generator.GeneratorOptions;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class EndBiomes {
public static final Set<ResourceLocation> FABRIC_VOID = Sets.newHashSet();
private static final Set<ResourceLocation> SUBBIOMES_UNMUTABLES = Sets.newHashSet();
public static final BiomePicker LAND_BIOMES = new BiomePicker();
public static final BiomePicker VOID_BIOMES = new BiomePicker();
public static final BiomePicker CAVE_BIOMES = new BiomePicker();
public static final List<BCLBiome> SUBBIOMES = Lists.newArrayList();
private static final JsonObject EMPTY_JSON = new JsonObject();
private static BiomeMap caveBiomeMap;
// Vanilla Land
public static final EndBiome END = registerBiome(Biomes.THE_END, BiomeType.LAND, 1F);
public static final EndBiome END_MIDLANDS = registerSubBiome(Biomes.END_MIDLANDS, END, 0.5F);
public static final EndBiome END_HIGHLANDS = registerSubBiome(Biomes.END_HIGHLANDS, END, 0.5F);
// Vanilla Void
public static final EndBiome END_BARRENS = registerBiome(Biomes.END_BARRENS, BiomeType.VOID, 1F);
public static final EndBiome SMALL_END_ISLANDS = registerBiome(Biomes.SMALL_END_ISLANDS, BiomeType.VOID, 1);
// Better End Land
public static final EndBiome FOGGY_MUSHROOMLAND = registerBiome(new FoggyMushroomlandBiome(), BiomeType.LAND);
public static final EndBiome CHORUS_FOREST = registerBiome(new ChorusForestBiome(), BiomeType.LAND);
@ -98,10 +97,10 @@ public class EndBiomes {
public static final EndBiome DRY_SHRUBLAND = registerBiome(new DryShrublandBiome(), BiomeType.LAND);
public static final EndBiome LANTERN_WOODS = registerBiome(new LanternWoodsBiome(), BiomeType.LAND);
public static final EndBiome NEON_OASIS = registerSubBiome(new NeonOasisBiome(), DUST_WASTELANDS);
// Better End Void
public static final EndBiome ICE_STARFIELD = registerBiome(new BiomeIceStarfield(), BiomeType.VOID);
// Better End Caves
public static final EndCaveBiome EMPTY_END_CAVE = registerCaveBiome(new EmptyEndCaveBiome());
public static final EndCaveBiome EMPTY_SMARAGDANT_CAVE = registerCaveBiome(new EmptySmaragdantCaveBiome());
@ -109,28 +108,28 @@ public class EndBiomes {
public static final EndCaveBiome EMPTY_AURORA_CAVE = registerCaveBiome(new EmptyAuroraCaveBiome());
public static final EndCaveBiome LUSH_AURORA_CAVE = registerCaveBiome(new LushAuroraCaveBiome());
public static final EndCaveBiome JADE_CAVE = registerCaveBiome(new JadeCaveBiome());
public static void register() {
CAVE_BIOMES.rebuild();
}
public static void onWorldLoad(long seed) {
if (caveBiomeMap == null || caveBiomeMap.getSeed() != seed) {
caveBiomeMap = new BiomeMap(seed, GeneratorOptions.getBiomeSizeCaves(), CAVE_BIOMES);
}
}
public static void mutateRegistry(Registry<Biome> biomeRegistry) {
LAND_BIOMES.clearMutables();
VOID_BIOMES.clearMutables();
CAVE_BIOMES.clearMutables();
if (FABRIC_VOID.isEmpty()) {
loadFabricAPIBiomes();
}
Map<String, JsonObject> configs = Maps.newHashMap();
biomeRegistry.forEach((biome) -> {
if (biome.getBiomeCategory() == BiomeCategory.THEEND) {
ResourceLocation id = biomeRegistry.getKey(biome);
@ -171,30 +170,30 @@ public class EndBiomes {
}
});
Configs.BIOME_CONFIG.saveChanges();
rebuildPicker(LAND_BIOMES, biomeRegistry);
rebuildPicker(VOID_BIOMES, biomeRegistry);
rebuildPicker(CAVE_BIOMES, biomeRegistry);
SUBBIOMES.forEach((endBiome) -> {
endBiome.updateActualBiomes(biomeRegistry);
});
}
private static void rebuildPicker(BiomePicker picker, Registry<Biome> biomeRegistry) {
picker.rebuild();
picker.getBiomes().forEach((endBiome) -> {
endBiome.updateActualBiomes(biomeRegistry);
});
}
private static void loadFabricAPIBiomes() {
List<ResourceKey<Biome>> biomes = Lists.newArrayList();
biomes.addAll(getBiomes(InternalBiomeData.getEndBiomesMap().get(Biomes.SMALL_END_ISLANDS)));
biomes.addAll(getBiomes(InternalBiomeData.getEndBarrensMap().get(Biomes.END_BARRENS)));
biomes.forEach((key) -> FABRIC_VOID.add(key.location()));
FABRIC_VOID.removeIf(id -> id.getNamespace().equals("endplus"));
if (BCLib.isDevEnvironment()) {
System.out.println("==================================");
System.out.println("Added void biomes from Fabric API:");
@ -204,12 +203,12 @@ public class EndBiomes {
System.out.println("==================================");
}
}
private static List<ResourceKey<Biome>> getBiomes(WeightedBiomePicker picker) {
IBiomeList biomeList = (IBiomeList) (Object) picker;
return biomeList == null ? Collections.emptyList() : biomeList.getBiomes();
}
private static JsonObject loadJsonConfig(String namespace) {
InputStream inputstream = EndBiomes.class.getResourceAsStream("/data/" + namespace + "/end_biome_properties.json");
if (inputstream != null) {
@ -219,24 +218,26 @@ public class EndBiomes {
return EMPTY_JSON;
}
}
/**
* Registers new {@link EndBiome} and adds it to picker, can be used to add existing mod biomes into the End.
* @param biome - {@link Biome} instance
* @param type - {@link BiomeType}
*
* @param biome - {@link Biome} instance
* @param type - {@link BiomeType}
* @param genChance - generation chance [0.0F - Infinity]
* @return registered {@link EndBiome}
*/
public static EndBiome registerBiome(Biome biome, BiomeType type, float genChance) {
return registerBiome(biome, type, 1, genChance);
}
/**
* Registers new {@link EndBiome} and adds it to picker, can be used to add existing mod biomes into the End.
* @param biome - {@link Biome} instance
* @param type - {@link BiomeType}
*
* @param biome - {@link Biome} instance
* @param type - {@link BiomeType}
* @param fogDensity - density of fog (def: 1F) [0.0F - Infinity]
* @param genChance - generation chance [0.0F - Infinity]
* @param genChance - generation chance [0.0F - Infinity]
* @return registered {@link EndBiome}
*/
public static EndBiome registerBiome(Biome biome, BiomeType type, float fogDensity, float genChance) {
@ -246,24 +247,26 @@ public class EndBiomes {
}
return endBiome;
}
/**
* Registers new {@link EndBiome} from existed {@link Biome} and put as a sub-biome into selected parent.
* @param biome - {@link Biome} instance
* @param parent - {@link EndBiome} to be linked with
*
* @param biome - {@link Biome} instance
* @param parent - {@link EndBiome} to be linked with
* @param genChance - generation chance [0.0F - Infinity]
* @return registered {@link EndBiome}
*/
public static EndBiome registerSubBiome(Biome biome, EndBiome parent, float genChance, boolean hasCaves) {
return registerSubBiome(biome, parent, 1, genChance, hasCaves);
}
/**
* Registers new {@link EndBiome} from existed {@link Biome} and put as a sub-biome into selected parent.
* @param biome - {@link Biome} instance
* @param parent - {@link EndBiome} to be linked with
*
* @param biome - {@link Biome} instance
* @param parent - {@link EndBiome} to be linked with
* @param fogDensity - density of fog (def: 1F) [0.0F - Infinity]
* @param genChance - generation chance [0.0F - Infinity]
* @param genChance - generation chance [0.0F - Infinity]
* @return registered {@link EndBiome}
*/
public static EndBiome registerSubBiome(Biome biome, EndBiome parent, float fogDensity, float genChance, boolean hasCaves) {
@ -277,10 +280,11 @@ public class EndBiomes {
}
return endBiome;
}
/**
* Put existing {@link EndBiome} as a sub-biome into selected parent.
* @param biome - {@link EndBiome} instance
*
* @param biome - {@link EndBiome} instance
* @param parent - {@link EndBiome} to be linked with
* @return registered {@link EndBiome}
*/
@ -294,11 +298,12 @@ public class EndBiomes {
}
return biome;
}
/**
* Registers {@link EndBiome} and adds it into worldgen.
*
* @param biome - {@link EndBiome} instance
* @param type - {@link BiomeType}
* @param type - {@link BiomeType}
* @return registered {@link EndBiome}
*/
public static EndBiome registerBiome(EndBiome biome, BiomeType type) {
@ -314,9 +319,10 @@ public class EndBiomes {
}
return biome;
}
/**
* Put integration sub-biome {@link EndBiome} into subbiomes list and registers it.
*
* @param biome - {@link EndBiome} instance
* @return registered {@link EndBiome}
*/
@ -329,10 +335,11 @@ public class EndBiomes {
}
return biome;
}
/**
* Link integration sub-biome with parent.
* @param biome - {@link EndBiome} instance
*
* @param biome - {@link EndBiome} instance
* @param parent - {@link ResourceLocation} parent id
*/
public static void addSubBiomeIntegration(EndBiome biome, ResourceLocation parent) {
@ -343,15 +350,15 @@ public class EndBiomes {
}
}
}
public static EndBiome registerBiome(ResourceKey<Biome> key, BiomeType type, float genChance) {
return registerBiome(BuiltinRegistries.BIOME.get(key), type, genChance);
}
public static EndBiome registerSubBiome(ResourceKey<Biome> key, EndBiome parent, float genChance) {
return registerSubBiome(BuiltinRegistries.BIOME.get(key), parent, genChance, true);
}
private static void addToPicker(EndBiome biome, BiomeType type) {
if (type == BiomeType.LAND) {
LAND_BIOMES.addBiome(biome);
@ -360,7 +367,7 @@ public class EndBiomes {
VOID_BIOMES.addBiome(biome);
}
}
public static EndCaveBiome registerCaveBiome(EndCaveBiome biome) {
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
BiomeAPI.registerBiome(biome);
@ -368,7 +375,7 @@ public class EndBiomes {
}
return biome;
}
public static EndCaveBiome getCaveBiome(int x, int z) {
return (EndCaveBiome) caveBiomeMap.getBiome(x, z);
}