Recipe fixes, replaced spaces with tabs

This commit is contained in:
paulevsGitch 2021-12-15 13:08:15 +03:00
parent 5ca6a92dd0
commit d8de624fd1
60 changed files with 1816 additions and 1851 deletions

View file

@ -5,10 +5,10 @@ BCLib is a library mod for BetterX team mods, developed for Fabric, MC 1.18
## Features: ## Features:
### Rendering ### Rendering
* Emissive textures (with _e suffix) * Emissive textures (with _e suffix)
* Can be applied to Solid and Transparent blocks; * Can be applied to Solid and Transparent blocks;
* Can be changed/added with resourcepacks; * Can be changed/added with resourcepacks;
* Incompatible with Sodium and Canvas (just will be not rendered); * Incompatible with Sodium and Canvas (just will be not rendered);
* Incompatible with Iris shaders (Iris without shaders works fine). * Incompatible with Iris shaders (Iris without shaders works fine).
* Procedural block and item models (from paterns or from code); * Procedural block and item models (from paterns or from code);
* Block render interfaces. * Block render interfaces.

View file

@ -3,9 +3,9 @@ buildscript {
classpath 'org.kohsuke:github-api:1.114' classpath 'org.kohsuke:github-api:1.114'
} }
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
} }
} }
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17
@ -15,16 +15,16 @@ version = project.mod_version
group = project.maven_group group = project.maven_group
repositories { repositories {
maven { url "https://maven.dblsaiko.net/" } maven { url "https://maven.dblsaiko.net/" }
maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" } maven { url "https://server.bbkr.space:8081/artifactory/libs-release/" }
maven { url "https://maven.fabricmc.net/" } maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.shedaniel.me/" } maven { url "https://maven.shedaniel.me/" }
maven { url 'https://maven.blamejared.com' } maven { url 'https://maven.blamejared.com' }
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
} }
loom { loom {
accessWidenerPath = file("src/main/resources/bclib.accesswidener") accessWidenerPath = file("src/main/resources/bclib.accesswidener")
} }
dependencies { dependencies {
@ -40,7 +40,7 @@ processResources {
println "Version: ${project.mod_version}" println "Version: ${project.mod_version}"
inputs.property "version", project.mod_version inputs.property "version", project.mod_version
filesMatching("fabric.mod.json") { filesMatching("fabric.mod.json") {
expand "version": project.mod_version expand "version": project.mod_version
} }
} }
@ -50,12 +50,12 @@ processResources {
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.encoding = "UTF-8" options.encoding = "UTF-8"
it.options.release = 17 it.options.release = 17
} }
javadoc { javadoc {
options.tags = [ "reason" ] options.tags = [ "reason" ]
options.stylesheetFile = new File(projectDir, "javadoc.css"); options.stylesheetFile = new File(projectDir, "javadoc.css");
} }
task javadocJar(type: Jar, dependsOn: javadoc) { task javadocJar(type: Jar, dependsOn: javadoc) {
@ -134,12 +134,12 @@ publishing {
} }
configurations { configurations {
dev { dev {
canBeResolved = false canBeResolved = false
canBeConsumed = true canBeConsumed = true
} }
} }
artifacts { artifacts {
dev jar dev jar
} }

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven { maven {
name = 'Fabric' name = 'Fabric'
url = 'https://maven.fabricmc.net/' url = 'https://maven.fabricmc.net/'
} }
gradlePluginPortal() gradlePluginPortal()
} }
} }

View file

