Merge pull request #149 from paulevsGitch/main

Code update
This commit is contained in:
paulevsGitch 2022-06-02 17:53:30 +03:00 committed by GitHub
commit 8940a405f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 70 additions and 32 deletions

View file

@ -11,7 +11,7 @@ loader_version= 0.13.3
fabric_version = 0.48.0+1.18.2
# Mod Properties
mod_version = 1.4.6
mod_version = 1.5.0
maven_group = ru.bclib
archives_base_name = bclib

View file

@ -55,10 +55,6 @@ public class PostInitAPI {
* @param isClient {@code boolean}, {@code true} for client, {@code false} for server.
*/
public static void postInit(boolean isClient) {
if (postInitFunctions == null) {
return;
}
postInitFunctions.forEach(function -> function.accept(isClient));
Registry.BLOCK.forEach(block -> {
processBlockCommon(block);
if (isClient) {
@ -66,11 +62,15 @@ public class PostInitAPI {
}
});
Registry.ITEM.forEach(item -> {
processItemCommon(item);
});
postInitFunctions = null;
if (postInitFunctions != null) {
postInitFunctions.forEach(function -> function.accept(isClient));
postInitFunctions = null;
}
blockTags = null;
itemTags = null;
BiomeAPI.loadFabricAPIBiomes();

View file

@ -430,19 +430,28 @@ public class BiomeAPI {
public static void loadFabricAPIBiomes() {
FabricBiomesData.NETHER_BIOMES.forEach((key) -> {
if (!hasBiome(key.location())) {
registerNetherBiome(BuiltinRegistries.BIOME.get(key));
Optional<Holder<Biome>> optional = BuiltinRegistries.BIOME.getHolder(key);
if (optional.isPresent()) {
registerNetherBiome(optional.get().value());
}
}
});
FabricBiomesData.END_LAND_BIOMES.forEach((key, weight) -> {
if (!hasBiome(key.location())) {
registerEndLandBiome(BuiltinRegistries.BIOME.getHolder(key).orElseThrow(), weight);
Optional<Holder<Biome>> optional = BuiltinRegistries.BIOME.getHolder(key);
if (optional.isPresent()) {
registerEndLandBiome(optional.get(), weight);
}
}
});
FabricBiomesData.END_VOID_BIOMES.forEach((key, weight) -> {
if (!hasBiome(key.location())) {
registerEndVoidBiome(BuiltinRegistries.BIOME.getOrCreateHolder(key), weight);
Optional<Holder<Biome>> optional = BuiltinRegistries.BIOME.getHolder(key);
if (optional.isPresent()) {
registerEndVoidBiome(optional.get(), weight);
}
}
});
}

View file

@ -0,0 +1,6 @@
package ru.bclib.interfaces;
public interface FrozableRegistry {
void setFrozeState(boolean frozen);
boolean getFrozeState();
}

View file

@ -0,0 +1,22 @@
package ru.bclib.mixin.common;
import net.minecraft.core.MappedRegistry;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import ru.bclib.interfaces.FrozableRegistry;
@Mixin(MappedRegistry.class)
public class MappedRegistryMixin<T> implements FrozableRegistry {
@Shadow
private boolean frozen;
@Override
public void setFrozeState(boolean frozen) {
this.frozen = frozen;
}
@Override
public boolean getFrozeState() {
return this.frozen;
}
}

View file

@ -33,7 +33,7 @@ public class BCLRecipeManager {
list.sort((v1, v2) -> {
boolean b1 = v1.getId().getNamespace().equals(MINECRAFT);
boolean b2 = v2.getId().getNamespace().equals(MINECRAFT);
return b1 ^ b2 ? (b1 ? 1 : -1) : 0;
return b1 ^ b2 ? (b1 ? 1 : -1) : v1.getId().compareTo(v2.getId());
});
return ImmutableList.copyOf(list);
});

View file

@ -4,7 +4,23 @@ import net.minecraft.world.level.biome.Biome;
import ru.bclib.config.Configs;
public class BCLBiomeSettings {
public static Builder createBCL(){
float terrainHeight;
float fogDensity;
float genChance;
int edgeSize;
boolean vertical;
BCLBiome edge;
protected BCLBiomeSettings() {
this.terrainHeight = 0.1F;
this.fogDensity = 1.0F;
this.genChance = 1.0F;
this.edgeSize = 0;
this.vertical = false;
this.edge = null;
}
public static Builder createBCL() {
return new Builder();
}
@ -13,9 +29,10 @@ public class BCLBiomeSettings {
super(new BCLBiomeSettings());
}
}
public static class CommonBuilder<T extends BCLBiomeSettings, R extends CommonBuilder>{
private final T storage;
CommonBuilder(T storage){
CommonBuilder(T storage) {
this.storage = storage;
}
@ -92,23 +109,6 @@ public class BCLBiomeSettings {
}
}
protected BCLBiomeSettings(){
this.terrainHeight = 0.1F;
this.fogDensity = 1.0F;
this.genChance = 1.0F;
this.edgeSize = 0;
this.vertical = false;
this.edge = null;
}
float terrainHeight;
float fogDensity;
float genChance;
int edgeSize;
boolean vertical;
BCLBiome edge;
/**
* Getter for biome generation chance, used in {@link ru.bclib.world.generator.BiomePicker} and in custom generators.
* @return biome generation chance as float.

View file

@ -38,7 +38,7 @@
"title.bclib.syncfiles.modlist": "Mod Information",
"message.bclib.syncfiles.modlist": "The following shows the state of your installed installed Mods.\n\nAll Mods that do not exist locally, or have a different version on the Server will be synchronized.",
"title.bclib.modmissmatch": "Mod Version Conflict",
"message.bclib.modmissmatch": "Some Mods on this client do not match the version of Mods on the Server.\n\nMismatching Mods can result in odd game behavior or crashes. Please make sue that you use the same mods as the server.",
"message.bclib.modmissmatch": "Some Mods on this client do not match the version of Mods on the Server.\n\nMismatching Mods can result in odd game behavior or crashes. Please make sure that you use the same mods as the server.",
"message.bclib.datafixer.progress.waitbackup": "Waiting for Backup to finish. This may take a while!",
"message.bclib.datafixer.progress.reading": "Reading Data",
@ -57,4 +57,4 @@
"title.config.bclib.client.rendering.netherThickFog": "Nether Thick Fog",
"tooltip.bclib.place_on": "Survives on: %s"
}
}

View file

@ -30,6 +30,7 @@
"BlockBehaviourMixin",
"BlockStateBaseMixin",
"ChunkGeneratorMixin",
"MappedRegistryMixin",
"WorldGenRegionMixin",
"DiggerItemAccessor",
"DimensionTypeMixin",