@ -72,7 +72,7 @@ public class TagAPI {
* Get or create {@link Tag.Named}. * Get or create {@link Tag.Named}.
* *
* @param containerSupplier - {@link TagCollection} {@link Supplier} tag collection; * @param containerSupplier - {@link TagCollection} {@link Supplier} tag collection;
* @param id - {@link ResourceLocation} tag id. * @param id - {@link ResourceLocation} tag id.
* @return {@link Tag.Named}. * @return {@link Tag.Named}.
*/ */
public static <T> Tag.Named<T> makeTag(Supplier<TagCollection<T>> containerSupplier, ResourceLocation id) { public static <T> Tag.Named<T> makeTag(Supplier<TagCollection<T>> containerSupplier, ResourceLocation id) {
@ -194,7 +194,7 @@ public class TagAPI {
* The call will reserve the Tag. The Tag is added to the blocks once * The call will reserve the Tag. The Tag is added to the blocks once
* {@link #apply(String, Map)} was executed. * {@link #apply(String, Map)} was executed.
* *
* @param tag The new Tag * @param tag The new Tag
* @param blocks One or more blocks that should receive the Tag. * @param blocks One or more blocks that should receive the Tag.
*/ */
public static void addTag(Tag.Named<Block> tag, Block... blocks) { public static void addTag(Tag.Named<Block> tag, Block... blocks) {
@ -282,7 +282,7 @@ public class TagAPI {
* In most cases there is no need to call this Method manually. * In most cases there is no need to call this Method manually.
* *
* @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or * @param directory The name of the Tag-directory. Should be either <i>"tags/blocks"</i> or
* <i>"tags/items"</i>. * <i>"tags/items"</i>.
* @param tagsMap The map that will hold the registered Tags * @param tagsMap The map that will hold the registered Tags
* @return The {@code tagsMap} Parameter. * @return The {@code tagsMap} Parameter.
*/ */

View file

@ -27,8 +27,6 @@ import net.minecraft.world.level.levelgen.GenerationStep;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.Noises; import net.minecraft.world.level.levelgen.Noises;
import net.minecraft.world.level.levelgen.SurfaceRules; import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
import net.minecraft.world.level.levelgen.SurfaceRules.SequenceRuleSource;
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.placement.PlacedFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature;
@ -38,7 +36,6 @@ import ru.bclib.util.ColorUtil;
import ru.bclib.world.biomes.BCLBiome; import ru.bclib.world.biomes.BCLBiome;
import ru.bclib.world.features.BCLFeature; import ru.bclib.world.features.BCLFeature;
import ru.bclib.world.structures.BCLStructureFeature; import ru.bclib.world.structures.BCLStructureFeature;
import ru.bclib.world.surface.DoubleBlockSurfaceNoiseCondition;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

View file

@ -35,7 +35,6 @@ import net.minecraft.world.level.biome.MobSpawnSettings.SpawnerData;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.dimension.DimensionType;
import net.minecraft.world.level.levelgen.GenerationStep.Carving; import net.minecraft.world.level.levelgen.GenerationStep.Carving;
import net.minecraft.world.level.levelgen.GenerationStep.Decoration; import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
@ -68,7 +67,6 @@ import ru.bclib.world.structures.BCLStructureFeature;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -182,7 +180,7 @@ public class BiomeAPI {
Random random = new Random(biome.getID().hashCode()); Random random = new Random(biome.getID().hashCode());
//temperature, humidity, continentalness, erosion, depth, weirdness, offset //temperature, humidity, continentalness, erosion, depth, weirdness, offset
Climate.ParameterPoint parameters = Climate.parameters( Climate.ParameterPoint parameters = Climate.parameters(
MHelper.randRange(-1.5F, 1.5F, random), MHelper.randRange(-1.5F, 1.5F, random),
MHelper.randRange(-1.5F, 1.5F, random), MHelper.randRange(-1.5F, 1.5F, random),
MHelper.randRange(-1.5F, 1.5F, random), //new in 1.18 MHelper.randRange(-1.5F, 1.5F, random), //new in 1.18

View file

@ -111,7 +111,7 @@ public class DataExchangeAPI extends DataExchange {
/** /**
* Registers a File for automatic client syncing. * Registers a File for automatic client syncing.
* *
* @param modID The ID of the calling Mod * @param modID The ID of the calling Mod
* @param fileName The name of the File * @param fileName The name of the File
*/ */
public static void addAutoSyncFile(String modID, File fileName) { public static void addAutoSyncFile(String modID, File fileName) {
@ -124,9 +124,9 @@ public class DataExchangeAPI extends DataExchange {
* The file is synced of the {@link SyncFileHash} on client and server are not equal. This method will not copy the * The file is synced of the {@link SyncFileHash} on client and server are not equal. This method will not copy the
* configs content from the client to the server. * configs content from the client to the server.
* *
* @param modID The ID of the calling Mod * @param modID The ID of the calling Mod
* @param uniqueID A unique Identifier for the File. (see {@link SyncFileHash#uniqueID} for * @param uniqueID A unique Identifier for the File. (see {@link SyncFileHash#uniqueID} for
* Details * Details
* @param fileName The name of the File * @param fileName The name of the File
*/ */
public static void addAutoSyncFile(String modID, String uniqueID, File fileName) { public static void addAutoSyncFile(String modID, String uniqueID, File fileName) {
@ -143,8 +143,8 @@ public class DataExchangeAPI extends DataExchange {
* if the File needs to be copied. Normally using the {@link SyncFileHash} * if the File needs to be copied. Normally using the {@link SyncFileHash}
* for comparison is sufficient. * for comparison is sufficient.
* *
* @param modID The ID of the calling Mod * @param modID The ID of the calling Mod
* @param fileName The name of the File * @param fileName The name of the File
* @param needTransfer If the predicate returns true, the file needs to get copied to the server. * @param needTransfer If the predicate returns true, the file needs to get copied to the server.
*/ */
public static void addAutoSyncFile(String modID, File fileName, NeedTransferPredicate needTransfer) { public static void addAutoSyncFile(String modID, File fileName, NeedTransferPredicate needTransfer) {
@ -161,10 +161,10 @@ public class DataExchangeAPI extends DataExchange {
* if the File needs to be copied. Normally using the {@link SyncFileHash} * if the File needs to be copied. Normally using the {@link SyncFileHash}
* for comparison is sufficient. * for comparison is sufficient.
* *
* @param modID The ID of the calling Mod * @param modID The ID of the calling Mod
* @param uniqueID A unique Identifier for the File. (see {@link SyncFileHash#uniqueID} for * @param uniqueID A unique Identifier for the File. (see {@link SyncFileHash#uniqueID} for
* Details * Details
* @param fileName The name of the File * @param fileName The name of the File
* @param needTransfer If the predicate returns true, the file needs to get copied to the server. * @param needTransfer If the predicate returns true, the file needs to get copied to the server.
*/ */
public static void addAutoSyncFile(String modID, String uniqueID, File fileName, NeedTransferPredicate needTransfer) { public static void addAutoSyncFile(String modID, String uniqueID, File fileName, NeedTransferPredicate needTransfer) {

View file

@ -16,93 +16,93 @@ import java.util.Objects;
* identical. * identical.
*/ */
public class SyncFileHash extends AutoSyncID { public class SyncFileHash extends AutoSyncID {
public final FileHash hash; public final FileHash hash;
SyncFileHash(String modID, File file, byte[] md5, int size, int value) { SyncFileHash(String modID, File file, byte[] md5, int size, int value) {
this(modID, file.getName(), md5, size, value); this(modID, file.getName(), md5, size, value);
} }
SyncFileHash(String modID, String uniqueID, byte[] md5, int size, int value) { SyncFileHash(String modID, String uniqueID, byte[] md5, int size, int value) {
this(modID, uniqueID, new FileHash(md5, size, value)); this(modID, uniqueID, new FileHash(md5, size, value));
} }
SyncFileHash(String modID, File file, FileHash hash) { SyncFileHash(String modID, File file, FileHash hash) {
this(modID, file.getName(), hash); this(modID, file.getName(), hash);
} }
SyncFileHash(String modID, String uniqueID, FileHash hash) { SyncFileHash(String modID, String uniqueID, FileHash hash) {
super(modID, uniqueID); super(modID, uniqueID);
this.hash = hash; this.hash = hash;
} }
final static NeedTransferPredicate NEED_TRANSFER = (clientHash, serverHash, content)-> !clientHash.equals(serverHash); final static NeedTransferPredicate NEED_TRANSFER = (clientHash, serverHash, content)-> !clientHash.equals(serverHash);
@Override @Override
public String toString() { public String toString() {
return super.toString()+": "+hash.toString(); return super.toString()+": "+hash.toString();
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (!(o instanceof SyncFileHash)) return false; if (!(o instanceof SyncFileHash)) return false;
if (!super.equals(o)) return false; if (!super.equals(o)) return false;
SyncFileHash that = (SyncFileHash) o; SyncFileHash that = (SyncFileHash) o;
return hash.equals(that.hash); return hash.equals(that.hash);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(super.hashCode(), hash); return Objects.hash(super.hashCode(), hash);
} }
/** /**
* Serializes the Object to a buffer * Serializes the Object to a buffer
* @param buf The buffer to write to * @param buf The buffer to write to
*/ */
public void serialize(FriendlyByteBuf buf) { public void serialize(FriendlyByteBuf buf) {
hash.serialize(buf); hash.serialize(buf);
DataHandler.writeString(buf, modID); DataHandler.writeString(buf, modID);
DataHandler.writeString(buf, uniqueID); DataHandler.writeString(buf, uniqueID);
} }
/** /**
*Deserialize a Buffer to a new {@link SyncFileHash}-Object *Deserialize a Buffer to a new {@link SyncFileHash}-Object
* @param buf Thea buffer to read from * @param buf Thea buffer to read from
* @return The received String * @return The received String
*/ */
public static SyncFileHash deserialize(FriendlyByteBuf buf){ public static SyncFileHash deserialize(FriendlyByteBuf buf){
final FileHash hash = FileHash.deserialize(buf); final FileHash hash = FileHash.deserialize(buf);
final String modID = DataHandler.readString(buf); final String modID = DataHandler.readString(buf);
final String uniqueID = DataHandler.readString(buf); final String uniqueID = DataHandler.readString(buf);
return new SyncFileHash(modID, uniqueID, hash); return new SyncFileHash(modID, uniqueID, hash);
} }
/** /**
* Create a new {@link SyncFileHash}. * Create a new {@link SyncFileHash}.
* <p> * <p>
* Will call {@link #create(String, File, String)} using the name of the File as {@code uniqueID}. * Will call {@link #create(String, File, String)} using the name of the File as {@code uniqueID}.
* @param modID ID of the calling Mod * @param modID ID of the calling Mod
* @param file The input file * @param file The input file
* *
* @return A new Instance. You can compare instances using {@link #equals(Object)} to determine if two files are * @return A new Instance. You can compare instances using {@link #equals(Object)} to determine if two files are
* identical. Will return {@code null} when an error occurs or the File does not exist * identical. Will return {@code null} when an error occurs or the File does not exist
*/ */
public static SyncFileHash create(String modID, File file){ public static SyncFileHash create(String modID, File file){
return create(modID, file, file.getName()); return create(modID, file, file.getName());
} }
/** /**
* Create a new {@link SyncFileHash}. * Create a new {@link SyncFileHash}.
* @param modID ID of the calling Mod * @param modID ID of the calling Mod
* @param file The input file * @param file The input file
* @param uniqueID The unique ID that is used for this File (see {@link SyncFileHash#uniqueID} for Details. * @param uniqueID The unique ID that is used for this File (see {@link SyncFileHash#uniqueID} for Details.
* @return A new Instance. You can compare instances using {@link #equals(Object)} to determine if two files are * @return A new Instance. You can compare instances using {@link #equals(Object)} to determine if two files are
* identical. Will return {@code null} when an error occurs or the File does not exist * identical. Will return {@code null} when an error occurs or the File does not exist
*/ */
public static SyncFileHash create(String modID, File file, String uniqueID){ public static SyncFileHash create(String modID, File file, String uniqueID){
return new SyncFileHash(modID, uniqueID, FileHash.create(file)); return new SyncFileHash(modID, uniqueID, FileHash.create(file));
} }
} }

View file

@ -68,15 +68,15 @@ public class AutoSync {
/** /**
* Registers a File for automatic client syncing. * Registers a File for automatic client syncing.
* *
* @param modID The ID of the calling Mod * @param modID The ID of the calling Mod
* @param needTransfer If the predicate returns true, the file needs to get copied to the server. * @param needTransfer If the predicate returns true, the file needs to get copied to the server.
* @param fileName The name of the File * @param fileName The name of the File
* @param requestContent When {@code true} the content of the file is requested for comparison. This will copy the * @param requestContent When {@code true} the content of the file is requested for comparison. This will copy the
* entire file from the client to the server. * entire file from the client to the server.
* <p> * <p>
* You should only use this option, if you need to compare parts of the file in order to decide * You should only use this option, if you need to compare parts of the file in order to decide
* If the File needs to be copied. Normally using the {@link SyncFileHash} * If the File needs to be copied. Normally using the {@link SyncFileHash}
* for comparison is sufficient. * for comparison is sufficient.
*/ */
public static void addAutoSyncFileData(String modID, File fileName, boolean requestContent, NeedTransferPredicate needTransfer) { public static void addAutoSyncFileData(String modID, File fileName, boolean requestContent, NeedTransferPredicate needTransfer) {
if (!PathUtil.isChildOf(PathUtil.GAME_FOLDER, fileName.toPath())){ if (!PathUtil.isChildOf(PathUtil.GAME_FOLDER, fileName.toPath())){
@ -89,17 +89,17 @@ public class AutoSync {
/** /**
* Registers a File for automatic client syncing. * Registers a File for automatic client syncing.
* *
* @param modID The ID of the calling Mod * @param modID The ID of the calling Mod
* @param uniqueID A unique Identifier for the File. (see {@link SyncFileHash#uniqueID} for * @param uniqueID A unique Identifier for the File. (see {@link SyncFileHash#uniqueID} for
* Details * Details
* @param needTransfer If the predicate returns true, the file needs to get copied to the server. * @param needTransfer If the predicate returns true, the file needs to get copied to the server.
* @param fileName The name of the File * @param fileName The name of the File
* @param requestContent When {@code true} the content of the file is requested for comparison. This will copy the * @param requestContent When {@code true} the content of the file is requested for comparison. This will copy the
* entire file from the client to the server. * entire file from the client to the server.
* <p> * <p>
* You should only use this option, if you need to compare parts of the file in order to decide * You should only use this option, if you need to compare parts of the file in order to decide
* If the File needs to be copied. Normally using the {@link SyncFileHash} * If the File needs to be copied. Normally using the {@link SyncFileHash}
* for comparison is sufficient. * for comparison is sufficient.
*/ */
public static void addAutoSyncFileData(String modID, String uniqueID, File fileName, boolean requestContent, NeedTransferPredicate needTransfer) { public static void addAutoSyncFileData(String modID, String uniqueID, File fileName, boolean requestContent, NeedTransferPredicate needTransfer) {
if (!PathUtil.isChildOf(PathUtil.GAME_FOLDER, fileName.toPath())){ if (!PathUtil.isChildOf(PathUtil.GAME_FOLDER, fileName.toPath())){

View file

@ -120,7 +120,7 @@ public class HelloClient extends DataHandler.FromServer {
final boolean canDownload = size>0 && Configs.SERVER_CONFIG.isOfferingMods() && (Configs.SERVER_CONFIG.isOfferingAllMods() || inmods.contains(modID)); final boolean canDownload = size>0 && Configs.SERVER_CONFIG.isOfferingMods() && (Configs.SERVER_CONFIG.isOfferingAllMods() || inmods.contains(modID));
buf.writeBoolean(canDownload); buf.writeBoolean(canDownload);
BCLib.LOGGER.info(" - Listing Mod " + modID + " v" + ver + " (size: " + PathUtil.humanReadableFileSize(size) + ", download="+canDownload+")"); BCLib.LOGGER.info(" - Listing Mod " + modID + " v" + ver + " (size: " + PathUtil.humanReadableFileSize(size) + ", download="+canDownload+")");
} }
} }
else { else {
@ -140,7 +140,7 @@ public class HelloClient extends DataHandler.FromServer {
buf.writeInt(existingAutoSyncFiles.size()); buf.writeInt(existingAutoSyncFiles.size());
for (AutoFileSyncEntry entry : existingAutoSyncFiles) { for (AutoFileSyncEntry entry : existingAutoSyncFiles) {
entry.serialize(buf); entry.serialize(buf);
BCLib.LOGGER.info(" - Offering " + (entry.isConfigFile() ? "Config " : "File ") + entry); BCLib.LOGGER.info(" - Offering " + (entry.isConfigFile() ? "Config " : "File ") + entry);
} }
} }
else { else {
@ -151,7 +151,7 @@ public class HelloClient extends DataHandler.FromServer {
if (Configs.SERVER_CONFIG.isOfferingFiles()) { if (Configs.SERVER_CONFIG.isOfferingFiles()) {
buf.writeInt(AutoSync.syncFolderDescriptions.size()); buf.writeInt(AutoSync.syncFolderDescriptions.size());
AutoSync.syncFolderDescriptions.forEach(desc -> { AutoSync.syncFolderDescriptions.forEach(desc -> {
BCLib.LOGGER.info(" - Offering Folder " + desc.localFolder + " (allowDelete=" + desc.removeAdditionalFiles + ")"); BCLib.LOGGER.info(" - Offering Folder " + desc.localFolder + " (allowDelete=" + desc.removeAdditionalFiles + ")");
desc.serialize(buf); desc.serialize(buf);
}); });
} }
@ -238,13 +238,13 @@ public class HelloClient extends DataHandler.FromServer {
//desc contains the fileCache sent from the server, load the local version to get hold of the actual file cache on the client //desc contains the fileCache sent from the server, load the local version to get hold of the actual file cache on the client
SyncFolderDescriptor localDescriptor = AutoSync.getSyncFolderDescriptor(desc.folderID); SyncFolderDescriptor localDescriptor = AutoSync.getSyncFolderDescriptor(desc.folderID);
if (localDescriptor != null) { if (localDescriptor != null) {
BCLib.LOGGER.info(" - " + desc.folderID + " (" + desc.localFolder + ", allowRemove=" + desc.removeAdditionalFiles + ")"); BCLib.LOGGER.info(" - " + desc.folderID + " (" + desc.localFolder + ", allowRemove=" + desc.removeAdditionalFiles + ")");
localDescriptor.invalidateCache(); localDescriptor.invalidateCache();
desc.relativeFilesStream() desc.relativeFilesStream()
.filter(desc::discardChildElements) .filter(desc::discardChildElements)
.forEach(subFile -> { .forEach(subFile -> {
BCLib.LOGGER.warning(" * " + subFile.relPath + " (REJECTED)"); BCLib.LOGGER.warning(" * " + subFile.relPath + " (REJECTED)");
}); });
@ -256,7 +256,7 @@ public class HelloClient extends DataHandler.FromServer {
.map(absPath -> new AutoSyncID.ForDirectFileRequest(desc.folderID, absPath.toFile())) .map(absPath -> new AutoSyncID.ForDirectFileRequest(desc.folderID, absPath.toFile()))
.collect(Collectors.toList()); .collect(Collectors.toList());
additionalFiles.forEach(aid -> BCLib.LOGGER.info(" * " + desc.localFolder.relativize(aid.relFile.toPath()) + " (missing on server)")); additionalFiles.forEach(aid -> BCLib.LOGGER.info(" * " + desc.localFolder.relativize(aid.relFile.toPath()) + " (missing on server)"));
filesToRemove.addAll(additionalFiles); filesToRemove.addAll(additionalFiles);
} }
@ -267,16 +267,16 @@ public class HelloClient extends DataHandler.FromServer {
if (localSubFile != null) { if (localSubFile != null) {
//the file exists locally, check if the hashes match //the file exists locally, check if the hashes match
if (!localSubFile.hash.equals(subFile.hash)) { if (!localSubFile.hash.equals(subFile.hash)) {
BCLib.LOGGER.info(" * " + subFile.relPath + " (changed)"); BCLib.LOGGER.info(" * " + subFile.relPath + " (changed)");
filesToRequest.add(new AutoSyncID.ForDirectFileRequest(desc.folderID, new File(subFile.relPath))); filesToRequest.add(new AutoSyncID.ForDirectFileRequest(desc.folderID, new File(subFile.relPath)));
} }
else { else {
BCLib.LOGGER.info(" * " + subFile.relPath); BCLib.LOGGER.info(" * " + subFile.relPath);
} }
} }
else { else {
//the file is missing locally //the file is missing locally
BCLib.LOGGER.info(" * " + subFile.relPath + " (missing on client)"); BCLib.LOGGER.info(" * " + subFile.relPath + " (missing on client)");
filesToRequest.add(new AutoSyncID.ForDirectFileRequest(desc.folderID, new File(subFile.relPath))); filesToRequest.add(new AutoSyncID.ForDirectFileRequest(desc.folderID, new File(subFile.relPath)));
} }
}); });
@ -285,7 +285,7 @@ public class HelloClient extends DataHandler.FromServer {
localDescriptor.invalidateCache(); localDescriptor.invalidateCache();
} }
else { else {
BCLib.LOGGER.info(" - " + desc.folderID + " (Failed to find)"); BCLib.LOGGER.info(" - " + desc.folderID + " (Failed to find)");
} }
}); });
} }
@ -320,11 +320,11 @@ public class HelloClient extends DataHandler.FromServer {
} }
} }
BCLib.LOGGER.info(" - " + e + ": " + actionString); BCLib.LOGGER.info(" - " + e + ": " + actionString);
if (debugHashes) { if (debugHashes) {
BCLib.LOGGER.info(" * " + e.serverHash + " (Server)"); BCLib.LOGGER.info(" * " + e.serverHash + " (Server)");
BCLib.LOGGER.info(" * " + e.localMatch.getFileHash() + " (Client)"); BCLib.LOGGER.info(" * " + e.localMatch.getFileHash() + " (Client)");
BCLib.LOGGER.info(" * local Content " + (contentWrapper.getRawContent() == null)); BCLib.LOGGER.info(" * local Content " + (contentWrapper.getRawContent() == null));
} }
} }
} }
@ -337,7 +337,7 @@ public class HelloClient extends DataHandler.FromServer {
final OfferedModInfo serverInfo = e.getValue(); final OfferedModInfo serverInfo = e.getValue();
final boolean requestMod = !serverInfo.version.equals(localVersion) && serverInfo.size > 0 && serverInfo.canDownload; final boolean requestMod = !serverInfo.version.equals(localVersion) && serverInfo.size > 0 && serverInfo.canDownload;
BCLib.LOGGER.info(" - " + e.getKey() + " (client=" + localVersion + ", server=" + serverInfo.version + ", size=" + PathUtil.humanReadableFileSize(serverInfo.size) + (requestMod ? ", requesting" : "") + (serverInfo.canDownload ? "" :", not offered")+ ")"); BCLib.LOGGER.info(" - " + e.getKey() + " (client=" + localVersion + ", server=" + serverInfo.version + ", size=" + PathUtil.humanReadableFileSize(serverInfo.size) + (requestMod ? ", requesting" : "") + (serverInfo.canDownload ? "" :", not offered")+ ")");
if (requestMod) { if (requestMod) {
filesToRequest.add(new AutoSyncID.ForModFileRequest(e.getKey(), serverInfo.version)); filesToRequest.add(new AutoSyncID.ForModFileRequest(e.getKey(), serverInfo.version));
} }
@ -451,7 +451,7 @@ public class HelloClient extends DataHandler.FromServer {
} }
if (removeFiles) { if (removeFiles) {
filesToRemove.forEach(aid -> { filesToRemove.forEach(aid -> {
BCLib.LOGGER.info(" - " + aid.relFile + " (removing)"); BCLib.LOGGER.info(" - " + aid.relFile + " (removing)");
aid.relFile.delete(); aid.relFile.delete();
}); });
} }
@ -469,13 +469,13 @@ public class HelloClient extends DataHandler.FromServer {
private void processOfferedFile(List<AutoSyncID> requestFiles, AutoSyncID aid) { private void processOfferedFile(List<AutoSyncID> requestFiles, AutoSyncID aid) {
if (aid instanceof WithContentOverride) { if (aid instanceof WithContentOverride) {
final WithContentOverride aidc = (WithContentOverride) aid; final WithContentOverride aidc = (WithContentOverride) aid;
BCLib.LOGGER.info(" - " + aid + " (updating Content)"); BCLib.LOGGER.info(" - " + aid + " (updating Content)");
SendFiles.writeSyncedFile(aid, aidc.contentWrapper.getRawContent(), aidc.localFile); SendFiles.writeSyncedFile(aid, aidc.contentWrapper.getRawContent(), aidc.localFile);
} }
else { else {
requestFiles.add(aid); requestFiles.add(aid);
BCLib.LOGGER.info(" - " + aid + " (requesting)"); BCLib.LOGGER.info(" - " + aid + " (requesting)");
} }
} }

View file

@ -19,7 +19,7 @@ import java.io.File;
* This message is sent once a player enters the world. It initiates a sequence of Messages that will sync files between both * This message is sent once a player enters the world. It initiates a sequence of Messages that will sync files between both
* client and server. * client and server.
* <table> * <table>
* <caption>Description</caption> * <caption>Description</caption>
* <tr> * <tr>
* <th>Server</th> * <th>Server</th>
* <th></th> * <th></th>

View file

@ -66,7 +66,7 @@ public class RequestFiles extends DataHandler.FromClient {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
AutoSyncID asid = AutoSyncID.deserializeData(buf); AutoSyncID asid = AutoSyncID.deserializeData(buf);
files.add(asid); files.add(asid);
BCLib.LOGGER.info(" - " + asid); BCLib.LOGGER.info(" - " + asid);
} }

View file

@ -74,7 +74,7 @@ public class SendFiles extends DataHandler.FromServer {
BCLib.LOGGER.info("Sending " + existingFiles.size() + " Files to Client:"); BCLib.LOGGER.info("Sending " + existingFiles.size() + " Files to Client:");
for (AutoFileSyncEntry entry : existingFiles) { for (AutoFileSyncEntry entry : existingFiles) {
int length = entry.serializeContent(buf); int length = entry.serializeContent(buf);
BCLib.LOGGER.info(" - " + entry + " (" + PathUtil.humanReadableFileSize(length) + ")"); BCLib.LOGGER.info(" - " + entry + " (" + PathUtil.humanReadableFileSize(length) + ")");
} }
} }
@ -112,7 +112,7 @@ public class SendFiles extends DataHandler.FromServer {
} else { } else {
type = "Ignoring "; type = "Ignoring ";
} }
BCLib.LOGGER.info(" - " + type + p.first + " (" + PathUtil.humanReadableFileSize(p.second.length) + ")"); BCLib.LOGGER.info(" - " + type + p.first + " (" + PathUtil.humanReadableFileSize(p.second.length) + ")");
} }
else { else {
BCLib.LOGGER.error(" - Failed to receive File " + p.third + ", possibly sent from a Mod that is not installed on the client."); BCLib.LOGGER.error(" - Failed to receive File " + p.third + ", possibly sent from a Mod that is not installed on the client.");
@ -173,7 +173,7 @@ public class SendFiles extends DataHandler.FromServer {
} while (path.toFile().exists()); } while (path.toFile().exists());
} }
BCLib.LOGGER.info(" - Writing " + path + " (" + PathUtil.humanReadableFileSize(data.length) + ")"); BCLib.LOGGER.info(" - Writing " + path + " (" + PathUtil.humanReadableFileSize(data.length) + ")");
try { try {
final File parentFile = path.getParent() final File parentFile = path.getParent()
.toFile(); .toFile();
@ -192,7 +192,7 @@ public class SendFiles extends DataHandler.FromServer {
collisionFreeName = String.format("%03d", count) + "_" + bakFileName; collisionFreeName = String.format("%03d", count) + "_" + bakFileName;
} while (targetPath.toFile().exists()); } while (targetPath.toFile().exists());
BCLib.LOGGER.info(" - Moving " + removeAfter + " to " +targetPath); BCLib.LOGGER.info(" - Moving " + removeAfter + " to " +targetPath);
removeAfter.toFile().renameTo(targetPath.toFile()); removeAfter.toFile().renameTo(targetPath.toFile());
} }
AutoSync.didReceiveFile(e, fileName); AutoSync.didReceiveFile(e, fileName);
@ -200,7 +200,7 @@ public class SendFiles extends DataHandler.FromServer {
} }
catch (IOException ioException) { catch (IOException ioException) {
BCLib.LOGGER.error(" --> Writing " + fileName + " failed: " + ioException); BCLib.LOGGER.error(" --> Writing " + fileName + " failed: " + ioException);
} }
} }

View file

@ -124,9 +124,9 @@ public class SyncFolderDescriptor {
buf.writeBoolean(removeAdditionalFiles); buf.writeBoolean(removeAdditionalFiles);
buf.writeInt(fileCache.size()); buf.writeInt(fileCache.size());
fileCache.forEach(fl -> { fileCache.forEach(fl -> {
BCLib.LOGGER.info(" - " + fl.relPath); BCLib.LOGGER.info(" - " + fl.relPath);
if (debugHashes) { if (debugHashes) {
BCLib.LOGGER.info(" " + fl.hash); BCLib.LOGGER.info(" " + fl.hash);
} }
fl.serialize(buf); fl.serialize(buf);
}); });

View file

@ -108,7 +108,7 @@ public class DataFixerAPI {
* {@code Minecraft.getInstance().getLevelSource()} * {@code Minecraft.getInstance().getLevelSource()}
* @param levelID The ID of the Level you want to patch * @param levelID The ID of the Level you want to patch
* @param showUI {@code true}, if you want to present the user with a Screen that offers to backup the world * @param showUI {@code true}, if you want to present the user with a Screen that offers to backup the world
* before applying the patches * before applying the patches
* @param onResume When this method retursn {@code true}, this function will be called when the world is ready * @param onResume When this method retursn {@code true}, this function will be called when the world is ready
* @return {@code true} if the UI was displayed. The UI is only displayed if {@code showUI} was {@code true} and * @return {@code true} if the UI was displayed. The UI is only displayed if {@code showUI} was {@code true} and
* patches were enabled in the config and the Guardian did find any patches that need to be applied to the world. * patches were enabled in the config and the Guardian did find any patches that need to be applied to the world.
@ -123,7 +123,7 @@ public class DataFixerAPI {
* *
* @param levelStorageAccess The access class of the level you want to patch * @param levelStorageAccess The access class of the level you want to patch
* @param showUI {@code true}, if you want to present the user with a Screen that offers to backup the world * @param showUI {@code true}, if you want to present the user with a Screen that offers to backup the world
* before applying the patches * before applying the patches
* @param onResume When this method retursn {@code true}, this function will be called when the world is ready * @param onResume When this method retursn {@code true}, this function will be called when the world is ready
* @return {@code true} if the UI was displayed. The UI is only displayed if {@code showUI} was {@code true} and * @return {@code true} if the UI was displayed. The UI is only displayed if {@code showUI} was {@code true} and
* patches were enabled in the config and the Guardian did find any patches that need to be applied to the world. * patches were enabled in the config and the Guardian did find any patches that need to be applied to the world.

View file

@ -70,12 +70,12 @@ public abstract class Patch {
* inconsistencies are found. * inconsistencies are found.
* *
* @param modID The ID of the Mod you want to register a patch for. This should be your * @param modID The ID of the Mod you want to register a patch for. This should be your
* ModID only. The ModID can not be {@code null} or an empty String. * ModID only. The ModID can not be {@code null} or an empty String.
* @param version The mod-version that introduces the patch. This needs Semantic-Version String * @param version The mod-version that introduces the patch. This needs Semantic-Version String
* like x.x.x. Developers are responsible for registering their patches in the correct * like x.x.x. Developers are responsible for registering their patches in the correct
* order (with increasing versions). You are not allowed to register a new * order (with increasing versions). You are not allowed to register a new
* Patch with a version lower or equal than * Patch with a version lower or equal than
* {@link Patch#maxPatchVersion(String)} * {@link Patch#maxPatchVersion(String)}
*/ */
protected Patch(@NotNull String modID, String version) { protected Patch(@NotNull String modID, String version) {
this(modID, version, false); this(modID, version, false);
@ -85,10 +85,10 @@ public abstract class Patch {
* Internal Constructor used to create patches that can allways run (no matter what patchlevel a level has) * Internal Constructor used to create patches that can allways run (no matter what patchlevel a level has)
* @param modID The ID of the Mod * @param modID The ID of the Mod
* @param version The mod-version that introduces the patch. When {@Code runAllways} is set, this version will * @param version The mod-version that introduces the patch. When {@Code runAllways} is set, this version will
* determine the patchlevel that is written to the level * determine the patchlevel that is written to the level
* @param alwaysApply When true, this patch is always active, no matter the patchlevel of the world. * @param alwaysApply When true, this patch is always active, no matter the patchlevel of the world.
* This should be used sparingly and just for patches that apply to level.dat (as they only take * This should be used sparingly and just for patches that apply to level.dat (as they only take
* effect when changes are detected). Use {@link ForcedLevelPatch} to instatiate. * effect when changes are detected). Use {@link ForcedLevelPatch} to instatiate.
*/ */
Patch(@NotNull String modID, String version, boolean alwaysApply) { Patch(@NotNull String modID, String version, boolean alwaysApply) {
//Patchlevels need to be unique and registered in ascending order //Patchlevels need to be unique and registered in ascending order
@ -201,11 +201,11 @@ public abstract class Patch {
* a {@link CompoundTag}. If the Path contains a non-leaf {@link net.minecraft.nbt.ListTag}, all members of that * a {@link CompoundTag}. If the Path contains a non-leaf {@link net.minecraft.nbt.ListTag}, all members of that
* list will be processed. For example: * list will be processed. For example:
* <pre> * <pre>
* - global + * - global +
* | - key (String) * | - key (String)
* | - items (List) + * | - items (List) +
* | - { id (String) } * | - { id (String) }
* | - { id (String) } * | - { id (String) }
* </pre> * </pre>
* The path <b>global.items.id</b> will fix all <i>id</i>-entries in the <i>items</i>-list, while the path * The path <b>global.items.id</b> will fix all <i>id</i>-entries in the <i>items</i>-list, while the path
* <b>global.key</b> will only fix the <i>key</i>-entry. * <b>global.key</b> will only fix the <i>key</i>-entry.

View file

@ -221,7 +221,7 @@ public class SurfaceRuleBuilder {
/** /**
* Set biome floor with specified {@link BlockState} and the given Noise Function. The rule is added with priority 3. * Set biome floor with specified {@link BlockState} and the given Noise Function. The rule is added with priority 3.
* @param surfaceBlockA {@link BlockState} for the ground cover. * @param surfaceBlockA {@link BlockState} for the ground cover.
* @param surfaceBlockB {@link BlockState} for the alternative ground cover. * @param surfaceBlockB {@link BlockState} for the alternative ground cover.
* @param noise The {@link NoiseCondition} * @param noise The {@link NoiseCondition}
* @return same {@link SurfaceRuleBuilder} instance. * @return same {@link SurfaceRuleBuilder} instance.
*/ */

View file

@ -19,8 +19,8 @@ import java.util.function.Consumer;
* <p> * <p>
* This Block-Type will: * This Block-Type will:
* <ul> * <ul>
* <li>Drop itself</li> * <li>Drop itself</li>
* <li>Automatically create an Item-Model from the Block-Model</li> * <li>Automatically create an Item-Model from the Block-Model</li>
* </ul> * </ul>
*/ */
public class BaseBlock extends Block implements BlockModelProvider { public class BaseBlock extends Block implements BlockModelProvider {
@ -63,7 +63,7 @@ public class BaseBlock extends Block implements BlockModelProvider {
* For example in {@link BaseLeavesBlock#BaseLeavesBlock(Block, MaterialColor, Consumer)} * For example in {@link BaseLeavesBlock#BaseLeavesBlock(Block, MaterialColor, Consumer)}
* *
* @param customizeProperties A {@link Consumer} to call with the preset properties * @param customizeProperties A {@link Consumer} to call with the preset properties
* @param settings The properties as created by the Block * @param settings The properties as created by the Block
* @return The reconfigured {@code settings} * @return The reconfigured {@code settings}
*/ */
static FabricBlockSettings acceptAndReturn(Consumer<FabricBlockSettings> customizeProperties, FabricBlockSettings settings) { static FabricBlockSettings acceptAndReturn(Consumer<FabricBlockSettings> customizeProperties, FabricBlockSettings settings) {

View file

@ -3,14 +3,14 @@ package ru.bclib.blocks;
import net.minecraft.world.level.material.MaterialColor; import net.minecraft.world.level.material.MaterialColor;
public class LeveledAnvilBlock extends BaseAnvilBlock{ public class LeveledAnvilBlock extends BaseAnvilBlock{
protected final int level; protected final int level;
public LeveledAnvilBlock(MaterialColor color, int level) { public LeveledAnvilBlock(MaterialColor color, int level) {
super(color); super(color);
this.level = level; this.level = level;
} }
public int getCraftingLevel() { public int getCraftingLevel() {
return level; return level;
} }
} }

View file

@ -220,7 +220,7 @@ public class OBJBlockModel implements UnbakedModel, BakedModel {
if (member.contains("/")) { if (member.contains("/")) {
String[] sub = member.split("/"); String[] sub = member.split("/");
vertexIndex.add(Integer.parseInt(sub[0]) - 1); // Vertex vertexIndex.add(Integer.parseInt(sub[0]) - 1); // Vertex
uvIndex.add(Integer.parseInt(sub[1]) - 1); // UV uvIndex.add(Integer.parseInt(sub[1]) - 1); // UV
} }
else { else {
vertexIndex.add(Integer.parseInt(member) - 1); // Vertex vertexIndex.add(Integer.parseInt(member) - 1); // Vertex

View file

@ -55,7 +55,7 @@ public class UnbakedQuad {
float z = data[dataIndex++]; // Z float z = data[dataIndex++]; // Z
POS.set(x, y, z, 0); POS.set(x, y, z, 0);
POS.transform(matrix); POS.transform(matrix);
vertexData[index] = Float.floatToIntBits(POS.x()); // X vertexData[index] = Float.floatToIntBits(POS.x()); // X
vertexData[index | 1] = Float.floatToIntBits(POS.y()); // Y vertexData[index | 1] = Float.floatToIntBits(POS.y()); // Y
vertexData[index | 2] = Float.floatToIntBits(POS.z()); // Z vertexData[index | 2] = Float.floatToIntBits(POS.z()); // Z
vertexData[index | 3] = -1; // Unknown constant vertexData[index | 3] = -1; // Unknown constant

View file

@ -39,372 +39,372 @@ import ru.bclib.complexmaterials.entry.RecipeEntry;
import ru.bclib.recipes.GridRecipe; import ru.bclib.recipes.GridRecipe;
public class WoodenComplexMaterial extends ComplexMaterial { public class WoodenComplexMaterial extends ComplexMaterial {
public static final ResourceLocation MATERIAL_ID = BCLib.makeID("wooden_material"); public static final ResourceLocation MATERIAL_ID = BCLib.makeID("wooden_material");
public static final String BLOCK_CRAFTING_TABLE = "crafting_table"; public static final String BLOCK_CRAFTING_TABLE = "crafting_table";
public static final String BLOCK_STRIPPED_BARK = "stripped_bark"; public static final String BLOCK_STRIPPED_BARK = "stripped_bark";
public static final String BLOCK_STRIPPED_LOG = "stripped_log"; public static final String BLOCK_STRIPPED_LOG = "stripped_log";
public static final String BLOCK_PRESSURE_PLATE = "plate"; public static final String BLOCK_PRESSURE_PLATE = "plate";
public static final String BLOCK_BOOKSHELF = "bookshelf"; public static final String BLOCK_BOOKSHELF = "bookshelf";
public static final String BLOCK_COMPOSTER = "composter"; public static final String BLOCK_COMPOSTER = "composter";
public static final String BLOCK_TRAPDOOR = "trapdoor"; public static final String BLOCK_TRAPDOOR = "trapdoor";
public static final String BLOCK_BARREL = "barrel"; public static final String BLOCK_BARREL = "barrel";
public static final String BLOCK_BUTTON = "button"; public static final String BLOCK_BUTTON = "button";
public static final String BLOCK_LADDER = "ladder"; public static final String BLOCK_LADDER = "ladder";
public static final String BLOCK_PLANKS = "planks"; public static final String BLOCK_PLANKS = "planks";
public static final String BLOCK_STAIRS = "stairs"; public static final String BLOCK_STAIRS = "stairs";
public static final String BLOCK_CHEST = "chest"; public static final String BLOCK_CHEST = "chest";
public static final String BLOCK_FENCE = "fence"; public static final String BLOCK_FENCE = "fence";
public static final String BLOCK_BARK = "bark"; public static final String BLOCK_BARK = "bark";
public static final String BLOCK_DOOR = "door"; public static final String BLOCK_DOOR = "door";
public static final String BLOCK_GATE = "gate"; public static final String BLOCK_GATE = "gate";
public static final String BLOCK_SIGN = "sign"; public static final String BLOCK_SIGN = "sign";
public static final String BLOCK_SLAB = "slab"; public static final String BLOCK_SLAB = "slab";
public static final String BLOCK_LOG = "log"; public static final String BLOCK_LOG = "log";
public static final String TAG_LOGS = "logs"; public static final String TAG_LOGS = "logs";
public final MaterialColor planksColor; public final MaterialColor planksColor;
public final MaterialColor woodColor; public final MaterialColor woodColor;
public WoodenComplexMaterial(String modID, String baseName, String receipGroupPrefix, MaterialColor woodColor, MaterialColor planksColor) { public WoodenComplexMaterial(String modID, String baseName, String receipGroupPrefix, MaterialColor woodColor, MaterialColor planksColor) {
super(modID, baseName, receipGroupPrefix); super(modID, baseName, receipGroupPrefix);
this.planksColor = planksColor; this.planksColor = planksColor;
this.woodColor = woodColor; this.woodColor = woodColor;
} }
@Override @Override
protected FabricBlockSettings getBlockSettings() { protected FabricBlockSettings getBlockSettings() {
return FabricBlockSettings.copyOf(Blocks.OAK_PLANKS) return FabricBlockSettings.copyOf(Blocks.OAK_PLANKS)
.materialColor(planksColor); .materialColor(planksColor);
} }
@Override @Override
public ResourceLocation getMaterialID() { public ResourceLocation getMaterialID() {
return MATERIAL_ID; return MATERIAL_ID;
} }
@Override @Override
protected void initTags() { protected void initTags() {
addBlockTag(TagAPI.makeBlockTag(getModID(), getBaseName() + "_logs")); addBlockTag(TagAPI.makeBlockTag(getModID(), getBaseName() + "_logs"));
addItemTag(TagAPI.makeItemTag(getModID(), getBaseName() + "_logs")); addItemTag(TagAPI.makeItemTag(getModID(), getBaseName() + "_logs"));
} }
@Override @Override
protected void initDefault(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) { protected void initDefault(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
initBase(blockSettings, itemSettings); initBase(blockSettings, itemSettings);
initStorage(blockSettings, itemSettings); initStorage(blockSettings, itemSettings);
initDecorations(blockSettings, itemSettings); initDecorations(blockSettings, itemSettings);
} }
final protected void initBase(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) { final protected void initBase(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
Tag.Named<Block> tagBlockLog = getBlockTag(TAG_LOGS); Tag.Named<Block> tagBlockLog = getBlockTag(TAG_LOGS);
Tag.Named<Item> tagItemLog = getItemTag(TAG_LOGS); Tag.Named<Item> tagItemLog = getItemTag(TAG_LOGS);
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> { new BlockEntry(BLOCK_STRIPPED_LOG, (complexMaterial, settings) -> {
return new BaseRotatedPillarBlock(settings); return new BaseRotatedPillarBlock(settings);
}) })
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
); );
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_STRIPPED_BARK, (complexMaterial, settings) -> { new BlockEntry(BLOCK_STRIPPED_BARK, (complexMaterial, settings) -> {
return new BaseBarkBlock(settings); return new BaseBarkBlock(settings);
}) })
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
); );
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_LOG, (complexMaterial, settings) -> { new BlockEntry(BLOCK_LOG, (complexMaterial, settings) -> {
return new BaseStripableLogBlock(woodColor, getBlock(BLOCK_STRIPPED_LOG)); return new BaseStripableLogBlock(woodColor, getBlock(BLOCK_STRIPPED_LOG));
}) })
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
); );
addBlockEntry( addBlockEntry(
new BlockEntry(BLOCK_BARK, (complexMaterial, settings) -> { new BlockEntry(BLOCK_BARK, (complexMaterial, settings) -> {
return new StripableBarkBlock(woodColor, getBlock(BLOCK_STRIPPED_BARK)); return new StripableBarkBlock(woodColor, getBlock(BLOCK_STRIPPED_BARK));
}) })
.setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog) .setBlockTags(BlockTags.LOGS, BlockTags.LOGS_THAT_BURN, tagBlockLog)
.setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog) .setItemTags(ItemTags.LOGS, ItemTags.LOGS_THAT_BURN, tagItemLog)
); );
addBlockEntry(new BlockEntry(BLOCK_PLANKS, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_PLANKS, (complexMaterial, settings) -> {
return new BaseBlock(settings); return new BaseBlock(settings);
}).setBlockTags(BlockTags.PLANKS) }).setBlockTags(BlockTags.PLANKS)
.setItemTags(ItemTags.PLANKS)); .setItemTags(ItemTags.PLANKS));
addBlockEntry(new BlockEntry(BLOCK_STAIRS, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_STAIRS, (complexMaterial, settings) -> {
return new BaseStairsBlock(getBlock(BLOCK_PLANKS)); return new BaseStairsBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS) }).setBlockTags(BlockTags.WOODEN_STAIRS, BlockTags.STAIRS)
.setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS)); .setItemTags(ItemTags.WOODEN_STAIRS, ItemTags.STAIRS));
addBlockEntry(new BlockEntry(BLOCK_SLAB, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_SLAB, (complexMaterial, settings) -> {
return new BaseSlabBlock(getBlock(BLOCK_PLANKS)); return new BaseSlabBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS) }).setBlockTags(BlockTags.WOODEN_SLABS, BlockTags.SLABS)
.setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS)); .setItemTags(ItemTags.WOODEN_SLABS, ItemTags.SLABS));
addBlockEntry(new BlockEntry(BLOCK_FENCE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_FENCE, (complexMaterial, settings) -> {
return new BaseFenceBlock(getBlock(BLOCK_PLANKS)); return new BaseFenceBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES) }).setBlockTags(BlockTags.FENCES, BlockTags.WOODEN_FENCES)
.setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES)); .setItemTags(ItemTags.FENCES, ItemTags.WOODEN_FENCES));
addBlockEntry(new BlockEntry(BLOCK_GATE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_GATE, (complexMaterial, settings) -> {
return new BaseGateBlock(getBlock(BLOCK_PLANKS)); return new BaseGateBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.FENCE_GATES)); }).setBlockTags(BlockTags.FENCE_GATES));
addBlockEntry(new BlockEntry(BLOCK_BUTTON, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BUTTON, (complexMaterial, settings) -> {
return new BaseWoodenButtonBlock(getBlock(BLOCK_PLANKS)); return new BaseWoodenButtonBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS) }).setBlockTags(BlockTags.BUTTONS, BlockTags.WOODEN_BUTTONS)
.setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS)); .setItemTags(ItemTags.BUTTONS, ItemTags.WOODEN_BUTTONS));
addBlockEntry(new BlockEntry(BLOCK_PRESSURE_PLATE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_PRESSURE_PLATE, (complexMaterial, settings) -> {
return new WoodenPressurePlateBlock(getBlock(BLOCK_PLANKS)); return new WoodenPressurePlateBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES) }).setBlockTags(BlockTags.PRESSURE_PLATES, BlockTags.WOODEN_PRESSURE_PLATES)
.setItemTags(ItemTags.WOODEN_PRESSURE_PLATES)); .setItemTags(ItemTags.WOODEN_PRESSURE_PLATES));
addBlockEntry(new BlockEntry(BLOCK_TRAPDOOR, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_TRAPDOOR, (complexMaterial, settings) -> {
return new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS)); return new BaseTrapdoorBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS) }).setBlockTags(BlockTags.TRAPDOORS, BlockTags.WOODEN_TRAPDOORS)
.setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS)); .setItemTags(ItemTags.TRAPDOORS, ItemTags.WOODEN_TRAPDOORS));
addBlockEntry(new BlockEntry(BLOCK_DOOR, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_DOOR, (complexMaterial, settings) -> {
return new BaseDoorBlock(getBlock(BLOCK_PLANKS)); return new BaseDoorBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS) }).setBlockTags(BlockTags.DOORS, BlockTags.WOODEN_DOORS)
.setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS)); .setItemTags(ItemTags.DOORS, ItemTags.WOODEN_DOORS));
addBlockEntry(new BlockEntry(BLOCK_LADDER, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_LADDER, (complexMaterial, settings) -> {
return new BaseLadderBlock(getBlock(BLOCK_PLANKS)); return new BaseLadderBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.CLIMBABLE)); }).setBlockTags(BlockTags.CLIMBABLE));
addBlockEntry(new BlockEntry(BLOCK_SIGN, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_SIGN, (complexMaterial, settings) -> {
return new BaseSignBlock(getBlock(BLOCK_PLANKS)); return new BaseSignBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(BlockTags.SIGNS) }).setBlockTags(BlockTags.SIGNS)
.setItemTags(ItemTags.SIGNS)); .setItemTags(ItemTags.SIGNS));
} }
final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) { final protected void initStorage(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_CHEST, (complexMaterial, settings) -> {
return new BaseChestBlock(getBlock(BLOCK_PLANKS)); return new BaseChestBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_CHEST, TagAPI.BLOCK_WOODEN_CHEST) }).setBlockTags(TagAPI.BLOCK_CHEST, TagAPI.BLOCK_WOODEN_CHEST)
.setItemTags(TagAPI.ITEM_CHEST, TagAPI.ITEM_WOODEN_CHEST)); .setItemTags(TagAPI.ITEM_CHEST, TagAPI.ITEM_WOODEN_CHEST));
addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BARREL, (complexMaterial, settings) -> {
return new BaseBarrelBlock(getBlock(BLOCK_PLANKS)); return new BaseBarrelBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_BARREL, TagAPI.BLOCK_WOODEN_BARREL) }).setBlockTags(TagAPI.BLOCK_BARREL, TagAPI.BLOCK_WOODEN_BARREL)
.setItemTags(TagAPI.ITEM_BARREL, TagAPI.ITEM_WOODEN_BARREL)); .setItemTags(TagAPI.ITEM_BARREL, TagAPI.ITEM_WOODEN_BARREL));
} }
final protected void initDecorations(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) { final protected void initDecorations(FabricBlockSettings blockSettings, FabricItemSettings itemSettings) {
addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_CRAFTING_TABLE, (complexMaterial, settings) -> {
return new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS)); return new BaseCraftingTableBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_WORKBENCHES) }).setBlockTags(TagAPI.BLOCK_WORKBENCHES)
.setItemTags(TagAPI.ITEM_WORKBENCHES)); .setItemTags(TagAPI.ITEM_WORKBENCHES));
addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_BOOKSHELF, (complexMaterial, settings) -> {
return new BaseBookshelfBlock(getBlock(BLOCK_PLANKS)); return new BaseBookshelfBlock(getBlock(BLOCK_PLANKS));
}).setBlockTags(TagAPI.BLOCK_BOOKSHELVES)); }).setBlockTags(TagAPI.BLOCK_BOOKSHELVES));
addBlockEntry(new BlockEntry(BLOCK_COMPOSTER, (complexMaterial, settings) -> { addBlockEntry(new BlockEntry(BLOCK_COMPOSTER, (complexMaterial, settings) -> {
return new BaseComposterBlock(getBlock(BLOCK_PLANKS)); return new BaseComposterBlock(getBlock(BLOCK_PLANKS));
})); }));
} }
@Override @Override
protected void initFlammable(FlammableBlockRegistry registry) { protected void initFlammable(FlammableBlockRegistry registry) {
getBlocks().forEach(block -> { getBlocks().forEach(block -> {
registry.add(block, 5, 20); registry.add(block, 5, 20);
}); });
registry.add(getBlock(BLOCK_LOG), 5, 5); registry.add(getBlock(BLOCK_LOG), 5, 5);
registry.add(getBlock(BLOCK_BARK), 5, 5); registry.add(getBlock(BLOCK_BARK), 5, 5);
registry.add(getBlock(BLOCK_STRIPPED_LOG), 5, 5); registry.add(getBlock(BLOCK_STRIPPED_LOG), 5, 5);
registry.add(getBlock(BLOCK_STRIPPED_BARK), 5, 5); registry.add(getBlock(BLOCK_STRIPPED_BARK), 5, 5);
} }
@Override @Override
public void initDefaultRecipes() { public void initDefaultRecipes() {
Block planks = getBlock(BLOCK_PLANKS); Block planks = getBlock(BLOCK_PLANKS);
addRecipeEntry(new RecipeEntry("planks", (material, config, id) -> { addRecipeEntry(new RecipeEntry("planks", (material, config, id) -> {
Block log_stripped = getBlock(BLOCK_STRIPPED_LOG); Block log_stripped = getBlock(BLOCK_STRIPPED_LOG);
Block bark_stripped = getBlock(BLOCK_STRIPPED_BARK); Block bark_stripped = getBlock(BLOCK_STRIPPED_BARK);
Block log = getBlock(BLOCK_LOG); Block log = getBlock(BLOCK_LOG);
Block bark = getBlock(BLOCK_BARK); Block bark = getBlock(BLOCK_BARK);
GridRecipe.make(id, planks) GridRecipe.make(id, planks)
.checkConfig(config) .checkConfig(config)
.setOutputCount(4) .setOutputCount(4)
.setList("#") .setList("#")
.addMaterial('#', log, bark, log_stripped, bark_stripped) .addMaterial('#', log, bark, log_stripped, bark_stripped)
.setGroup(receipGroupPrefix + "_planks") .setGroup(receipGroupPrefix + "_planks")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> { addRecipeEntry(new RecipeEntry("stairs", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_STAIRS)) GridRecipe.make(id, getBlock(BLOCK_STAIRS))
.checkConfig(config) .checkConfig(config)
.setOutputCount(4) .setOutputCount(4)
.setShape("# ", "## ", "###") .setShape("# ", "## ", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_stairs") .setGroup(receipGroupPrefix + "_planks_stairs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> { addRecipeEntry(new RecipeEntry("slab", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_SLAB)) GridRecipe.make(id, getBlock(BLOCK_SLAB))
.checkConfig(config) .checkConfig(config)
.setOutputCount(6) .setOutputCount(6)
.setShape("###") .setShape("###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_slabs") .setGroup(receipGroupPrefix + "_planks_slabs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> { addRecipeEntry(new RecipeEntry("fence", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_FENCE)) GridRecipe.make(id, getBlock(BLOCK_FENCE))
.checkConfig(config) .checkConfig(config)
.setOutputCount(3) .setOutputCount(3)
.setShape("#I#", "#I#") .setShape("#I#", "#I#")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_planks_fences") .setGroup(receipGroupPrefix + "_planks_fences")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> { addRecipeEntry(new RecipeEntry("gate", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_GATE)) GridRecipe.make(id, getBlock(BLOCK_GATE))
.checkConfig(config) .checkConfig(config)
.setShape("I#I", "I#I") .setShape("I#I", "I#I")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_planks_gates") .setGroup(receipGroupPrefix + "_planks_gates")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("button", (material, config, id) -> { addRecipeEntry(new RecipeEntry("button", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BUTTON)) GridRecipe.make(id, getBlock(BLOCK_BUTTON))
.checkConfig(config) .checkConfig(config)
.setList("#") .setList("#")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_buttons") .setGroup(receipGroupPrefix + "_planks_buttons")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> { addRecipeEntry(new RecipeEntry("pressure_plate", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_PRESSURE_PLATE)) GridRecipe.make(id, getBlock(BLOCK_PRESSURE_PLATE))
.checkConfig(config) .checkConfig(config)
.setShape("##") .setShape("##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_planks_plates") .setGroup(receipGroupPrefix + "_planks_plates")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> { addRecipeEntry(new RecipeEntry("trapdoor", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_TRAPDOOR)) GridRecipe.make(id, getBlock(BLOCK_TRAPDOOR))
.checkConfig(config) .checkConfig(config)
.setOutputCount(2) .setOutputCount(2)
.setShape("###", "###") .setShape("###", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_trapdoors") .setGroup(receipGroupPrefix + "_trapdoors")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("door", (material, config, id) -> { addRecipeEntry(new RecipeEntry("door", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_DOOR)) GridRecipe.make(id, getBlock(BLOCK_DOOR))
.checkConfig(config) .checkConfig(config)
.setOutputCount(3) .setOutputCount(3)
.setShape("##", "##", "##") .setShape("##", "##", "##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_doors") .setGroup(receipGroupPrefix + "_doors")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> { addRecipeEntry(new RecipeEntry("crafting_table", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_CRAFTING_TABLE)) GridRecipe.make(id, getBlock(BLOCK_CRAFTING_TABLE))
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_tables") .setGroup(receipGroupPrefix + "_tables")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> { addRecipeEntry(new RecipeEntry("ladder", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_LADDER)) GridRecipe.make(id, getBlock(BLOCK_LADDER))
.checkConfig(config) .checkConfig(config)
.setOutputCount(3) .setOutputCount(3)
.setShape("I I", "I#I", "I I") .setShape("I I", "I#I", "I I")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_ladders") .setGroup(receipGroupPrefix + "_ladders")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> { addRecipeEntry(new RecipeEntry("sign", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_SIGN)) GridRecipe.make(id, getBlock(BLOCK_SIGN))
.checkConfig(config) .checkConfig(config)
.setOutputCount(3) .setOutputCount(3)
.setShape("###", "###", " I ") .setShape("###", "###", " I ")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('I', Items.STICK) .addMaterial('I', Items.STICK)
.setGroup(receipGroupPrefix + "_signs") .setGroup(receipGroupPrefix + "_signs")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> { addRecipeEntry(new RecipeEntry("chest", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_CHEST)) GridRecipe.make(id, getBlock(BLOCK_CHEST))
.checkConfig(config) .checkConfig(config)
.setShape("###", "# #", "###") .setShape("###", "# #", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.setGroup(receipGroupPrefix + "_chests") .setGroup(receipGroupPrefix + "_chests")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> { addRecipeEntry(new RecipeEntry("barrel", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BARREL)) GridRecipe.make(id, getBlock(BLOCK_BARREL))
.checkConfig(config) .checkConfig(config)
.setShape("#S#", "# #", "#S#") .setShape("#S#", "# #", "#S#")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('S', getBlock(BLOCK_SLAB)) .addMaterial('S', getBlock(BLOCK_SLAB))
.setGroup(receipGroupPrefix + "_barrels") .setGroup(receipGroupPrefix + "_barrels")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> { addRecipeEntry(new RecipeEntry("bookshelf", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BOOKSHELF)) GridRecipe.make(id, getBlock(BLOCK_BOOKSHELF))
.checkConfig(config) .checkConfig(config)
.setShape("###", "PPP", "###") .setShape("###", "PPP", "###")
.addMaterial('#', planks) .addMaterial('#', planks)
.addMaterial('P', Items.BOOK) .addMaterial('P', Items.BOOK)
.setGroup(receipGroupPrefix + "_bookshelves") .setGroup(receipGroupPrefix + "_bookshelves")
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> { addRecipeEntry(new RecipeEntry("bark", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_BARK)) GridRecipe.make(id, getBlock(BLOCK_BARK))
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_LOG)) .addMaterial('#', getBlock(BLOCK_LOG))
.setOutputCount(3) .setOutputCount(3)
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("log", (material, config, id) -> { addRecipeEntry(new RecipeEntry("log", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_LOG)) GridRecipe.make(id, getBlock(BLOCK_LOG))
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_BARK)) .addMaterial('#', getBlock(BLOCK_BARK))
.setOutputCount(3) .setOutputCount(3)
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("stripped_bark", (material, config, id) -> { addRecipeEntry(new RecipeEntry("stripped_bark", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_STRIPPED_BARK)) GridRecipe.make(id, getBlock(BLOCK_STRIPPED_BARK))
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_STRIPPED_LOG)) .addMaterial('#', getBlock(BLOCK_STRIPPED_LOG))
.setOutputCount(3) .setOutputCount(3)
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("stripped_log", (material, config, id) -> { addRecipeEntry(new RecipeEntry("stripped_log", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_STRIPPED_LOG)) GridRecipe.make(id, getBlock(BLOCK_STRIPPED_LOG))
.checkConfig(config) .checkConfig(config)
.setShape("##", "##") .setShape("##", "##")
.addMaterial('#', getBlock(BLOCK_STRIPPED_BARK)) .addMaterial('#', getBlock(BLOCK_STRIPPED_BARK))
.setOutputCount(3) .setOutputCount(3)
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("composter", (material, config, id) -> { addRecipeEntry(new RecipeEntry("composter", (material, config, id) -> {
GridRecipe.make(id, getBlock(BLOCK_COMPOSTER)) GridRecipe.make(id, getBlock(BLOCK_COMPOSTER))
.checkConfig(config) .checkConfig(config)
.setShape("# #", "# #", "###") .setShape("# #", "# #", "###")
.addMaterial('#', getBlock(BLOCK_SLAB)) .addMaterial('#', getBlock(BLOCK_SLAB))
.build(); .build();
})); }));
addRecipeEntry(new RecipeEntry("shulker", (material, config, id) -> { addRecipeEntry(new RecipeEntry("shulker", (material, config, id) -> {
GridRecipe.make(id, Blocks.SHULKER_BOX) GridRecipe.make(id, Blocks.SHULKER_BOX)
.checkConfig(config) .checkConfig(config)
.setShape("S", "#", "S") .setShape("S", "#", "S")
.addMaterial('S', Items.SHULKER_SHELL) .addMaterial('S', Items.SHULKER_SHELL)
.addMaterial('#', getBlock(BLOCK_CHEST)) .addMaterial('#', getBlock(BLOCK_CHEST))
.build(); .build();
})); }));
} }
} }

View file

@ -4,45 +4,45 @@ import ru.bclib.BCLib;
import ru.bclib.api.dataexchange.handler.autosync.AutoSync; import ru.bclib.api.dataexchange.handler.autosync.AutoSync;
public class ClientConfig extends NamedPathConfig { public class ClientConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", AutoSync.SYNC_CATEGORY); public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", AutoSync.SYNC_CATEGORY);
@ConfigUI(leftPadding = 8) @ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> ACCEPT_CONFIGS = DependendConfigToken.Boolean(true, "acceptConfigs", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> ACCEPT_CONFIGS = DependendConfigToken.Boolean(true, "acceptConfigs", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
@ConfigUI(leftPadding = 8) @ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> ACCEPT_FILES = DependendConfigToken.Boolean(true, "acceptFiles", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> ACCEPT_FILES = DependendConfigToken.Boolean(true, "acceptFiles", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
@ConfigUI(leftPadding = 8) @ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> ACCEPT_MODS = DependendConfigToken.Boolean(false, "acceptMods", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> ACCEPT_MODS = DependendConfigToken.Boolean(false, "acceptMods", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
@ConfigUI(leftPadding = 8) @ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> DISPLAY_MOD_INFO = DependendConfigToken.Boolean(true, "displayModInfo", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> DISPLAY_MOD_INFO = DependendConfigToken.Boolean(true, "displayModInfo", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
@ConfigUI(topPadding = 12) @ConfigUI(topPadding = 12)
public static final ConfigToken<Boolean> DEBUG_HASHES = ConfigToken.Boolean(false, "debugHashes", AutoSync.SYNC_CATEGORY); public static final ConfigToken<Boolean> DEBUG_HASHES = ConfigToken.Boolean(false, "debugHashes", AutoSync.SYNC_CATEGORY);
public ClientConfig() { public ClientConfig() {
super(BCLib.MOD_ID, "client", false); super(BCLib.MOD_ID, "client", false);
} }
public boolean shouldPrintDebugHashes() { public boolean shouldPrintDebugHashes() {
return get(DEBUG_HASHES); return get(DEBUG_HASHES);
} }
public boolean isAllowingAutoSync() { public boolean isAllowingAutoSync() {
return get(ENABLED); return get(ENABLED);
} }
public boolean isAcceptingMods() { public boolean isAcceptingMods() {
return get(ACCEPT_MODS) /*&& isAllowingAutoSync()*/; return get(ACCEPT_MODS) /*&& isAllowingAutoSync()*/;
} }
public boolean isAcceptingConfigs() { public boolean isAcceptingConfigs() {
return get(ACCEPT_CONFIGS) /*&& isAllowingAutoSync()*/; return get(ACCEPT_CONFIGS) /*&& isAllowingAutoSync()*/;
} }
public boolean isAcceptingFiles() { public boolean isAcceptingFiles() {
return get(ACCEPT_FILES) /*&& isAllowingAutoSync()*/; return get(ACCEPT_FILES) /*&& isAllowingAutoSync()*/;
} }
public boolean isShowingModInfo() { public boolean isShowingModInfo() {
return get(DISPLAY_MOD_INFO) /*&& isAllowingAutoSync()*/; return get(DISPLAY_MOD_INFO) /*&& isAllowingAutoSync()*/;
} }
} }

View file

@ -66,7 +66,7 @@ public final class ConfigKeeper {
/** /**
* Called for content based auto-sync. * Called for content based auto-sync.
* *
* @param me - When called in AutoSync this represents the content of the client. * @param me - When called in AutoSync this represents the content of the client.
* @param other - When called in AutoSync, this represents the content of the server * @param other - When called in AutoSync, this represents the content of the server
* @return {@code true} if content was changed * @return {@code true} if content was changed
*/ */

View file

@ -7,44 +7,44 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ServerConfig extends NamedPathConfig { public class ServerConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", AutoSync.SYNC_CATEGORY); public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", AutoSync.SYNC_CATEGORY);
public static final DependendConfigToken<Boolean> OFFER_CONFIGS = DependendConfigToken.Boolean(true, "offerConfigs", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> OFFER_CONFIGS = DependendConfigToken.Boolean(true, "offerConfigs", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
public static final DependendConfigToken<Boolean> OFFER_FILES = DependendConfigToken.Boolean(true, "offerFiles", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> OFFER_FILES = DependendConfigToken.Boolean(true, "offerFiles", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
public static final DependendConfigToken<Boolean> OFFER_MODS = DependendConfigToken.Boolean(true, "offerMods", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> OFFER_MODS = DependendConfigToken.Boolean(true, "offerMods", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
public static final DependendConfigToken<Boolean> OFFER_ALL_MODS = DependendConfigToken.Boolean(false, "offerAllMods", AutoSync.SYNC_CATEGORY, (config) -> config.get(OFFER_MODS)); public static final DependendConfigToken<Boolean> OFFER_ALL_MODS = DependendConfigToken.Boolean(false, "offerAllMods", AutoSync.SYNC_CATEGORY, (config) -> config.get(OFFER_MODS));
public static final DependendConfigToken<Boolean> SEND_ALL_MOD_INFO = DependendConfigToken.Boolean(false, "sendAllModInfo", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED)); public static final DependendConfigToken<Boolean> SEND_ALL_MOD_INFO = DependendConfigToken.Boolean(false, "sendAllModInfo", AutoSync.SYNC_CATEGORY, (config) -> config.get(ENABLED));
public static final ConfigToken<List<String>> ADDITIONAL_MODS = ConfigToken.StringArray(new ArrayList<>(0), "additionalMods", AutoSync.SYNC_CATEGORY); public static final ConfigToken<List<String>> ADDITIONAL_MODS = ConfigToken.StringArray(new ArrayList<>(0), "additionalMods", AutoSync.SYNC_CATEGORY);
public static final ConfigToken<List<String>> EXCLUDED_MODS = ConfigToken.StringArray(new ArrayList<>(0), "excludeMods", AutoSync.SYNC_CATEGORY); public static final ConfigToken<List<String>> EXCLUDED_MODS = ConfigToken.StringArray(new ArrayList<>(0), "excludeMods", AutoSync.SYNC_CATEGORY);
public ServerConfig() { public ServerConfig() {
super(BCLib.MOD_ID, "server", false); super(BCLib.MOD_ID, "server", false);
} }
public boolean isAllowingAutoSync() { public boolean isAllowingAutoSync() {
return get(ENABLED); return get(ENABLED);
} }
public boolean isOfferingConfigs() { public boolean isOfferingConfigs() {
return get(OFFER_CONFIGS) /*&& isAllowingAutoSync()*/; return get(OFFER_CONFIGS) /*&& isAllowingAutoSync()*/;
} }
public boolean isOfferingFiles() { public boolean isOfferingFiles() {
return get(OFFER_FILES) /*&& isAllowingAutoSync()*/; return get(OFFER_FILES) /*&& isAllowingAutoSync()*/;
} }
public boolean isOfferingMods() { public boolean isOfferingMods() {
return get(OFFER_MODS) /*&& isAllowingAutoSync()*/; return get(OFFER_MODS) /*&& isAllowingAutoSync()*/;
} }
public boolean isOfferingAllMods() { public boolean isOfferingAllMods() {
return get(OFFER_ALL_MODS) /*&& isAllowingAutoSync()*/; return get(OFFER_ALL_MODS) /*&& isAllowingAutoSync()*/;
} }
public boolean isOfferingInfosForMods() { public boolean isOfferingInfosForMods() {
return get(SEND_ALL_MOD_INFO) /*&& isAllowingAutoSync()*/; return get(SEND_ALL_MOD_INFO) /*&& isAllowingAutoSync()*/;
} }
} }

View file

@ -9,64 +9,64 @@ import java.util.List;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class GridColumn extends GridContainer { public class GridColumn extends GridContainer {
GridColumn(double width) { GridColumn(double width) {
super(width); super(width);
} }
GridColumn(double width, GridLayout.GridValueType widthType) { GridColumn(double width, GridLayout.GridValueType widthType) {
super(width, widthType); super(width, widthType);
} }
public GridRow addRow() { public GridRow addRow() {
return addRow(VerticalAlignment.TOP); return addRow(VerticalAlignment.TOP);
} }
public GridRow addRow(VerticalAlignment align) { public GridRow addRow(VerticalAlignment align) {
GridRow row = new GridRow(1.0, widthType==GridValueType.INHERIT?GridValueType.INHERIT:GridLayout.GridValueType.PERCENTAGE, align); GridRow row = new GridRow(1.0, widthType==GridValueType.INHERIT?GridValueType.INHERIT:GridLayout.GridValueType.PERCENTAGE, align);
this.cells.add(row); this.cells.add(row);
return row; return row;
} }
public void addSpacerRow() { public void addSpacerRow() {
this.addSpacerRow(4); this.addSpacerRow(4);
} }
public void addSpacerRow(int height) { public void addSpacerRow(int height) {
GridCell cell = new GridCell(1.0, height, GridValueType.PERCENTAGE, null, null); GridCell cell = new GridCell(1.0, height, GridValueType.PERCENTAGE, null, null);
this.cells.add(cell); this.cells.add(cell);
} }
@Override @Override
public int calculateWidth(final int parentWidth){ public int calculateWidth(final int parentWidth){
if (widthType == GridValueType.INHERIT) { if (widthType == GridValueType.INHERIT) {
return cells.stream() return cells.stream()
.filter(row->row.widthType == GridValueType.INHERIT) .filter(row->row.widthType == GridValueType.INHERIT)
.map(row -> row.buildElement(0, 0, 1, 0, 0, null).width) .map(row -> row.buildElement(0, 0, 1, 0, 0, null).width)
.reduce(0, (p, c) -> Math.max(p, c)); .reduce(0, (p, c) -> Math.max(p, c));
} else { } else {
return super.calculateWidth(parentWidth); return super.calculateWidth(parentWidth);
} }
} }
@Override @Override
protected GridElement buildElementAt(int left, int inTop, int width, final List<GridElement> collector) { protected GridElement buildElementAt(int left, int inTop, int width, final List<GridElement> collector) {
int height = 0; int height = 0;
int top = inTop; int top = inTop;
if (widthType == GridValueType.INHERIT) { if (widthType == GridValueType.INHERIT) {
width = calculateWidth(width); width = calculateWidth(width);
} }
for (GridCellDefinition row : cells) { for (GridCellDefinition row : cells) {
GridElement element = row.buildElement(width, 0, 1, left, top, collector); GridElement element = row.buildElement(width, 0, 1, left, top, collector);
top += element.height; top += element.height;
height += element.height; height += element.height;
} }
return new GridElement(left, inTop, width, height); return new GridElement(left, inTop, width, height);
} }
} }

View file

@ -3,8 +3,8 @@ package ru.bclib.gui.screens;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
public interface AtomicProgressListener { public interface AtomicProgressListener {
public void incAtomic(int maxProgress); public void incAtomic(int maxProgress);
public void resetAtomic(); public void resetAtomic();
public void stop(); public void stop();
public void progressStage(Component component); public void progressStage(Component component);
} }

View file

@ -11,41 +11,41 @@ import ru.bclib.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class ConfirmRestartScreen extends BCLibScreen { public class ConfirmRestartScreen extends BCLibScreen {
private final Component description; private final Component description;
private final ConfirmRestartScreen.Listener listener; private final ConfirmRestartScreen.Listener listener;
public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener) { public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener) {
this(listener, null); this(listener, null);
} }
public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener, Component message) { public ConfirmRestartScreen(ConfirmRestartScreen.Listener listener, Component message) {
super(new TranslatableComponent("title.bclib.confirmrestart")); super(new TranslatableComponent("title.bclib.confirmrestart"));
this.description = message==null?new TranslatableComponent("message.bclib.confirmrestart"):message; this.description = message==null?new TranslatableComponent("message.bclib.confirmrestart"):message;
this.listener = listener; this.listener = listener;
} }
protected void initLayout() { protected void initLayout() {
final int BUTTON_HEIGHT = 20; final int BUTTON_HEIGHT = 20;
grid.addRow().addMessage(this.description, this.font, Alignment.CENTER); grid.addRow().addMessage(this.description, this.font, Alignment.CENTER);
grid.addSpacerRow(); grid.addSpacerRow();
GridRow row = grid.addRow(); GridRow row = grid.addRow();
row.addFiller(); row.addFiller();
row.addButton(CommonComponents.GUI_PROCEED, BUTTON_HEIGHT, font, (button) -> { row.addButton(CommonComponents.GUI_PROCEED, BUTTON_HEIGHT, font, (button) -> {
listener.proceed(); listener.proceed();
}); });
row.addFiller(); row.addFiller();
} }
public boolean shouldCloseOnEsc() { public boolean shouldCloseOnEsc() {
return false; return false;
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public interface Listener { public interface Listener {
void proceed(); void proceed();
} }
} }

View file

@ -12,49 +12,49 @@ import ru.bclib.gui.gridlayout.GridRow;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class LevelFixErrorScreen extends BCLibScreen { public class LevelFixErrorScreen extends BCLibScreen {
private final String[] errors; private final String[] errors;
final Listener onContinue; final Listener onContinue;
public LevelFixErrorScreen(Screen parent, String[] errors, Listener onContinue) { public LevelFixErrorScreen(Screen parent, String[] errors, Listener onContinue) {
super(parent, new TranslatableComponent("title.bclib.datafixer.error"), 10, true); super(parent, new TranslatableComponent("title.bclib.datafixer.error"), 10, true);
this.errors = errors; this.errors = errors;
this.onContinue = onContinue; this.onContinue = onContinue;
} }
@Override @Override
protected void initLayout() { protected void initLayout() {
grid.addSpacerRow(); grid.addSpacerRow();
grid.addRow().addMessage(new TranslatableComponent("message.bclib.datafixer.error"), font, GridLayout.Alignment.CENTER); grid.addRow().addMessage(new TranslatableComponent("message.bclib.datafixer.error"), font, GridLayout.Alignment.CENTER);
grid.addSpacerRow(8); grid.addSpacerRow(8);
GridRow row = grid.addRow(); GridRow row = grid.addRow();
row.addSpacer(10); row.addSpacer(10);
GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT); GridColumn col = row.addColumn(300, GridLayout.GridValueType.CONSTANT);
for (String error : errors){ for (String error : errors){
TextComponent dash = new TextComponent("-"); TextComponent dash = new TextComponent("-");
row = col.addRow(); row = col.addRow();
row.addString(dash, this); row.addString(dash, this);
row.addSpacer(4); row.addSpacer(4);
row.addString(new TextComponent(error), this); row.addString(new TextComponent(error), this);
} }
grid.addSpacerRow(8); grid.addSpacerRow(8);
row = grid.addRow(); row = grid.addRow();
row.addFiller(); row.addFiller();
row.addButton(new TranslatableComponent("title.bclib.datafixer.error.continue"), 0.5f, 20, font, (n)-> { row.addButton(new TranslatableComponent("title.bclib.datafixer.error.continue"), 0.5f, 20, font, (n)-> {
onClose(); onClose();
onContinue.doContinue(true); onContinue.doContinue(true);
}); });
row.addSpacer(); row.addSpacer();
row.addButton(CommonComponents.GUI_CANCEL, 20, font, (n)-> { row.addButton(CommonComponents.GUI_CANCEL, 20, font, (n)-> {
this.minecraft.setScreen(null); this.minecraft.setScreen(null);
}); });
row.addFiller(); row.addFiller();
} }
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public interface Listener { public interface Listener {
void doContinue(boolean markFixed); void doContinue(boolean markFixed);
} }
} }

View file

@ -26,193 +26,193 @@ import java.util.stream.Collectors;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class ModListScreen extends BCLibScreen { public class ModListScreen extends BCLibScreen {
private final List<ModUtil.ModInfo> mods; private final List<ModUtil.ModInfo> mods;
private final HelloClient.IServerModMap serverInfo; private final HelloClient.IServerModMap serverInfo;
private final Component description; private final Component description;
private final Component buttonTitle; private final Component buttonTitle;
private static List<ModUtil.ModInfo> extractModList(Map<String, ModUtil.ModInfo> mods){ private static List<ModUtil.ModInfo> extractModList(Map<String, ModUtil.ModInfo> mods){
List<ModUtil.ModInfo> list = new LinkedList<ModUtil.ModInfo>(); List<ModUtil.ModInfo> list = new LinkedList<ModUtil.ModInfo>();
ModUtil.getMods().forEach((id, info) -> list.add(info)); ModUtil.getMods().forEach((id, info) -> list.add(info));
return list; return list;
} }
public ModListScreen(Screen parent, Component title, Component description, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) { public ModListScreen(Screen parent, Component title, Component description, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo); this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
} }
public ModListScreen(Screen parent, Component title, Component description, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) { public ModListScreen(Screen parent, Component title, Component description, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo); this(parent, title, description, CommonComponents.GUI_BACK, mods, serverInfo);
} }
public ModListScreen(Screen parent, Component title, Component description, Component button, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) { public ModListScreen(Screen parent, Component title, Component description, Component button, Map<String, ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
this(parent, title, description, button, extractModList(mods), serverInfo); this(parent, title, description, button, extractModList(mods), serverInfo);
} }
public ModListScreen(Screen parent, Component title, Component description, Component button, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) { public ModListScreen(Screen parent, Component title, Component description, Component button, List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo) {
super(parent, title, 10, true); super(parent, title, 10, true);
this.mods = mods; this.mods = mods;
this.serverInfo = serverInfo; this.serverInfo = serverInfo;
this.description = description; this.description = description;
this.buttonTitle = button; this.buttonTitle = button;
} }
public static List<String> localMissing(HelloClient.IServerModMap serverInfo){ public static List<String> localMissing(HelloClient.IServerModMap serverInfo){
return serverInfo.keySet() return serverInfo.keySet()
.stream() .stream()
.filter(modid -> !ModUtil.getMods().keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList()); .filter(modid -> !ModUtil.getMods().keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList());
} }
public static List<String> serverMissing(HelloClient.IServerModMap serverInfo){ public static List<String> serverMissing(HelloClient.IServerModMap serverInfo){
return ModUtil.getMods().entrySet() return ModUtil.getMods().entrySet()
.stream() .stream()
.filter(entry -> entry.getValue().metadata.getEnvironment() != ModEnvironment.CLIENT) .filter(entry -> entry.getValue().metadata.getEnvironment() != ModEnvironment.CLIENT)
.map(entry -> entry.getKey()) .map(entry -> entry.getKey())
.filter(modid -> !serverInfo.keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList()); .filter(modid -> !serverInfo.keySet().stream().filter(mod -> mod.equals(modid)).findFirst().isPresent()).collect(Collectors.toList());
} }
public static void addModDesc(GridColumn grid, java.util.List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo, GridScreen parent) { public static void addModDesc(GridColumn grid, java.util.List<ModUtil.ModInfo> mods, HelloClient.IServerModMap serverInfo, GridScreen parent) {
final int STATE_OK = 6; final int STATE_OK = 6;
final int STATE_SERVER_MISSING_CLIENT_MOD = 5; final int STATE_SERVER_MISSING_CLIENT_MOD = 5;
final int STATE_MISSING_NOT_OFFERED = 4; final int STATE_MISSING_NOT_OFFERED = 4;
final int STATE_VERSION_NOT_OFFERED = 3; final int STATE_VERSION_NOT_OFFERED = 3;
final int STATE_VERSION = 2; final int STATE_VERSION = 2;
final int STATE_SERVER_MISSING = 1; final int STATE_SERVER_MISSING = 1;
final int STATE_MISSING = 0; final int STATE_MISSING = 0;
List<Triple<String, Integer, String>> items = new LinkedList<>(); List<Triple<String, Integer, String>> items = new LinkedList<>();
if (serverInfo!=null) { if (serverInfo!=null) {
serverInfo.keySet() serverInfo.keySet()
.stream() .stream()
.filter(modid -> !mods.stream().filter(mod -> mod.metadata.getId().equals(modid)).findFirst().isPresent()) .filter(modid -> !mods.stream().filter(mod -> mod.metadata.getId().equals(modid)).findFirst().isPresent())
.forEach(modid -> { .forEach(modid -> {
HelloClient.OfferedModInfo nfo = serverInfo.get(modid); HelloClient.OfferedModInfo nfo = serverInfo.get(modid);
String stateString = nfo.version(); String stateString = nfo.version();
if (nfo.size()>0) { if (nfo.size()>0) {
stateString = "Version: " + stateString + ", Size: " + PathUtil.humanReadableFileSize(nfo.size()); stateString = "Version: " + stateString + ", Size: " + PathUtil.humanReadableFileSize(nfo.size());
} }
if (nfo.canDownload()) { if (nfo.canDownload()) {
stateString += ", offered by server"; stateString += ", offered by server";
} }
items.add(new Triple<>(modid, nfo.canDownload()?STATE_MISSING:STATE_MISSING_NOT_OFFERED, stateString)); items.add(new Triple<>(modid, nfo.canDownload()?STATE_MISSING:STATE_MISSING_NOT_OFFERED, stateString));
}); });
} }
mods.forEach(mod -> { mods.forEach(mod -> {
String serverVersion = null; String serverVersion = null;
int serverSize = 0; int serverSize = 0;
int state = STATE_OK; int state = STATE_OK;
if (serverInfo != null) { if (serverInfo != null) {
final String modID = mod.metadata.getId(); final String modID = mod.metadata.getId();
HelloClient.OfferedModInfo data = serverInfo.get(modID); HelloClient.OfferedModInfo data = serverInfo.get(modID);
if (data!=null) { if (data!=null) {
final String modVer = data.version(); final String modVer = data.version();
final int size = data.size(); final int size = data.size();
if (!modVer.equals(mod.getVersion())) { if (!modVer.equals(mod.getVersion())) {
state = data.canDownload()?STATE_VERSION:STATE_VERSION_NOT_OFFERED; state = data.canDownload()?STATE_VERSION:STATE_VERSION_NOT_OFFERED;
serverVersion = modVer; serverVersion = modVer;
serverSize = size; serverSize = size;
} }
} else if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT){ } else if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT){
state = STATE_SERVER_MISSING_CLIENT_MOD; state = STATE_SERVER_MISSING_CLIENT_MOD;
} else { } else {
state = STATE_SERVER_MISSING; state = STATE_SERVER_MISSING;
} }
} }
String stateString = mod.metadata.getVersion().toString(); String stateString = mod.metadata.getVersion().toString();
if (serverVersion!=null) { if (serverVersion!=null) {
stateString = "Client: " + stateString; stateString = "Client: " + stateString;
stateString += ", Server: " + serverVersion; stateString += ", Server: " + serverVersion;
if (serverSize>0) { if (serverSize>0) {
stateString += ", Size: " + PathUtil.humanReadableFileSize(serverSize); stateString += ", Size: " + PathUtil.humanReadableFileSize(serverSize);
} }
} }
if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT) { if (mod.metadata.getEnvironment() == ModEnvironment.CLIENT) {
stateString+= ", client-only"; stateString+= ", client-only";
} else if (mod.metadata.getEnvironment() == ModEnvironment.SERVER) { } else if (mod.metadata.getEnvironment() == ModEnvironment.SERVER) {
stateString+= ", server-only"; stateString+= ", server-only";
} }
items.add(new Triple<>(mod.metadata.getName(), state, stateString)); items.add(new Triple<>(mod.metadata.getName(), state, stateString));
}); });
items.stream() items.stream()
.sorted(Comparator.comparing(a -> a.second + a.first.toLowerCase(Locale.ROOT))) .sorted(Comparator.comparing(a -> a.second + a.first.toLowerCase(Locale.ROOT)))
.forEach(t -> { .forEach(t -> {
final String name = t.first; final String name = t.first;
final int state = t.second; final int state = t.second;
final String stateString = t.third; final String stateString = t.third;
int color = GridLayout.COLOR_RED; int color = GridLayout.COLOR_RED;
final String typeText; final String typeText;
if (state==STATE_VERSION || state==STATE_VERSION_NOT_OFFERED) { if (state==STATE_VERSION || state==STATE_VERSION_NOT_OFFERED) {
typeText = "[VERSION]"; typeText = "[VERSION]";
if (state == STATE_VERSION_NOT_OFFERED) { if (state == STATE_VERSION_NOT_OFFERED) {
color = GridLayout.COLOR_YELLOW; color = GridLayout.COLOR_YELLOW;
} }
} else if (state==STATE_MISSING || state==STATE_MISSING_NOT_OFFERED) { } else if (state==STATE_MISSING || state==STATE_MISSING_NOT_OFFERED) {
typeText = "[MISSING]"; typeText = "[MISSING]";
if (state == STATE_MISSING_NOT_OFFERED) { if (state == STATE_MISSING_NOT_OFFERED) {
color = GridLayout.COLOR_YELLOW; color = GridLayout.COLOR_YELLOW;
} }
} else if (state==STATE_SERVER_MISSING || state == STATE_SERVER_MISSING_CLIENT_MOD) { } else if (state==STATE_SERVER_MISSING || state == STATE_SERVER_MISSING_CLIENT_MOD) {
if (state == STATE_SERVER_MISSING_CLIENT_MOD) { if (state == STATE_SERVER_MISSING_CLIENT_MOD) {
color = GridLayout.COLOR_CYAN; color = GridLayout.COLOR_CYAN;
typeText = "[OK]"; typeText = "[OK]";
} else { } else {
typeText = "[NOT ON SERVER]"; typeText = "[NOT ON SERVER]";
} }
} else { } else {
color = GridLayout.COLOR_DARK_GREEN; color = GridLayout.COLOR_DARK_GREEN;
typeText = "[OK]"; typeText = "[OK]";
} }
TextComponent dash = new TextComponent("-"); TextComponent dash = new TextComponent("-");
TextComponent typeTextComponent = new TextComponent(typeText); TextComponent typeTextComponent = new TextComponent(typeText);
GridRow row = grid.addRow(); GridRow row = grid.addRow();
row.addString(dash, parent); row.addString(dash, parent);
row.addSpacer(4); row.addSpacer(4);
row.addString(new TextComponent(name), parent); row.addString(new TextComponent(name), parent);
row.addSpacer(4); row.addSpacer(4);
row.addString(typeTextComponent, color, parent); row.addString(typeTextComponent, color, parent);
if (!stateString.isEmpty()) { if (!stateString.isEmpty()) {
row = grid.addRow(); row = grid.addRow();
row.addSpacer(4 + parent.getWidth(dash)); row.addSpacer(4 + parent.getWidth(dash));
row.addString(new TextComponent(stateString), GridLayout.COLOR_GRAY, parent); row.addString(new TextComponent(stateString), GridLayout.COLOR_GRAY, parent);
} }
grid.addSpacerRow(); grid.addSpacerRow();
}); });
} }
@Override @Override
protected void initLayout() { protected void initLayout() {
if (description != null) { if (description != null) {
grid.addSpacerRow(); grid.addSpacerRow();
grid.addRow().addMessage(description, font, GridLayout.Alignment.CENTER); grid.addRow().addMessage(description, font, GridLayout.Alignment.CENTER);
grid.addSpacerRow(8); grid.addSpacerRow(8);
} }
GridRow row = grid.addRow(); GridRow row = grid.addRow();
row.addSpacer(10); row.addSpacer(10);
GridColumn col = row.addColumn(200, GridLayout.GridValueType.CONSTANT); GridColumn col = row.addColumn(200, GridLayout.GridValueType.CONSTANT);
addModDesc(col, mods, serverInfo, this); addModDesc(col, mods, serverInfo, this);
grid.addSpacerRow(8); grid.addSpacerRow(8);
row = grid.addRow(); row = grid.addRow();
row.addFiller(); row.addFiller();
row.addButton(buttonTitle, 20, font, (n)-> { row.addButton(buttonTitle, 20, font, (n)-> {
onClose(); onClose();
}); });
row.addFiller(); row.addFiller();
} }
} }

View file

@ -55,16 +55,16 @@ class ModMenuScreenFactoryImpl {
* <p> * <p>
* Example: * Example:
* <pre>{@code public class ModMenu extends ModMenuIntegration { * <pre>{@code public class ModMenu extends ModMenuIntegration {
* public static final ModMenuApiMarker entrypointObject = createEntrypoint(new EntryPoint()); * public static final ModMenuApiMarker entrypointObject = createEntrypoint(new EntryPoint());
* *
* public EntryPoint() { * public EntryPoint() {
* super(GridScreen::new); * super(GridScreen::new);
* } * }
* }}</pre> * }}</pre>
* You'd also need to add the ModMenu-Entrypoint to your <i>fabric.mod.json</i>: * You'd also need to add the ModMenu-Entrypoint to your <i>fabric.mod.json</i>:
* <pre>"entrypoints": { * <pre>"entrypoints": {
* ... * ...
* "modmenu": [ "your.mod.ModMenu::entrypointObject" ] * "modmenu": [ "your.mod.ModMenu::entrypointObject" ]
* }</pre> * }</pre>
*/ */
public abstract class ModMenuIntegration { public abstract class ModMenuIntegration {
@ -101,7 +101,7 @@ public abstract class ModMenuIntegration {
/** /**
* Create a new ModMenu delegate * Create a new ModMenu delegate
* @param screenFactory A Factory. The Factory receives the currently visible {@code parent}-Screen * @param screenFactory A Factory. The Factory receives the currently visible {@code parent}-Screen
* and must return a new Screen Object. * and must return a new Screen Object.
*/ */
public ModMenuIntegration(ModMenuScreenFactory screenFactory){ public ModMenuIntegration(ModMenuScreenFactory screenFactory){
this.screenFactory = screenFactory; this.screenFactory = screenFactory;

View file

@ -3,7 +3,7 @@ package ru.bclib.interfaces;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
public interface SurfaceMaterialProvider { public interface SurfaceMaterialProvider {
BlockState getTopMaterial(); BlockState getTopMaterial();
BlockState getUnderMaterial(); BlockState getUnderMaterial();
BlockState getAltTopMaterial(); BlockState getAltTopMaterial();
} }

View file

@ -2,5 +2,5 @@ package ru.bclib.interfaces;
@FunctionalInterface @FunctionalInterface
public interface TriConsumer<A, B, C> { public interface TriConsumer<A, B, C> {
void accept(A a, B b, C c); void accept(A a, B b, C c);
} }

View file

@ -1,12 +1,6 @@
package ru.bclib.mixin.client; package ru.bclib.mixin.client;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.mojang.datafixers.util.Function4; import com.mojang.datafixers.util.Function4;
import net.fabricmc.fabric.api.event.registry.DynamicRegistrySetupCallback;
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.Minecraft.ExperimentalDialogType; import net.minecraft.client.Minecraft.ExperimentalDialogType;
import net.minecraft.client.color.block.BlockColors; import net.minecraft.client.color.block.BlockColors;
@ -15,17 +9,10 @@ import net.minecraft.client.main.GameConfig;
import net.minecraft.core.Registry; import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess; import net.minecraft.core.RegistryAccess;
import net.minecraft.core.RegistryAccess.RegistryHolder; import net.minecraft.core.RegistryAccess.RegistryHolder;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.packs.resources.ResourceManager; import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.world.level.DataPackConfig; import net.minecraft.world.level.DataPackConfig;
import net.minecraft.world.level.LevelSettings; import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.WorldGenSettings; import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
import net.minecraft.world.level.levelgen.feature.StructureFeature;
import net.minecraft.world.level.storage.LevelStorageSource; import net.minecraft.world.level.storage.LevelStorageSource;
import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess;
import net.minecraft.world.level.storage.WorldData; import net.minecraft.world.level.storage.WorldData;
@ -35,18 +22,12 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ru.bclib.BCLib;
import ru.bclib.api.LifeCycleAPI; import ru.bclib.api.LifeCycleAPI;
import ru.bclib.api.biomes.BiomeAPI; import ru.bclib.api.biomes.BiomeAPI;
import ru.bclib.api.dataexchange.DataExchangeAPI; import ru.bclib.api.dataexchange.DataExchangeAPI;
import ru.bclib.api.datafixer.DataFixerAPI; import ru.bclib.api.datafixer.DataFixerAPI;
import ru.bclib.interfaces.CustomColorProvider; import ru.bclib.interfaces.CustomColorProvider;
import ru.bclib.mixin.common.StructureSettingsAccessor;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
@Mixin(Minecraft.class) @Mixin(Minecraft.class)

View file

@ -31,35 +31,35 @@ import java.util.concurrent.CompletableFuture;
@Mixin(MinecraftServer.class) @Mixin(MinecraftServer.class)
public class MinecraftServerMixin { public class MinecraftServerMixin {
@Shadow @Shadow
private ServerResources resources; private ServerResources resources;
@Final @Final
@Shadow @Shadow
private Map<ResourceKey<Level>, ServerLevel> levels; private Map<ResourceKey<Level>, ServerLevel> levels;
@Final @Final
@Shadow @Shadow
protected WorldData worldData; protected WorldData worldData;
@Inject(method = "<init>*", at = @At("TAIL")) @Inject(method = "<init>*", at = @At("TAIL"))
private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) { private void bclib_onServerInit(Thread thread, RegistryHolder registryHolder, LevelStorageAccess levelStorageAccess, WorldData worldData, PackRepository packRepository, Proxy proxy, DataFixer dataFixer, ServerResources serverResources, MinecraftSessionService minecraftSessionService, GameProfileRepository gameProfileRepository, GameProfileCache gameProfileCache, ChunkProgressListenerFactory chunkProgressListenerFactory, CallbackInfo ci) {
DataExchangeAPI.prepareServerside(); DataExchangeAPI.prepareServerside();
} }
@Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true) @Inject(method = "reloadResources", at = @At(value = "RETURN"), cancellable = true)
private void bclib_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) { private void bclib_reloadResources(Collection<String> collection, CallbackInfoReturnable<CompletableFuture<Void>> info) {
bclib_injectRecipes(); bclib_injectRecipes();
} }
@Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true) @Inject(method = "loadLevel", at = @At(value = "RETURN"), cancellable = true)
private void bclib_loadLevel(CallbackInfo info) { private void bclib_loadLevel(CallbackInfo info) {
bclib_injectRecipes(); bclib_injectRecipes();
//BiomeAPI.initRegistry(MinecraftServer.class.cast(this)); //BiomeAPI.initRegistry(MinecraftServer.class.cast(this));
} }
private void bclib_injectRecipes() { private void bclib_injectRecipes() {
RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager(); RecipeManagerAccessor accessor = (RecipeManagerAccessor) resources.getRecipeManager();
accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes())); accessor.bclib_setRecipes(BCLRecipeManager.getMap(accessor.bclib_getRecipes()));
} }
} }

View file

@ -12,8 +12,8 @@ import ru.bclib.world.biomes.FabricBiomesData;
@Mixin(value = NetherBiomeData.class, remap = false) @Mixin(value = NetherBiomeData.class, remap = false)
public class NetherBiomeDataMixin { public class NetherBiomeDataMixin {
@Inject(method = "addNetherBiome", at = @At(value = "HEAD")) @Inject(method = "addNetherBiome", at = @At(value = "HEAD"))
private static void bclib_addNetherBiome(ResourceKey<Biome> biome, Climate.ParameterPoint spawnNoisePoint, CallbackInfo info) { private static void bclib_addNetherBiome(ResourceKey<Biome> biome, Climate.ParameterPoint spawnNoisePoint, CallbackInfo info) {
FabricBiomesData.NETHER_BIOMES.add(biome); FabricBiomesData.NETHER_BIOMES.add(biome);
} }
} }

View file

@ -3,7 +3,6 @@ package ru.bclib.mixin.common;
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
import net.minecraft.world.level.levelgen.SurfaceRules; import net.minecraft.world.level.levelgen.SurfaceRules;
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource; import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
import org.apache.commons.codec.language.bm.Rule;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Mutable;

View file

@ -12,39 +12,39 @@ import java.util.function.Supplier;
@Mixin(SurfaceRules.Context.class) @Mixin(SurfaceRules.Context.class)
public interface SurfaceRulesContextAccessor { public interface SurfaceRulesContextAccessor {
@Accessor("blockX") @Accessor("blockX")
int getBlockX(); int getBlockX();
@Accessor("blockY") @Accessor("blockY")
int getBlockY(); int getBlockY();
@Accessor("blockZ") @Accessor("blockZ")
int getBlockZ(); int getBlockZ();
@Accessor("surfaceDepth") @Accessor("surfaceDepth")
int getSurfaceDepth(); int getSurfaceDepth();
@Accessor("biome") @Accessor("biome")
Supplier<Biome> getBiome(); Supplier<Biome> getBiome();
@Accessor("biomeKey") @Accessor("biomeKey")
Supplier<ResourceKey<Biome>> getBiomeKey(); Supplier<ResourceKey<Biome>> getBiomeKey();
@Accessor("chunk") @Accessor("chunk")
ChunkAccess getChunk(); ChunkAccess getChunk();
@Accessor("noiseChunk") @Accessor("noiseChunk")
NoiseChunk getNoiseChunk(); NoiseChunk getNoiseChunk();
@Accessor("stoneDepthAbove") @Accessor("stoneDepthAbove")
int getStoneDepthAbove(); int getStoneDepthAbove();
@Accessor("stoneDepthBelow") @Accessor("stoneDepthBelow")
int getStoneDepthBelow(); int getStoneDepthBelow();
@Accessor("lastUpdateY") @Accessor("lastUpdateY")
long getLastUpdateY(); long getLastUpdateY();
@Accessor("lastUpdateXZ") @Accessor("lastUpdateXZ")
long getLastUpdateXZ(); long getLastUpdateXZ();
} }

View file

@ -12,24 +12,24 @@ import ru.bclib.world.biomes.FabricBiomesData;
@Mixin(value = TheEndBiomeData.class, remap = false) @Mixin(value = TheEndBiomeData.class, remap = false)
public class TheEndBiomeDataMixin { public class TheEndBiomeDataMixin {
@Inject(method = "addEndBiomeReplacement", at = @At(value = "HEAD")) @Inject(method = "addEndBiomeReplacement", at = @At(value = "HEAD"))
private static void bclib_addEndBiomeReplacement(ResourceKey<Biome> replaced, ResourceKey<Biome> variant, double weight, CallbackInfo info) { private static void bclib_addEndBiomeReplacement(ResourceKey<Biome> replaced, ResourceKey<Biome> variant, double weight, CallbackInfo info) {
if (replaced == Biomes.END_BARRENS || replaced == Biomes.SMALL_END_ISLANDS) { if (replaced == Biomes.END_BARRENS || replaced == Biomes.SMALL_END_ISLANDS) {
FabricBiomesData.END_VOID_BIOMES.put(variant, (float) weight); FabricBiomesData.END_VOID_BIOMES.put(variant, (float) weight);
} }
else { else {
FabricBiomesData.END_LAND_BIOMES.put(variant, (float) weight); FabricBiomesData.END_LAND_BIOMES.put(variant, (float) weight);
} }
} }
@Inject(method = "addEndMidlandsReplacement", at = @At(value = "HEAD")) @Inject(method = "addEndMidlandsReplacement", at = @At(value = "HEAD"))
private static void bclib_addEndMidlandsReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> midlands, double weight, CallbackInfo info) { private static void bclib_addEndMidlandsReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> midlands, double weight, CallbackInfo info) {
FabricBiomesData.END_LAND_BIOMES.put(midlands, (float) weight); FabricBiomesData.END_LAND_BIOMES.put(midlands, (float) weight);
} }
@Inject(method = "addEndBarrensReplacement", at = @At(value = "HEAD")) @Inject(method = "addEndBarrensReplacement", at = @At(value = "HEAD"))
private static void bclib_addEndBarrensReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> barrens, double weight, CallbackInfo info) { private static void bclib_addEndBarrensReplacement(ResourceKey<Biome> highlands, ResourceKey<Biome> barrens, double weight, CallbackInfo info) {
FabricBiomesData.END_LAND_BIOMES.put(barrens, (float) weight); FabricBiomesData.END_LAND_BIOMES.put(barrens, (float) weight);
FabricBiomesData.END_VOID_BIOMES.put(barrens, (float) weight); FabricBiomesData.END_VOID_BIOMES.put(barrens, (float) weight);
} }
} }

View file

@ -33,301 +33,299 @@ import ru.bclib.util.RecipeHelper;
import java.util.Objects; import java.util.Objects;
public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory { public class AnvilRecipe implements Recipe<Container>, UnknownReceipBookCategory {
public final static String GROUP = "smithing"; public final static String GROUP = "smithing";
public final static RecipeType<AnvilRecipe> TYPE = BCLRecipeManager.registerType(BCLib.MOD_ID, GROUP); public final static RecipeType<AnvilRecipe> TYPE = BCLRecipeManager.registerType(BCLib.MOD_ID, GROUP);
public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer( public final static Serializer SERIALIZER = BCLRecipeManager.registerSerializer(
BCLib.MOD_ID, BCLib.MOD_ID,
GROUP, GROUP,
new Serializer() new Serializer()
); );
public final static ResourceLocation ID = BCLib.makeID(GROUP); public final static ResourceLocation ID = BCLib.makeID(GROUP);
private final ResourceLocation id; private final ResourceLocation id;
private final Ingredient input; private final Ingredient input;
private final ItemStack output; private final ItemStack output;
private final int damage; private final int damage;
private final int toolLevel; private final int toolLevel;
private final int anvilLevel; private final int anvilLevel;
private final int inputCount; private final int inputCount;
public AnvilRecipe(ResourceLocation identifier, Ingredient input, ItemStack output, int inputCount, int toolLevel, int anvilLevel, int damage) { public AnvilRecipe(ResourceLocation identifier, Ingredient input, ItemStack output, int inputCount, int toolLevel, int anvilLevel, int damage) {
this.id = identifier; this.id = identifier;
this.input = input; this.input = input;
this.output = output; this.output = output;
this.toolLevel = toolLevel; this.toolLevel = toolLevel;
this.anvilLevel = anvilLevel; this.anvilLevel = anvilLevel;
this.inputCount = inputCount; this.inputCount = inputCount;
this.damage = damage; this.damage = damage;
} }
public static Builder create(String id) { public static Builder create(String id) {
return create(BCLib.makeID(id)); return create(BCLib.makeID(id));
} }
public static Builder create(ResourceLocation id) { public static Builder create(ResourceLocation id) {
Builder.INSTANCE.id = id; Builder.INSTANCE.id = id;
Builder.INSTANCE.input = null; Builder.INSTANCE.input = null;
Builder.INSTANCE.output = null; Builder.INSTANCE.output = null;
Builder.INSTANCE.inputCount = 1; Builder.INSTANCE.inputCount = 1;
Builder.INSTANCE.toolLevel = 1; Builder.INSTANCE.toolLevel = 1;
Builder.INSTANCE.anvilLevel = 1; Builder.INSTANCE.anvilLevel = 1;
Builder.INSTANCE.damage = 1; Builder.INSTANCE.damage = 1;
Builder.INSTANCE.alright = true; Builder.INSTANCE.alright = true;
Builder.INSTANCE.exist = true; Builder.INSTANCE.exist = true;
return Builder.INSTANCE; return Builder.INSTANCE;
} }
@Override @Override
public RecipeSerializer<?> getSerializer() { public RecipeSerializer<?> getSerializer() {
return SERIALIZER; return SERIALIZER;
} }
@Override @Override
public ItemStack getResultItem() { public ItemStack getResultItem() {
return this.output; return this.output;
} }
@Override @Override
public boolean matches(Container craftingInventory, Level world) { public boolean matches(Container craftingInventory, Level world) {
return this.matches(craftingInventory); return this.matches(craftingInventory);
} }
@Override @Override
public ItemStack assemble(Container craftingInventory) { public ItemStack assemble(Container craftingInventory) {
return this.output.copy(); return this.output.copy();
} }
public ItemStack craft(Container craftingInventory, Player player) { public ItemStack craft(Container craftingInventory, Player player) {
if (!player.isCreative()) { if (!player.isCreative()) {
if (!checkHammerDurability(craftingInventory, player)) return ItemStack.EMPTY; if (!checkHammerDurability(craftingInventory, player)) return ItemStack.EMPTY;
ItemStack hammer = craftingInventory.getItem(1); ItemStack hammer = craftingInventory.getItem(1);
hammer.hurtAndBreak(this.damage, player, entity -> entity.broadcastBreakEvent((InteractionHand) null)); hammer.hurtAndBreak(this.damage, player, entity -> entity.broadcastBreakEvent((InteractionHand) null));
} }
return this.assemble(craftingInventory); return this.assemble(craftingInventory);
} }
public boolean checkHammerDurability(Container craftingInventory, Player player) { public boolean checkHammerDurability(Container craftingInventory, Player player) {
if (player.isCreative()) return true; if (player.isCreative()) return true;
ItemStack hammer = craftingInventory.getItem(1); ItemStack hammer = craftingInventory.getItem(1);
int damage = hammer.getDamageValue() + this.damage; int damage = hammer.getDamageValue() + this.damage;
return damage < hammer.getMaxDamage(); return damage < hammer.getMaxDamage();
} }
public boolean matches(Container craftingInventory) { public boolean matches(Container craftingInventory) {
ItemStack hammer = craftingInventory.getItem(1); ItemStack hammer = craftingInventory.getItem(1);
if (hammer.isEmpty() || !TagAPI.ITEM_HAMMERS.contains(hammer.getItem())) { if (hammer.isEmpty() || !TagAPI.ITEM_HAMMERS.contains(hammer.getItem())) {
return false; return false;
} }
ItemStack material = craftingInventory.getItem(0); ItemStack material = craftingInventory.getItem(0);
int materialCount = material.getCount(); int materialCount = material.getCount();
int level = ((TieredItem) hammer.getItem()).getTier().getLevel(); int level = ((TieredItem) hammer.getItem()).getTier().getLevel();
return this.input.test(craftingInventory.getItem(0)) && materialCount >= this.inputCount && level >= this.toolLevel; return this.input.test(craftingInventory.getItem(0)) && materialCount >= this.inputCount && level >= this.toolLevel;
} }
public int getDamage() { public int getDamage() {
return this.damage; return this.damage;
} }
public int getInputCount() { public int getInputCount() {
return this.inputCount; return this.inputCount;
} }
public int getAnvilLevel() { public int getAnvilLevel() {
return this.anvilLevel; return this.anvilLevel;
} }
@Override @Override
public NonNullList<Ingredient> getIngredients() { public NonNullList<Ingredient> getIngredients() {
NonNullList<Ingredient> defaultedList = NonNullList.create(); NonNullList<Ingredient> defaultedList = NonNullList.create();
defaultedList.add(Ingredient.of(TagAPI.ITEM_HAMMERS defaultedList.add(Ingredient.of(TagAPI.ITEM_HAMMERS
.getValues() .getValues()
.stream() .stream()
.filter(hammer -> ((TieredItem) hammer).getTier().getLevel() >= toolLevel) .filter(hammer -> ((TieredItem) hammer).getTier().getLevel() >= toolLevel)
.map(ItemStack::new))); .map(ItemStack::new)));
defaultedList.add(input); defaultedList.add(input);
return defaultedList; return defaultedList;
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public boolean canCraftInDimensions(int width, int height) { public boolean canCraftInDimensions(int width, int height) {
return true; return true;
} }
@Override @Override
public ResourceLocation getId() { public ResourceLocation getId() {
return this.id; return this.id;
} }
@Override @Override
public RecipeType<?> getType() { public RecipeType<?> getType() {
return TYPE; return TYPE;
} }
@Override @Override
public boolean isSpecial() { public boolean isSpecial() {
return true; return true;
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
AnvilRecipe that = (AnvilRecipe) o; AnvilRecipe that = (AnvilRecipe) o;
return damage == that.damage && toolLevel == that.toolLevel && id.equals(that.id) && input.equals(that.input) && output return damage == that.damage && toolLevel == that.toolLevel && id.equals(that.id) && input.equals(that.input) && output.equals(that.output);
.equals(that.output); }
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, input, output, damage, toolLevel); return Objects.hash(id, input, output, damage, toolLevel);
} }
@Override @Override
public String toString() { public String toString() {
return "AnvilRecipe [" + id + "]"; return "AnvilRecipe [" + id + "]";
} }
public static class Builder { public static class Builder {
private final static Builder INSTANCE = new Builder(); private final static Builder INSTANCE = new Builder();
private ResourceLocation id; private ResourceLocation id;
private Ingredient input; private Ingredient input;
private ItemStack output; private ItemStack output;
private int inputCount = 1; private int inputCount = 1;
private int toolLevel = 1; private int toolLevel = 1;
private int anvilLevel = 1; private int anvilLevel = 1;
private int damage = 1; private int damage = 1;
private boolean alright; private boolean alright;
private boolean exist; private boolean exist;
private Builder() { } private Builder() {}
public Builder setInput(ItemLike... inputItems) { public Builder setInput(ItemLike... inputItems) {
this.alright &= RecipeHelper.exists(inputItems); this.alright &= RecipeHelper.exists(inputItems);
this.setInput(Ingredient.of(inputItems)); this.setInput(Ingredient.of(inputItems));
return this; return this;
} }
public Builder setInput(Tag<Item> inputTag) { public Builder setInput(Tag<Item> inputTag) {
this.setInput(Ingredient.of(inputTag)); this.setInput(Ingredient.of(inputTag));
return this; return this;
} }
public Builder setInput(Ingredient ingredient) { public Builder setInput(Ingredient ingredient) {
this.input = ingredient; this.input = ingredient;
return this; return this;
} }
public Builder setInputCount(int count) { public Builder setInputCount(int count) {
this.inputCount = count; this.inputCount = count;
return this; return this;
} }
public Builder setOutput(ItemLike output) { public Builder setOutput(ItemLike output) {
return this.setOutput(output, 1); return this.setOutput(output, 1);
} }
public Builder setOutput(ItemLike output, int amount) { public Builder setOutput(ItemLike output, int amount) {
this.alright &= RecipeHelper.exists(output); this.alright &= RecipeHelper.exists(output);
this.output = new ItemStack(output, amount); this.output = new ItemStack(output, amount);
return this; return this;
} }
public Builder setToolLevel(int level) { public Builder setToolLevel(int level) {
this.toolLevel = level; this.toolLevel = level;
return this; return this;
} }
public Builder setAnvilLevel(int level) { public Builder setAnvilLevel(int level) {
this.anvilLevel = level; this.anvilLevel = level;
return this; return this;
} }
public Builder setDamage(int damage) { public Builder setDamage(int damage) {
this.damage = damage; this.damage = damage;
return this; return this;
} }
public Builder checkConfig(PathConfig config) { public Builder checkConfig(PathConfig config) {
exist &= config.getBoolean("anvil", id.getPath(), true); exist &= config.getBoolean("anvil", id.getPath(), true);
return this; return this;
} }
public void build() { public void build() {
if (exist) { if (exist) {
if (input == null) { return;
BCLib.LOGGER.warning("Input for Anvil recipe can't be 'null', recipe {} will be ignored!", id); }
return;
} if (input == null) {
if (output == null) { BCLib.LOGGER.warning("Input for Anvil recipe can't be 'null', recipe {} will be ignored!", id);
BCLib.LOGGER.warning("Output for Anvil recipe can't be 'null', recipe {} will be ignored!", id); return;
return; }
} if (output == null) {
if (BCLRecipeManager.getRecipe(TYPE, id) != null) { BCLib.LOGGER.warning("Output for Anvil recipe can't be 'null', recipe {} will be ignored!", id);
BCLib.LOGGER.warning("Can't add Anvil recipe! Id {} already exists!", id); return;
return; }
} if (BCLRecipeManager.getRecipe(TYPE, id) != null) {
if (!alright) { BCLib.LOGGER.warning("Can't add Anvil recipe! Id {} already exists!", id);
BCLib.LOGGER.debug("Can't add Anvil recipe {}! Ingeredient or output not exists.", id); return;
return; }
} if (!alright) {
BCLRecipeManager.addRecipe( BCLib.LOGGER.debug("Can't add Anvil recipe {}! Ingeredient or output not exists.", id);
TYPE, return;
new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage) }
); BCLRecipeManager.addRecipe(TYPE, new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage));
} }
} }
}
public static class Serializer implements RecipeSerializer<AnvilRecipe> { public static class Serializer implements RecipeSerializer<AnvilRecipe> {
@Override @Override
public AnvilRecipe fromJson(ResourceLocation id, JsonObject json) { public AnvilRecipe fromJson(ResourceLocation id, JsonObject json) {
Ingredient input = Ingredient.fromJson(json.get("input")); Ingredient input = Ingredient.fromJson(json.get("input"));
JsonObject result = GsonHelper.getAsJsonObject(json, "result"); JsonObject result = GsonHelper.getAsJsonObject(json, "result");
ItemStack output = ItemUtil.fromJsonRecipe(result); ItemStack output = ItemUtil.fromJsonRecipe(result);
if (output == null) { if (output == null) {
throw new IllegalStateException("Output item does not exists!"); throw new IllegalStateException("Output item does not exists!");
} }
if (result.has("nbt")) { if (result.has("nbt")) {
try { try {
String nbtData = GsonHelper.getAsString(result, "nbt"); String nbtData = GsonHelper.getAsString(result, "nbt");
CompoundTag nbt = TagParser.parseTag(nbtData); CompoundTag nbt = TagParser.parseTag(nbtData);
output.setTag(nbt); output.setTag(nbt);
} }
catch (CommandSyntaxException ex) { catch (CommandSyntaxException ex) {
BCLib.LOGGER.warning("Error parse nbt data for output.", ex); BCLib.LOGGER.warning("Error parse nbt data for output.", ex);
} }
} }
int inputCount = GsonHelper.getAsInt(json, "inputCount", 1); int inputCount = GsonHelper.getAsInt(json, "inputCount", 1);
int toolLevel = GsonHelper.getAsInt(json, "toolLevel", 1); int toolLevel = GsonHelper.getAsInt(json, "toolLevel", 1);
int anvilLevel = GsonHelper.getAsInt(json, "anvilLevel", 1); int anvilLevel = GsonHelper.getAsInt(json, "anvilLevel", 1);
int damage = GsonHelper.getAsInt(json, "damage", 1); int damage = GsonHelper.getAsInt(json, "damage", 1);
return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage); return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage);
} }
@Override @Override
public AnvilRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf packetBuffer) { public AnvilRecipe fromNetwork(ResourceLocation id, FriendlyByteBuf packetBuffer) {
Ingredient input = Ingredient.fromNetwork(packetBuffer); Ingredient input = Ingredient.fromNetwork(packetBuffer);
ItemStack output = packetBuffer.readItem(); ItemStack output = packetBuffer.readItem();
int inputCount = packetBuffer.readVarInt(); int inputCount = packetBuffer.readVarInt();
int toolLevel = packetBuffer.readVarInt(); int toolLevel = packetBuffer.readVarInt();
int anvilLevel = packetBuffer.readVarInt(); int anvilLevel = packetBuffer.readVarInt();
int damage = packetBuffer.readVarInt(); int damage = packetBuffer.readVarInt();
return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage); return new AnvilRecipe(id, input, output, inputCount, toolLevel, anvilLevel, damage);
} }
@Override @Override
public void toNetwork(FriendlyByteBuf packetBuffer, AnvilRecipe recipe) { public void toNetwork(FriendlyByteBuf packetBuffer, AnvilRecipe recipe) {
recipe.input.toNetwork(packetBuffer); recipe.input.toNetwork(packetBuffer);
packetBuffer.writeItem(recipe.output); packetBuffer.writeItem(recipe.output);
packetBuffer.writeVarInt(recipe.inputCount); packetBuffer.writeVarInt(recipe.inputCount);
packetBuffer.writeVarInt(recipe.toolLevel); packetBuffer.writeVarInt(recipe.toolLevel);
packetBuffer.writeVarInt(recipe.anvilLevel); packetBuffer.writeVarInt(recipe.anvilLevel);
packetBuffer.writeVarInt(recipe.damage); packetBuffer.writeVarInt(recipe.damage);
} }
} }
} }

View file

@ -9,7 +9,6 @@ import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.SmeltingRecipe; import net.minecraft.world.item.crafting.SmeltingRecipe;
import net.minecraft.world.item.crafting.SmokingRecipe; import net.minecraft.world.item.crafting.SmokingRecipe;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import ru.bclib.BCLib;
import ru.bclib.config.PathConfig; import ru.bclib.config.PathConfig;
public class FurnaceRecipe { public class FurnaceRecipe {
@ -77,54 +76,53 @@ public class FurnaceRecipe {
public void build(boolean blasting, boolean campfire, boolean smoker) { public void build(boolean blasting, boolean campfire, boolean smoker) {
if (exist) { if (exist) {
SmeltingRecipe recipe = new SmeltingRecipe( return;
}
SmeltingRecipe recipe = new SmeltingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time
);
BCLRecipeManager.addRecipe(RecipeType.SMELTING, recipe);
if (blasting) {
BlastingRecipe recipe2 = new BlastingRecipe(
id, id,
group, group,
Ingredient.of(input), Ingredient.of(input),
new ItemStack(output, count), new ItemStack(output, count),
xp, xp,
time time / 2
); );
BCLRecipeManager.addRecipe(RecipeType.SMELTING, recipe); BCLRecipeManager.addRecipe(RecipeType.BLASTING, recipe2);
if (blasting) {
BlastingRecipe recipe2 = new BlastingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time / 2
);
BCLRecipeManager.addRecipe(RecipeType.BLASTING, recipe2);
}
if (campfire) {
CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time * 3
);
BCLRecipeManager.addRecipe(RecipeType.CAMPFIRE_COOKING, recipe2);
}
if (smoker) {
SmokingRecipe recipe2 = new SmokingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time / 2
);
BCLRecipeManager.addRecipe(RecipeType.SMOKING, recipe2);
}
} }
else {
BCLib.LOGGER.debug("Furnace recipe {} couldn't be added", id); if (campfire) {
CampfireCookingRecipe recipe2 = new CampfireCookingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time * 3
);
BCLRecipeManager.addRecipe(RecipeType.CAMPFIRE_COOKING, recipe2);
}
if (smoker) {
SmokingRecipe recipe2 = new SmokingRecipe(
id,
group,
Ingredient.of(input),
new ItemStack(output, count),
xp,
time / 2
);
BCLRecipeManager.addRecipe(RecipeType.SMOKING, recipe2);
} }
} }
} }

View file

@ -12,7 +12,6 @@ import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.ShapedRecipe; import net.minecraft.world.item.crafting.ShapedRecipe;
import net.minecraft.world.item.crafting.ShapelessRecipe; import net.minecraft.world.item.crafting.ShapelessRecipe;
import net.minecraft.world.level.ItemLike; import net.minecraft.world.level.ItemLike;
import ru.bclib.BCLib;
import ru.bclib.config.PathConfig; import ru.bclib.config.PathConfig;
import java.util.Arrays; import java.util.Arrays;
@ -30,7 +29,7 @@ public class GridRecipe {
private String[] shape; private String[] shape;
private Map<Character, Ingredient> materialKeys = Maps.newHashMap(); private Map<Character, Ingredient> materialKeys = Maps.newHashMap();
private int count; private int count;
private boolean exist = true; private boolean exist;
private GridRecipe() {} private GridRecipe() {}
@ -114,24 +113,23 @@ public class GridRecipe {
} }
public void build() { public void build() {
if (exist) { if (!exist) {
int height = shape.length; return;
int width = shape[0].length();
ItemStack result = new ItemStack(output, count);
NonNullList<Ingredient> materials = this.getMaterials(width, height);
CraftingRecipe recipe = shaped ? new ShapedRecipe(
id,
group,
width,
height,
materials,
result
) : new ShapelessRecipe(id, group, result, materials);
BCLRecipeManager.addRecipe(type, recipe);
}
else {
BCLib.LOGGER.debug("Recipe {} couldn't be added", id);
} }
int height = shape.length;
int width = shape[0].length();
ItemStack result = new ItemStack(output, count);
NonNullList<Ingredient> materials = this.getMaterials(width, height);
CraftingRecipe recipe = shaped ? new ShapedRecipe(
id,
group,
width,
height,
materials,
result
) : new ShapelessRecipe(id, group, result, materials);
BCLRecipeManager.addRecipe(type, recipe);
} }
} }

View file

@ -25,7 +25,7 @@ public class SmithingTableRecipe {
BUILDER.base = null; BUILDER.base = null;
BUILDER.addition = null; BUILDER.addition = null;
BUILDER.result = null; BUILDER.result = null;
BUILDER.alright = true; BUILDER.exist = true;
return BUILDER; return BUILDER;
} }
@ -34,7 +34,6 @@ public class SmithingTableRecipe {
private Ingredient base; private Ingredient base;
private Ingredient addition; private Ingredient addition;
private ItemStack result; private ItemStack result;
private boolean alright;
private boolean exist; private boolean exist;
private SmithingTableRecipe() {} private SmithingTableRecipe() {}
@ -49,13 +48,13 @@ public class SmithingTableRecipe {
} }
public SmithingTableRecipe setResult(ItemLike item, int count) { public SmithingTableRecipe setResult(ItemLike item, int count) {
this.alright &= BCLRecipeManager.exists(item); this.exist &= BCLRecipeManager.exists(item);
this.result = new ItemStack(item, count); this.result = new ItemStack(item, count);
return this; return this;
} }
public SmithingTableRecipe setBase(ItemLike... items) { public SmithingTableRecipe setBase(ItemLike... items) {
this.alright &= BCLRecipeManager.exists(items); this.exist &= BCLRecipeManager.exists(items);
this.base = Ingredient.of(items); this.base = Ingredient.of(items);
return this; return this;
} }
@ -66,7 +65,7 @@ public class SmithingTableRecipe {
} }
public SmithingTableRecipe setAddition(ItemLike... items) { public SmithingTableRecipe setAddition(ItemLike... items) {
this.alright &= BCLRecipeManager.exists(items); this.exist &= BCLRecipeManager.exists(items);
this.addition = Ingredient.of(items); this.addition = Ingredient.of(items);
return this; return this;
} }
@ -97,10 +96,7 @@ public class SmithingTableRecipe {
BCLib.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id); BCLib.LOGGER.warning("Can't add Smithing recipe! Id {} already exists!", id);
return; return;
} }
if (!alright) {
BCLib.LOGGER.debug("Can't add Smithing recipe {}! Ingeredients or output not exists.", id);
return;
}
BCLRecipeManager.addRecipe(TYPE, new UpgradeRecipe(id, base, addition, result)); BCLRecipeManager.addRecipe(TYPE, new UpgradeRecipe(id, base, addition, result));
} }
} }

View file

@ -94,7 +94,7 @@ public class BlocksHelper {
/** /**
* Rotates {@link BlockState} horizontally. Used in block classes with {@link Direction} {@link Property} in rotate function. * Rotates {@link BlockState} horizontally. Used in block classes with {@link Direction} {@link Property} in rotate function.
* *
* @param state - {@link BlockState} to mirror; * @param state - {@link BlockState} to mirror;
* @param rotation - {@link Rotation}; * @param rotation - {@link Rotation};
* @param facing - Block {@link Direction} {@link Property}. * @param facing - Block {@link Direction} {@link Property}.
* @return Rotated {@link BlockState}. * @return Rotated {@link BlockState}.

View file

@ -45,9 +45,9 @@ public class PathUtil {
/** /**
* A simple directory walker that ignores dot-files * A simple directory walker that ignores dot-files
* *
* @param path The path where you want to start * @param path The path where you want to start
* @param pathConsumer The consumer called for each valid file. The consumer will get an absolute {@link Path}-Object * @param pathConsumer The consumer called for each valid file. The consumer will get an absolute {@link Path}-Object
* for each visited file * for each visited file
*/ */
public static void fileWalker(File path, Consumer<Path> pathConsumer) { public static void fileWalker(File path, Consumer<Path> pathConsumer) {
fileWalker(path, true, pathConsumer); fileWalker(path, true, pathConsumer);
@ -56,10 +56,10 @@ public class PathUtil {
/** /**
* A simple directory walker that ignores dot-files * A simple directory walker that ignores dot-files
* *
* @param path The path where you want to start * @param path The path where you want to start
* @param recursive if {@code false}, only the {@code path} is traversed * @param recursive if {@code false}, only the {@code path} is traversed
* @param pathConsumer The consumer called for each valid file. The consumer will get an absolute {@link Path}-Object * @param pathConsumer The consumer called for each valid file. The consumer will get an absolute {@link Path}-Object
* for each visited file * for each visited file
*/ */
public static void fileWalker(File path, boolean recursive, Consumer<Path> pathConsumer) { public static void fileWalker(File path, boolean recursive, Consumer<Path> pathConsumer) {
if (!path.exists()) return; if (!path.exists()) return;

View file

@ -73,12 +73,12 @@ public class TranslationHelper {
if (!missingNames.isEmpty()) { if (!missingNames.isEmpty()) {
System.out.println("========================================"); System.out.println("========================================");
System.out.println(" MISSING NAMES LIST"); System.out.println(" MISSING NAMES LIST");
if (!missingNames.isEmpty()) { if (!missingNames.isEmpty()) {
if (languageCode.equals("en_us")) { if (languageCode.equals("en_us")) {
System.out.println("========================================"); System.out.println("========================================");
System.out.println(" AUTO ENGLISH BEAUTIFICATION"); System.out.println(" AUTO ENGLISH BEAUTIFICATION");
System.out.println("========================================"); System.out.println("========================================");
missingNames.stream().sorted().forEach(name -> { missingNames.stream().sorted().forEach(name -> {
System.out.println(" \"" + name + "\": \"" + fastTranslateEn(name) + "\","); System.out.println(" \"" + name + "\": \"" + fastTranslateEn(name) + "\",");
@ -86,7 +86,7 @@ public class TranslationHelper {
} }
else { else {
System.out.println("========================================"); System.out.println("========================================");
System.out.println(" TEMPLATE: [" + languageCode + "]"); System.out.println(" TEMPLATE: [" + languageCode + "]");
System.out.println("========================================"); System.out.println("========================================");
missingNames.stream().sorted().forEach(name -> { missingNames.stream().sorted().forEach(name -> {
System.out.println(" \"" + name + "\": \"\","); System.out.println(" \"" + name + "\": \"\",");

View file

@ -102,7 +102,7 @@ public class BCLFeature {
* @param veins iterations per chunk. * @param veins iterations per chunk.
* @param veinSize size of ore vein. * @param veinSize size of ore vein.
* @param minY A {@link VerticalAnchor} for the minimum height, for example * @param minY A {@link VerticalAnchor} for the minimum height, for example
* {@code VerticalAnchor.bottom()}, {@code VerticalAnchor.absolute(10)}, {@code VerticalAnchor.aboveBottom(10)} * {@code VerticalAnchor.bottom()}, {@code VerticalAnchor.absolute(10)}, {@code VerticalAnchor.aboveBottom(10)}
* @param maxY A {@link VerticalAnchor} for the maximum height. * @param maxY A {@link VerticalAnchor} for the maximum height.
* @return new BCLFeature instance. * @return new BCLFeature instance.
*/ */
@ -113,15 +113,15 @@ public class BCLFeature {
/** /**
* Will create a basic ore feature. * Will create a basic ore feature.
* *
* @param id {@link ResourceLocation} feature ID. * @param id {@link ResourceLocation} feature ID.
* @param blockOre {@link Decoration} feature step. * @param blockOre {@link Decoration} feature step.
* @param hostBlock {@link Block} to generate feature in. * @param hostBlock {@link Block} to generate feature in.
* @param veins iterations per chunk. * @param veins iterations per chunk.
* @param veinSize size of ore vein. * @param veinSize size of ore vein.
* @param minY A {@link VerticalAnchor} for the minimum height, for example * @param minY A {@link VerticalAnchor} for the minimum height, for example
* {@code VerticalAnchor.bottom()}, {@code VerticalAnchor.absolute(10)}, {@code VerticalAnchor.aboveBottom(10)} * {@code VerticalAnchor.bottom()}, {@code VerticalAnchor.absolute(10)}, {@code VerticalAnchor.aboveBottom(10)}
* @param maxY A {@link VerticalAnchor} for the maximum height. * @param maxY A {@link VerticalAnchor} for the maximum height.
* @param rare when true, this is placed as a rare resource * @param rare when true, this is placed as a rare resource
* @return new BCLFeature instance. * @return new BCLFeature instance.
*/ */
public static BCLFeature makeOreFeature(ResourceLocation id, Block blockOre, Block hostBlock, int veins, int veinSize, VerticalAnchor minY, VerticalAnchor maxY, boolean rare) { public static BCLFeature makeOreFeature(ResourceLocation id, Block blockOre, Block hostBlock, int veins, int veinSize, VerticalAnchor minY, VerticalAnchor maxY, boolean rare) {
@ -131,14 +131,14 @@ public class BCLFeature {
/** /**
* Will create a basic ore feature. * Will create a basic ore feature.
* *
* @param id {@link ResourceLocation} feature ID. * @param id {@link ResourceLocation} feature ID.
* @param blockOre {@link Decoration} feature step. * @param blockOre {@link Decoration} feature step.
* @param hostBlock {@link Block} to generate feature in. * @param hostBlock {@link Block} to generate feature in.
* @param veins iterations per chunk. * @param veins iterations per chunk.
* @param veinSize size of ore vein. * @param veinSize size of ore vein.
* @param placement {@link net.minecraft.world.level.levelgen.placement.PlacementModifier} for the ore distribution, * @param placement {@link net.minecraft.world.level.levelgen.placement.PlacementModifier} for the ore distribution,
* for example {@code PlacementUtils.FULL_RANGE}, {@code PlacementUtils.RANGE_10_10} * for example {@code PlacementUtils.FULL_RANGE}, {@code PlacementUtils.RANGE_10_10}
* @param rare when true, this is placed as a rare resource * @param rare when true, this is placed as a rare resource
* @return new BCLFeature instance. * @return new BCLFeature instance.
*/ */
public static BCLFeature makeOreFeature(ResourceLocation id, Block blockOre, Block hostBlock, int veins, int veinSize, PlacementModifier placement, boolean rare) { public static BCLFeature makeOreFeature(ResourceLocation id, Block blockOre, Block hostBlock, int veins, int veinSize, PlacementModifier placement, boolean rare) {

View file

@ -8,20 +8,20 @@ import ru.bclib.api.biomes.BiomeAPI;
import java.util.List; import java.util.List;
public abstract class BCLBiomeSource extends BiomeSource { public abstract class BCLBiomeSource extends BiomeSource {
protected final Registry<Biome> biomeRegistry; protected final Registry<Biome> biomeRegistry;
protected final long seed; protected final long seed;
private static List<Biome> preInit(Registry<Biome> biomeRegistry, List<Biome> biomes){ private static List<Biome> preInit(Registry<Biome> biomeRegistry, List<Biome> biomes){
biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome)); biomes.forEach(biome -> BiomeAPI.sortBiomeFeatures(biome));
return biomes; return biomes;
} }
protected BCLBiomeSource(Registry<Biome> biomeRegistry, long seed, List<Biome> list) { protected BCLBiomeSource(Registry<Biome> biomeRegistry, long seed, List<Biome> list) {
super(preInit(biomeRegistry, list)); super(preInit(biomeRegistry, list));
this.seed = seed; this.seed = seed;
this.biomeRegistry = biomeRegistry; this.biomeRegistry = biomeRegistry;
BiomeAPI.initRegistry(biomeRegistry); BiomeAPI.initRegistry(biomeRegistry);
} }
} }

View file

@ -32,20 +32,20 @@ public class BCLibNetherBiomeSource extends BCLBiomeSource {
}); });
private BiomeMap biomeMap; private BiomeMap biomeMap;
private static boolean forceLegacyGenerator = false; private static boolean forceLegacyGenerator = false;
private static int lastWorldHeight; private static int lastWorldHeight;
private static int worldHeight; private static int worldHeight;
/** /**
* When true, the older square generator is used for the nether. * When true, the older square generator is used for the nether.
* *
* This override is used (for example) by BetterNether to force the legacy generation for worlds * This override is used (for example) by BetterNether to force the legacy generation for worlds
* that were created before 1.18 * that were created before 1.18
* @param val wether or not you want to force the old generatore. * @param val wether or not you want to force the old generatore.
*/ */
public static void setForceLegacyGeneration(boolean val){ public static void setForceLegacyGeneration(boolean val){
forceLegacyGenerator = val; forceLegacyGenerator = val;
} }
/** /**
* Set world height, used when Nether is larger than vanilla 128 blocks tall. * Set world height, used when Nether is larger than vanilla 128 blocks tall.

View file

@ -6,29 +6,29 @@ import ru.bclib.noise.OpenSimplexNoise;
import ru.bclib.util.MHelper; import ru.bclib.util.MHelper;
public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition { public class DoubleBlockSurfaceNoiseCondition extends SurfaceNoiseCondition {
public static final DoubleBlockSurfaceNoiseCondition CONDITION = new DoubleBlockSurfaceNoiseCondition(0); public static final DoubleBlockSurfaceNoiseCondition CONDITION = new DoubleBlockSurfaceNoiseCondition(0);
private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141); private static final OpenSimplexNoise NOISE = new OpenSimplexNoise(4141);
private final double threshold; private final double threshold;
public DoubleBlockSurfaceNoiseCondition(double threshold){ public DoubleBlockSurfaceNoiseCondition(double threshold){
this.threshold = threshold; this.threshold = threshold;
} }
private static int lastX = Integer.MIN_VALUE; private static int lastX = Integer.MIN_VALUE;
private static int lastZ = Integer.MIN_VALUE; private static int lastZ = Integer.MIN_VALUE;
private static double lastValue = 0; private static double lastValue = 0;
@Override @Override
public boolean test(SurfaceRulesContextAccessor context) { public boolean test(SurfaceRulesContextAccessor context) {
final int x = context.getBlockX(); final int x = context.getBlockX();
final int z = context.getBlockZ(); final int z = context.getBlockZ();
if (lastX==x && lastZ==z) return lastValue > threshold; if (lastX==x && lastZ==z) return lastValue > threshold;
double value = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, MHelper.RANDOM); double value = NOISE.eval(x * 0.1, z * 0.1) + MHelper.randRange(-0.4, 0.4, MHelper.RANDOM);
lastX=x; lastX=x;
lastZ=z; lastZ=z;
lastValue=value; lastValue=value;
return value > threshold; return value > threshold;
} }
} }

View file

@ -16,7 +16,7 @@
"title.bclib.confirmrestart": "Restart Required", "title.bclib.confirmrestart": "Restart Required",
"message.bclib.confirmrestart": "The requested content was synchronized. You need to restart Minecraft now.", "message.bclib.confirmrestart": "The requested content was synchronized. You need to restart Minecraft now.",
"title.link.bclib.discord": "Discord", "title.link.bclib.discord": "Discord",
"title.bclib.modmenu.main": "BCLib Settings", "title.bclib.modmenu.main": "BCLib Settings",
"title.bclib.progress": "Progress", "title.bclib.progress": "Progress",
"title.bclib.filesync.progress": "File Transfer", "title.bclib.filesync.progress": "File Transfer",
"message.bclib.filesync.progress": "Syncing File-Content with Server", "message.bclib.filesync.progress": "Syncing File-Content with Server",

View file

@ -16,7 +16,7 @@
"title.bclib.confirmrestart": "재시작 필요", "title.bclib.confirmrestart": "재시작 필요",
"message.bclib.confirmrestart": "요청한 콘텐츠가 동기화되었습니다. 지금 마인크래프트를 다시 시작해야 합니다.", "message.bclib.confirmrestart": "요청한 콘텐츠가 동기화되었습니다. 지금 마인크래프트를 다시 시작해야 합니다.",
"title.link.bclib.discord": "디스코드", "title.link.bclib.discord": "디스코드",
"title.bclib.modmenu.main": "BCLib 환경설정", "title.bclib.modmenu.main": "BCLib 환경설정",
"title.bclib.progress": "진행", "title.bclib.progress": "진행",
"title.bclib.filesync.progress": "파일 전송", "title.bclib.filesync.progress": "파일 전송",
"message.bclib.filesync.progress": "파일 내용을 서버와 동기화하는 중", "message.bclib.filesync.progress": "파일 내용을 서버와 동기화하는 중",

View file

@ -3,7 +3,7 @@
// Value near 254 // Value near 254
bool isEmissive(float alpha) { bool isEmissive(float alpha) {
return 0.9960 < alpha && alpha < 0.9962; return 0.9960 < alpha && alpha < 0.9962;
} }
void frx_startFragment(inout frx_FragmentData fragData) { void frx_startFragment(inout frx_FragmentData fragData) {

View file

@ -32,7 +32,7 @@ vec3 hsvToRGB(vec3 color) {
// Value near 254 // Value near 254
bool isEmissive(float alpha) { bool isEmissive(float alpha) {
return 0.9960 < alpha && alpha < 0.9962; return 0.9960 < alpha && alpha < 0.9962;
} }
void main() { void main() {

View file

@ -34,7 +34,7 @@ vec3 hsvToRGB(vec3 color) {
// Value near 254 // Value near 254
bool isEmissive(float alpha) { bool isEmissive(float alpha) {
return 0.9960 < alpha && alpha < 0.9962; return 0.9960 < alpha && alpha < 0.9962;
} }
void main() { void main() {

View file

@ -33,7 +33,7 @@ vec3 hsvToRGB(vec3 color) {
// Value near 254 // Value near 254
bool isEmissive(float alpha) { bool isEmissive(float alpha) {
return 0.9960 < alpha && alpha < 0.9962; return 0.9960 < alpha && alpha < 0.9962;
} }
void main() { void main() {

View file

@ -32,7 +32,7 @@ vec3 hsvToRGB(vec3 color) {
// Value near 254 // Value near 254
bool isEmissive(float alpha) { bool isEmissive(float alpha) {
return 0.9960 < alpha && alpha < 0.9962; return 0.9960 < alpha && alpha < 0.9962;
} }
void main() { void main() {

View file

@ -1,10 +1,10 @@
accessWidener v1 named accessWidener v1 named
# Classes # Classes
accessible class net/minecraft/client/Minecraft$ExperimentalDialogType accessible class net/minecraft/client/Minecraft$ExperimentalDialogType
accessible class net/minecraft/world/level/levelgen/SurfaceRules$Context accessible class net/minecraft/world/level/levelgen/SurfaceRules$Context
accessible class net/minecraft/world/level/levelgen/SurfaceRules$Condition accessible class net/minecraft/world/level/levelgen/SurfaceRules$Condition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SurfaceRule accessible class net/minecraft/world/level/levelgen/SurfaceRules$SurfaceRule
accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyXZCondition accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyXZCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition accessible class net/minecraft/world/level/levelgen/SurfaceRules$LazyCondition
accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRuleSource

View file

@ -26,10 +26,10 @@
"server": [ "server": [
"ru.bclib.server.BCLibServer" "ru.bclib.server.BCLibServer"
], ],
"modmenu": [ "ru.bclib.gui.modmenu.EntryPoint::entrypointObject" ] "modmenu": [ "ru.bclib.gui.modmenu.EntryPoint::entrypointObject" ]
}, },
"accessWidener" : "bclib.accesswidener", "accessWidener" : "bclib.accesswidener",
"mixins": [ "mixins": [
"bclib.mixins.common.json", "bclib.mixins.common.json",
"bclib.mixins.client.json" "bclib.mixins.client.json"
], ],
@ -37,12 +37,12 @@
"fabricloader": ">=0.12.9", "fabricloader": ">=0.12.9",
"fabric": ">=0.44.0", "fabric": ">=0.44.0",
"minecraft": ">=1.18.1" "minecraft": ">=1.18.1"
}, },
"custom":{ "custom":{
"modmenu":{ "modmenu":{
"links":{ "links":{
"title.link.bclib.discord":"https://discord.gg/kYuATbYbKW" "title.link.bclib.discord":"https://discord.gg/kYuATbYbKW"
} }
} }
} }
} }