diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 637f7846..00000000 --- a/.editorconfig +++ /dev/null @@ -1,21 +0,0 @@ -# http://editorconfig.org -root = true - -[*] -indent_style = tab -indent_size = 4 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = false -max_line_length = 120 - -[{*.json,*.mcmeta}] -indent_style = space -indent_size = 2 - -[{*.java,*.gradle}] -ij_continuation_indent_size = 4 -ij_java_class_count_to_use_import_on_demand = 99 -ij_java_names_count_to_use_import_on_demand = 99 -ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.simibubi.**, |, com.mojang.**, |, net.minecraft.**, |, net.minecraftforge.**, |, dev.rdh.**, |, ** \ No newline at end of file diff --git a/.gitignore b/.gitignore index ef1a98f2..c476faf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,40 @@ -.idea -build -.gradle -run -.DS_Store -src/main/resources/assets/create +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..9de71cb5 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,6 @@ +# Security Policy + +## Reporting a Vulnerability + +To report a security issue, please contact a developer with a description of the issue, the steps you took to create the +issue, affected versions, and, if known, mitigations for the issue. This project follows a 90 day disclosure timeline. diff --git a/build.gradle b/build.gradle index e16044f3..478115f3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,132 +1,105 @@ -//file:noinspection GroovyAssignabilityCheck plugins { - id 'dev.architectury.loom' version "${loom_version}" - id 'io.github.juuxel.loom-vineflower' version "${vineflower_version}" - id 'io.github.p03w.machete' version '2.0.1' - id 'maven-publish' + id 'fabric-loom' version '1.4-SNAPSHOT' + id 'maven-publish' + id "io.github.p03w.machete" version "1.+" // automatic jar compressing on build } -sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 - +version = project.mod_version group = project.maven_group -archivesBaseName = project.archives_base_name -String buildNumber = System.getenv("GITHUB_RUN_NUMBER") -version = "${mod_version}${ buildNumber != null ? "-${buildNumber}" : ''}+mc${minecraft_version}" - -def generatedResources = file('src/generated/resources') - -sourceSets.main.resources { - srcDir(generatedResources) - exclude '.cache/' -} -loom { - silentMojangMappingsLicense() - - forge { - mixinConfig "interiors.mixins.json" - } - - runs { - data { - data() - programArgs '--mod', 'interiors' - programArg '--all' - programArgs '--output', generatedResources.absolutePath - programArgs '--existing', file('src/main/resources/').absolutePath - programArgs '--existing-mod', 'create' - } - } +base { + archivesName = project.archives_base_name } repositories { - mavenCentral() - mavenLocal() - maven { url 'https://maven.parchmentmc.org' } - maven { url 'https://maven.quiltmc.org/repository/release' } - maven { url 'https://maven.blamejared.com/' } - maven { url 'https://maven.neoforged.net/releases/' } - - maven { - url 'https://maven.tterrag.com/' - content { - includeGroup 'com.jozufozu.flywheel' - includeGroup 'com.tterrag.registrate' - includeGroup 'com.simibubi.create' - } - } - maven { - url 'https://api.modrinth.com/maven' - content { includeGroup 'maven.modrinth' } - } - maven { - url 'https://www.cursemaven.com' - content { includeGroup 'curse.maven' } - } -} - -configurations { - jarJar - - modImplementation.extendsFrom jarJar - include.extendsFrom jarJar + maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI + maven { url = "https://dvs1.progwml6.com/files/maven/" } // JEI + maven { url = "https://maven.parchmentmc.org" } // Parchment mappings + maven { url = "https://maven.quiltmc.org/repository/release" } // Quilt Mappings + maven { url = "https://api.modrinth.com/maven" } // LazyDFU + maven { url = "https://maven.terraformersmc.com/releases/" } // Mod Menu + maven { url = "https://mvn.devos.one/snapshots/" } // Create, Porting Lib, Forge Tags, Milk Lib, Registrate + maven { url = "https://cursemaven.com" } // Forge Config API Port + maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes + maven { url = "https://jitpack.io/" } // Mixin Extras, Fabric ASM + maven { url = "https://maven.tterrag.com/" } // Flywheel } dependencies { - minecraft "com.mojang:minecraft:${minecraft_version}" - - mappings(loom.layered { - it.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings}:intermediary-v2") - it.parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip") - it.officialMojangMappings { nameSyntheticMembers = false } - }) - - forge "net.neoforged:forge:${minecraft_version}-${neo_version}" - - // Create and Co. - modImplementation "com.tterrag.registrate:Registrate:${registrate_version}" - modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } - modImplementation "com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}" - - // JEI - modCompileOnly "mezz.jei:jei-${minecraft_version}-common-api:${jei_version}" - modCompileOnly "mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}" - modLocalRuntime("mezz.jei:jei-${minecraft_version}-forge:${jei_version}") { transitive = false } - - // Dev QOL - modLocalRuntime 'curse.maven:better-mods-button-541584:4665757' - modLocalRuntime 'curse.maven:ferritecore-429235:4574361' - modLocalRuntime "curse.maven:catalogue-459701:4766090" + // To change the versions see the gradle.properties file + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings(loom.layered { + it.mappings("org.quiltmc:quilt-mappings:${minecraft_version}+build.${qm_version}:intermediary-v2") + it.parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip") + it.officialMojangMappings { nameSyntheticMembers = false } + }) + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + // Fabric API. This is technically optional, but you probably want it anyway. + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}") + + // Development QOL + modLocalRuntime("maven.modrinth:lazydfu:${lazydfu_version}") + modLocalRuntime("com.terraformersmc:modmenu:${modmenu_version}") } processResources { - def props = [ - version: mod_version, - neo_version: neo_version.split("\\.")[0], // only specify major version of forge - minecraft_version: minecraft_version, - create_version: create_version.split("-")[0] // cut off build number - ] - inputs.properties props - - filesMatching('META-INF/mods.toml') { - expand props - } - - //don't include create's stuff in the jar in case they are there - exclude 'assets/create.zip' - exclude 'assets/create' + // require dependencies to be the version compiled against or newer + Map properties = new HashMap<>() + properties.put("version", version) + properties.put("loader_version", loader_version) + properties.put("fabric_version", fabric_version) + properties.put("create_version", create_version) + properties.put("minecraft_version", minecraft_version) + + properties.forEach((k, v) -> inputs.property(k, v)) + + filesMatching("fabric.mod.json") { + expand properties + } } -// disable machete locally for faster builds -machete { enabled = buildNumber != null } tasks.withType(JavaCompile).configureEach { - it.options.encoding = 'UTF-8' - it.options.release.set 17 + it.options.release = 17 } -java { withSourcesJar() } +java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} + +jar { + from("LICENSE") { + rename { "${it}_${project.base.archivesName.get()}" } + } +} + +machete { + // disable machete locally for faster builds + enabled != null +} -remapJar { - archiveClassifier.set('dev') +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 1cbfd8f7..e6d31264 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,35 +1,30 @@ -## Gradle Settings -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false +# Done to increase the memory available to gradle. +org.gradle.jvmargs=-Xmx1G org.gradle.parallel=true -org.gradle.caching=true - -loom.platform = forge - -## Gradle Plugins -loom_version = 1.3.357 -vineflower_version = 1.11.0 - -## Mod Info +# Fabric Properties +# check these on https://fabricmc.net/develop +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.10 +loader_version=0.14.24 +# Mappings +# https://lambdaurora.dev/tools/import_quilt.html +qm_version=23 +# https://parchmentmc.org/docs/getting-started +parchment_version=2023.07.16 +# Mod Properties +maven_group=com.sudolev archives_base_name = interiors mod_version=0.5.2 -maven_group = com.sudolev - -## Versions -# Minecraft: https://feedback.minecraft.net/hc/en-us/sections/360001186971-Release-Changelogs -minecraft_version = 1.20.1 -# Parchment: https://parchmentmc.org/docs/getting-started -parchment_version = 2023.06.26 -# Quilt Mappings - https://lambdaurora.dev/tools/import_quilt.html -quilt_mappings = 23 -# NeoForge: https://neoforged.net/ -neo_version = 47.1.65 - -## Mod Dependencies -# Create, Registrate, and Flywheel: https://github.com/Creators-of-Create/Create/wiki/Depending-on-Create#types-of-dependencies -registrate_version = MC1.20-1.3.3 -create_version = 0.5.1.e-22 -flywheel_version = 0.6.10-7 - -# JEI: https://modrinth.com/mod/jei/versions?l=forge&g=1.20.1 -jei_version = 15.2.0.27 +# Dependencies +fabric_version=0.90.7+1.20.1 +create_version=0.5.1-d-build.1161+mc1.20.1 +modmenu_version=7.2.1 +# LazyDFU - https://modrinth.com/mod/lazydfu/versions +lazydfu_version=0.1.3 +recipe_viewer=undefined +# JEI - https://www.curseforge.com/minecraft/mc-mods/jei/files/all +jei_version=11.5.2.1007 +# REI - https://modrinth.com/mod/roughly-enough-items/versions +rei_version=9.1.580 +# EMI - https://modrinth.com/mod/emi/versions +emi_version=0.6.1+1.19.2 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 943f0cbf..00000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 37aef8d3..00000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip -networkTimeout=10000 -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d..0adc8e1a 100644 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/settings.gradle b/settings.gradle index 8edeb79c..11729aa1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,11 +1,12 @@ pluginManagement { repositories { - maven { url 'https://maven.fabricmc.net/' } - maven { url 'https://maven.architectury.dev/' } - maven { url 'https://maven.neoforged.net/releases/' } + maven { + name = 'Fabric' + url = 'https://maven.fabricmc.net/' + } + maven { url = "https://server.bbkr.space/artifactory/libs-release/" } + maven { url = "https://maven.quiltmc.org/repository/release" } + mavenCentral() gradlePluginPortal() } -} - -// no colon because gradle -rootProject.name = "Create Interiors" \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/com/sudolev/interiors/CreateInteriors.java b/src/main/java/com/sudolev/interiors/CreateInteriors.java index a8f8daab..6fb667ee 100644 --- a/src/main/java/com/sudolev/interiors/CreateInteriors.java +++ b/src/main/java/com/sudolev/interiors/CreateInteriors.java @@ -1,70 +1,46 @@ package com.sudolev.interiors; -import java.util.List; -import java.util.function.Function; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.simibubi.create.foundation.data.CreateRegistrate; -import com.simibubi.create.foundation.item.ItemDescription.Modifier; -import com.simibubi.create.foundation.item.TooltipHelper.Palette; - -import net.minecraft.resources.ResourceLocation; - -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.eventbus.api.EventPriority; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.fml.ModList; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.forgespi.language.IModInfo; - -import com.sudolev.interiors.foundation.data.CIDatagen; +import com.simibubi.create.foundation.item.ItemDescription; +import com.simibubi.create.foundation.item.KineticStats; +import com.simibubi.create.foundation.item.TooltipHelper; +import com.simibubi.create.foundation.item.TooltipModifier; import com.sudolev.interiors.content.registry.CIBlocks; import com.sudolev.interiors.content.registry.CIEntities; -import com.sudolev.interiors.content.registry.CITab; +import com.sudolev.interiors.content.registry.CITags; +import net.fabricmc.api.ModInitializer; +import net.minecraft.resources.ResourceLocation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -@Mod(CreateInteriors.ID) -public final class CreateInteriors { +public final class CreateInteriors implements ModInitializer { public static final String ID = "interiors"; - public static final String NAME = getModProperty(IModInfo::getDisplayName); - public static final Logger LOGGER = LoggerFactory.getLogger(NAME); - public static final String VERSION = getModProperty(IModInfo::getVersion); + public static final Logger LOGGER = LoggerFactory.getLogger(ID); + public static final String VERSION = "0.5.1"; public static final CreateRegistrate REGISTRATE = CreateRegistrate.create(ID); static { - REGISTRATE.setTooltipModifierFactory(item -> new Modifier(item, Palette.STANDARD_CREATE)); + REGISTRATE.setTooltipModifierFactory(item -> { + return new ItemDescription.Modifier(item, TooltipHelper.Palette.STANDARD_CREATE) + .andThen(TooltipModifier.mapNull(KineticStats.create(item))); + }); } - public CreateInteriors() { - final IEventBus forge = MinecraftForge.EVENT_BUS, mod = REGISTRATE.getModEventBus(); - LOGGER.info("{} v{} initializing", NAME, VERSION); - CITab.register(mod); - CIBlocks.register(); - CIEntities.register(); + // REGISTRATE.setTooltipModifierFactory(item -> new Modifier(item, Palette.STANDARD_CREATE)); - forge.register(this); - mod.addListener(EventPriority.LOWEST, CIDatagen::gatherData); - REGISTRATE.registerEventListeners(mod); + public static ResourceLocation asResource(String path) { + return new ResourceLocation(ID, path); } - private static String getModProperty(Function f) { - List infoList = ModList.get().getModFileById(ID).getMods(); - if(infoList.size() > 1 && LOGGER != null) { - LOGGER.error("Multiple mods for ID: " + ID); - } - - for(IModInfo info : infoList) { - if(info.getModId().equals(ID)) { - return f.apply(info).toString(); - } - } - return "UNKNOWN"; + @Override + public void onInitialize() { + LOGGER.info("{} v{} initializing", ID, VERSION); + CIEntities.register(); + CIBlocks.register(); + CITags.register(); + REGISTRATE.register(); + // ModLoadingContext modLoadingContext = new ModLoadingContext(); } - - public static ResourceLocation asResource(String path) { - return new ResourceLocation(ID, path); - } } \ No newline at end of file diff --git a/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java b/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java index 0b4d73b6..8618ec29 100644 --- a/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java +++ b/src/main/java/com/sudolev/interiors/content/block/seat/BigChairBlock.java @@ -1,12 +1,10 @@ package com.sudolev.interiors.content.block.seat; -import java.util.List; - -import org.jetbrains.annotations.NotNull; - import com.simibubi.create.AllItems; import com.simibubi.create.foundation.utility.BlockHelper; - +import com.sudolev.interiors.content.entity.BigSeatEntity; +import com.sudolev.interiors.content.registry.CIBlocks; +import io.github.fabricators_of_create.porting_lib.util.TagUtil; import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; @@ -22,9 +20,9 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.NotNull; -import com.sudolev.interiors.content.entity.BigSeatEntity; -import com.sudolev.interiors.content.registry.CIBlocks; +import java.util.List; @SuppressWarnings("NullableProblems") public class BigChairBlock extends ChairBlock { @@ -58,7 +56,7 @@ public InteractionResult use(BlockState state, Level world, BlockPos pos, Player return InteractionResult.PASS; } - DyeColor color = DyeColor.getColor(heldItem); + DyeColor color = TagUtil.getColorFromStack(heldItem); if(color != null && color != this.color) { if(world.isClientSide) return InteractionResult.SUCCESS; diff --git a/src/main/java/com/sudolev/interiors/content/block/seat/BigSeatMovementBehaviour.java b/src/main/java/com/sudolev/interiors/content/block/seat/BigSeatMovementBehaviour.java index e0fe9fc9..b65e1017 100644 --- a/src/main/java/com/sudolev/interiors/content/block/seat/BigSeatMovementBehaviour.java +++ b/src/main/java/com/sudolev/interiors/content/block/seat/BigSeatMovementBehaviour.java @@ -1,13 +1,9 @@ package com.sudolev.interiors.content.block.seat; -import java.util.Map; -import java.util.UUID; - import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.actors.seat.SeatMovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.foundation.utility.VecHelper; - import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.SlabBlock; @@ -15,6 +11,9 @@ import net.minecraft.world.level.block.state.properties.SlabType; import net.minecraft.world.phys.Vec3; +import java.util.Map; +import java.util.UUID; + public class BigSeatMovementBehaviour extends SeatMovementBehaviour { @Override public void visitNewPosition(MovementContext context, BlockPos pos) { @@ -42,6 +41,6 @@ public void visitNewPosition(MovementContext context, BlockPos pos) { toDismount.stopRiding(); Vec3 position = VecHelper.getCenterOf(pos).add(0, 1f, 0); toDismount.teleportTo(position.x, position.y, position.z); - toDismount.getPersistentData().remove("ContraptionDismountLocation"); + toDismount.getCustomData().remove("ContraptionDismountLocation"); } } diff --git a/src/main/java/com/sudolev/interiors/content/registry/CIBlocks.java b/src/main/java/com/sudolev/interiors/content/registry/CIBlocks.java index 0c4bbb7b..df865b70 100644 --- a/src/main/java/com/sudolev/interiors/content/registry/CIBlocks.java +++ b/src/main/java/com/sudolev/interiors/content/registry/CIBlocks.java @@ -1,24 +1,23 @@ package com.sudolev.interiors.content.registry; -import static com.simibubi.create.AllInteractionBehaviours.interactionBehaviour; -import static com.simibubi.create.AllMovementBehaviours.movementBehaviour; -import static com.simibubi.create.content.redstone.displayLink.AllDisplayBehaviours.assignDataBehaviour; -import static com.simibubi.create.foundation.block.ProperWaterloggedBlock.WATERLOGGED; -import static com.simibubi.create.foundation.data.TagGen.axeOnly; -import static com.sudolev.interiors.CreateInteriors.REGISTRATE; - import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTags.AllItemTags; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.actors.seat.SeatInteractionBehaviour; import com.simibubi.create.content.contraptions.actors.seat.SeatMovementBehaviour; +import com.simibubi.create.content.redstone.displayLink.AllDisplayBehaviours; import com.simibubi.create.content.redstone.displayLink.source.EntityNameDisplaySource; import com.simibubi.create.foundation.block.DyedBlockList; import com.simibubi.create.foundation.data.AssetLookup; import com.simibubi.create.foundation.data.SharedProperties; import com.simibubi.create.foundation.item.ItemDescription; import com.simibubi.create.foundation.utility.DyeHelper; - +import com.sudolev.interiors.CreateInteriors; +import com.sudolev.interiors.content.block.WallMountedTable; +import com.sudolev.interiors.content.block.seat.*; +import com.tterrag.registrate.providers.RegistrateRecipeProvider; +import com.tterrag.registrate.util.entry.BlockEntry; +import io.github.fabricators_of_create.porting_lib.models.generators.ConfiguredModel; import net.minecraft.core.registries.Registries; import net.minecraft.data.recipes.RecipeCategory; import net.minecraft.data.recipes.ShapelessRecipeBuilder; @@ -28,242 +27,234 @@ import net.minecraft.world.item.DyeColor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.MapColor; -import net.minecraftforge.client.model.generators.ConfiguredModel; - -import com.sudolev.interiors.CreateInteriors; -import com.sudolev.interiors.content.block.WallMountedTable; -import com.sudolev.interiors.content.block.seat.BigChairBlock; -import com.sudolev.interiors.content.block.seat.BigSeatMovementBehaviour; -import com.sudolev.interiors.content.block.seat.ChairBlock; -import com.sudolev.interiors.content.block.seat.DirectionalSeatBlock; -import com.sudolev.interiors.content.block.seat.FloorChairBlock; -import com.tterrag.registrate.providers.RegistrateRecipeProvider; -import com.tterrag.registrate.util.entry.BlockEntry; +import static com.simibubi.create.AllInteractionBehaviours.interactionBehaviour; +import static com.simibubi.create.AllMovementBehaviours.movementBehaviour; +import static com.simibubi.create.foundation.block.ProperWaterloggedBlock.WATERLOGGED; +import static com.simibubi.create.foundation.data.TagGen.axeOnly; +import static com.sudolev.interiors.CreateInteriors.REGISTRATE; @SuppressWarnings("unused") public final class CIBlocks { - static { - REGISTRATE.setCreativeTab(CITab.TAB); - } - public static final BlockEntry SEATWOOD_PLANKS = REGISTRATE.block("seatwood_planks", Block::new) - .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(DyeColor.ORANGE)) - .transform(axeOnly()) - .tag(BlockTags.PLANKS) - .item() - .tag(ItemTags.PLANKS) - .build() - .register(); - + .initialProperties(SharedProperties::wooden) + .properties(p -> p.mapColor(MapColor.TERRACOTTA_ORANGE)) + .transform(axeOnly()) + .tag(BlockTags.PLANKS) + .item() + .tag(ItemTags.PLANKS) + .build() + .register(); public static final BlockEntry WALL_MOUNTED_TABLE = REGISTRATE.block("wall_mounted_table", WallMountedTable::new) - .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(DyeColor.ORANGE)) - .transform(axeOnly()) - .blockstate((context, provider) -> provider.getVariantBuilder(context.get()) - .forAllStatesExcept(state -> { - String facing = state.getValue(ChairBlock.FACING).getSerializedName(); - int rotation = facing(state); - - return ConfiguredModel.builder() - .modelFile(provider.models().getExistingFile(provider.modLoc("block/wall_table"))).rotationY(rotation) - .build(); - }, WATERLOGGED)) - .item() + .initialProperties(SharedProperties::wooden) + .properties(p -> p.mapColor(MapColor.TERRACOTTA_ORANGE)) + .transform(axeOnly()) + .blockstate((context, provider) -> provider.getVariantBuilder(context.get()) + .forAllStatesExcept(state -> { + String facing = state.getValue(ChairBlock.FACING).getSerializedName(); + int rotation = facing(state); + + return ConfiguredModel.builder() + .modelFile(provider.models().getExistingFile(provider.modLoc("block/wall_table"))).rotationY(rotation) + .build(); + }, WATERLOGGED)) + .item() .model(AssetLookup.customBlockItemModel("wall_table")) - .build() - .register(); - + .build() + .register(); public static final DyedBlockList FLOOR_CHAIRS = new DyedBlockList<>(color -> { String colorName = color.getSerializedName(); - return REGISTRATE.block(colorName + "_floor_chair", p -> new FloorChairBlock(p, color)) - .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(color)) - .transform(axeOnly()) - .blockstate((c, p) -> p.getVariantBuilder(c.get()) - .forAllStatesExcept(state -> { - String facing = state.getValue(ChairBlock.FACING).getSerializedName(); - String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); - String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; - int rotation = facing(state); - - ResourceLocation top = Create.asResource("block/seat/top_" + colorName); - ResourceLocation side = Create.asResource("block/seat/side_" + colorName); - ResourceLocation sideTop = p.modLoc("block/chair/side_top_" + colorName); - - return ConfiguredModel.builder().modelFile(p.models() - .withExistingParent("block/floor_chair/" + colorName + "_floor_chair_" + armrest + cropped_state, - p.modLoc("block/floor_chair/" + armrest + cropped_state)) - .texture("top", top) - .texture("side", side) - .texture("side_front", side) - .texture("side_top", sideTop)) - .rotationY(rotation) - .build(); - }, WATERLOGGED)) - .recipe((c, p) -> { - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(ItemTags.WOODEN_SLABS) - .requires(ItemTags.WOODEN_SLABS) - .requires(DyeHelper.getWoolOfDye(color)) - .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) - .save(p, CreateInteriors.asResource("crafting/floor_chair/" + c.getName())); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(ItemTags.WOODEN_SLABS) - .requires(AllBlocks.SEATS.get(color)) - .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) - .save(p, CreateInteriors.asResource("crafting/floor_chair/" + c.getName() + "_from_seat")); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(CITags.Items.FLOOR_CHAIRS) - .requires(color.getTag()) - .unlockedBy("has_floor_chair", RegistrateRecipeProvider.has(CITags.Items.FLOOR_CHAIRS)) - .save(p, CreateInteriors.asResource("crafting/floor_chair/" + c.getName() + "_from_other_floor_chair")); - }) - .onRegister(movementBehaviour(new SeatMovementBehaviour())) - .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) - .onRegister(assignDataBehaviour(new EntityNameDisplaySource(), "entity_name")) - .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) - .tag(CITags.Blocks.FLOOR_CHAIRS) - .item().tag(CITags.Items.FLOOR_CHAIRS) - .model(AssetLookup.customBlockItemModel("floor_chair", colorName + "_floor_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) - .build().register(); + return REGISTRATE.block(colorName + "_floor_chair", p -> new FloorChairBlock(p, color)) + .initialProperties(SharedProperties::wooden) + .properties(p -> p.mapColor(color)) + .transform(axeOnly()) + .blockstate((c, p) -> p.getVariantBuilder(c.get()) + .forAllStatesExcept(state -> { + String facing = state.getValue(ChairBlock.FACING).getSerializedName(); + String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); + String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; + + int rotation = facing(state); + + ResourceLocation top = Create.asResource("block/seat/top_" + colorName); + ResourceLocation side = Create.asResource("block/seat/side_" + colorName); + ResourceLocation sideTop = p.modLoc("block/chair/side_top_" + colorName); + + return ConfiguredModel.builder().modelFile(p.models() + .withExistingParent("block/floor_chair/" + colorName + "_floor_chair_" + armrest + cropped_state, + p.modLoc("block/floor_chair/" + armrest + cropped_state)) + .texture("top", top) + .texture("side", side) + .texture("side_front", side) + .texture("side_top", sideTop)) + .rotationY(rotation) + .build(); + }, WATERLOGGED)) + .recipe((c, p) -> { + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + .requires(ItemTags.WOODEN_SLABS) + .requires(ItemTags.WOODEN_SLABS) + .requires(DyeHelper.getWoolOfDye(color)) + .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) + .save(p, CreateInteriors.asResource("crafting/floor_chair/" + c.getName())); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + .requires(ItemTags.WOODEN_SLABS) + .requires(AllBlocks.SEATS.get(color).asStack().getItem()) + .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) + .save(p, CreateInteriors.asResource("crafting/floor_chair/" + c.getName() + "_from_seat")); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + // .requires(CITags.Items.FLOOR_CHAIRS) + .requires(color.getTag()) + // .unlockedBy("has_floor_chair", RegistrateRecipeProvider.has(CITags.Items.FLOOR_CHAIRS)) + .save(p, CreateInteriors.asResource("crafting/floor_chair/" + c.getName() + "_from_other_floor_chair")); + }) + .onRegister(movementBehaviour(new SeatMovementBehaviour())) + .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) + .onRegister(AllDisplayBehaviours.assignDataBehaviour(new EntityNameDisplaySource(), "entity_name")) + .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) + .tag(CITags.BlockTags.FLOOR_CHAIRS.tag) + .item() + .tag(CITags.ItemTags.FLOOR_CHAIRS.tag) + .model(AssetLookup.customBlockItemModel("floor_chair", colorName + "_floor_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) + .build().register(); }); public static final DyedBlockList CHAIRS = new DyedBlockList<>(color -> { String colorName = color.getSerializedName(); return REGISTRATE.block(colorName + "_chair", p -> new BigChairBlock(p, color)) + .initialProperties(SharedProperties::wooden) + .properties(p -> p.mapColor(color)) + .transform(axeOnly()) + .blockstate((c, p) -> p.getVariantBuilder(c.get()) + .forAllStatesExcept(state -> { + String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); + String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; + + int rotation = facing(state); + + ResourceLocation top = Create.asResource("block/seat/top_" + colorName); + ResourceLocation side = Create.asResource("block/seat/side_" + colorName); + ResourceLocation sideTop = p.modLoc("block/chair/side_top_" + colorName); + + return ConfiguredModel.builder().modelFile(p.models() + .withExistingParent("block/chair/" + colorName + "_chair_" + armrest + cropped_state, + p.modLoc("block/chair/" + armrest + cropped_state)) + .texture("top", top).texture("side_top", sideTop) + .texture("side_front", side).texture("side", side)) + .rotationY(rotation).build(); + }, WATERLOGGED)) + .recipe((c, p) -> { + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + .requires(ItemTags.WOODEN_SLABS) + .requires(ItemTags.PLANKS) + .requires(DyeHelper.getWoolOfDye(color)) + .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) + .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName())); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + .requires(ItemTags.PLANKS) + .requires(AllBlocks.SEATS.get(color).asStack().getItem()) + .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) + .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName() + "_from_seat")); + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + .requires(ItemTags.WOODEN_SLABS) + .requires(FLOOR_CHAIRS.get(color).asStack().getItem()) // REMOMVE ItemLike if it breaks stuff! + // .unlockedBy("has_floor_chair", RegistrateRecipeProvider.has(CITags.Items.FLOOR_CHAIRS)) + .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName() + "_from_floor_chair")); + + ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) + // .requires(CITags.ItemTags.CHAIRS.tag) + .requires(color.getTag()) + // .unlockedBy("has_chair", RegistrateRecipeProvider.has(CITags.ItemTags.CHAIRS.tag)) + .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName() + "_from_other_chair")); + }) + .onRegister(movementBehaviour(new BigSeatMovementBehaviour())) + .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) + .onRegister(AllDisplayBehaviours.assignDataBehaviour(new EntityNameDisplaySource(), "entity_name")) + .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) + .tag(CITags.BlockTags.CHAIRS.tag) + .item() + .tag(CITags.ItemTags.CHAIRS.tag) + .model(AssetLookup.customBlockItemModel("chair", colorName + "_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) + .build() + .register(); + }); + public static final BlockEntry KELP_CHAIR = REGISTRATE.block("kelp_chair", p -> new BigChairBlock(p, DyeColor.BLACK)) .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(color)) + .properties(p -> p.mapColor(MapColor.TERRACOTTA_BLACK)) .transform(axeOnly()) .blockstate((c, p) -> p.getVariantBuilder(c.get()) - .forAllStatesExcept(state -> { - String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); - String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; - - int rotation = facing(state); - - ResourceLocation top = Create.asResource("block/seat/top_" + colorName); - ResourceLocation side = Create.asResource("block/seat/side_" + colorName); - ResourceLocation sideTop = p.modLoc("block/chair/side_top_" + colorName); - - return ConfiguredModel.builder().modelFile(p.models() - .withExistingParent("block/chair/" + colorName + "_chair_" + armrest + cropped_state, - p.modLoc("block/chair/" + armrest + cropped_state)) - .texture("top", top).texture("side_top", sideTop) - .texture("side_front", side).texture("side", side)) - .rotationY(rotation).build(); - }, WATERLOGGED)) - .recipe((c, p) -> { - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(ItemTags.WOODEN_SLABS) - .requires(ItemTags.PLANKS) - .requires(DyeHelper.getWoolOfDye(color)) - .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) - .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName())); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(ItemTags.PLANKS) - .requires(AllBlocks.SEATS.get(color)) - .unlockedBy("has_seat", RegistrateRecipeProvider.has(AllItemTags.SEATS.tag)) - .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName() + "_from_seat")); - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(ItemTags.WOODEN_SLABS) - .requires(FLOOR_CHAIRS.get(color)) - .unlockedBy("has_floor_chair", RegistrateRecipeProvider.has(CITags.Items.FLOOR_CHAIRS)) - .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName() + "_from_floor_chair")); - - ShapelessRecipeBuilder.shapeless(RecipeCategory.BUILDING_BLOCKS, c.get()) - .requires(CITags.Items.CHAIRS) - .requires(color.getTag()) - .unlockedBy("has_chair", RegistrateRecipeProvider.has(CITags.Items.CHAIRS)) - .save(p, CreateInteriors.asResource("crafting/chair/" + c.getName() + "_from_other_chair")); - }) + .forAllStatesExcept(state -> { + String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); + String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; + + int rotation = facing(state); + + return ConfiguredModel.builder().modelFile(p.models() + .withExistingParent("block/chair/kelp_chair_" + armrest + cropped_state, + p.modLoc("block/chair/" + armrest + cropped_state))) + .rotationY(rotation) + .build(); + }, WATERLOGGED)) .onRegister(movementBehaviour(new BigSeatMovementBehaviour())) .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) - .onRegister(assignDataBehaviour(new EntityNameDisplaySource(), "entity_name")) .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) - .tag(CITags.Blocks.CHAIRS) .item() - .tag(CITags.Items.CHAIRS) - .model(AssetLookup.customBlockItemModel("chair", colorName + "_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) + .model(AssetLookup.customBlockItemModel("chair", "kelp_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) .build() .register(); - }); - - public static final BlockEntry KELP_CHAIR = REGISTRATE.block("kelp_chair", p -> new BigChairBlock(p, DyeColor.BLACK)) - .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(DyeColor.BLACK)) - .transform(axeOnly()) - .blockstate((c, p) -> p.getVariantBuilder(c.get()) - .forAllStatesExcept(state -> { - String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); - String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; - - int rotation = facing(state); - - return ConfiguredModel.builder().modelFile(p.models() - .withExistingParent("block/chair/kelp_chair_" + armrest + cropped_state, - p.modLoc("block/chair/" + armrest + cropped_state))) - .rotationY(rotation) - .build(); - }, WATERLOGGED)) - .onRegister(movementBehaviour(new BigSeatMovementBehaviour())) - .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) - .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) - .item() - .model(AssetLookup.customBlockItemModel("chair", "kelp_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) - .build() - .register(); - public static final BlockEntry KELP_FLOOR_CHAIR = REGISTRATE.block("kelp_floor_chair", p -> new FloorChairBlock(p, DyeColor.BLACK)) - .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(DyeColor.BLACK)) - .transform(axeOnly()) - .blockstate((c, p) -> p.getVariantBuilder(c.get()) - .forAllStatesExcept(state -> { - String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); - String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; - - int rotation = facing(state); - - return ConfiguredModel.builder().modelFile(p.models() - .withExistingParent("block/chair/kelp_floor_chair_" + armrest + cropped_state, - p.modLoc("block/floor_chair/" + armrest + cropped_state))) - .rotationY(rotation) - .build(); - }, WATERLOGGED)) - .onRegister(movementBehaviour(new SeatMovementBehaviour())) - .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) - .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) - .item() - .model(AssetLookup.customBlockItemModel("chair", "kelp_floor_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) - .build() - .register(); - + .initialProperties(SharedProperties::wooden) + .properties(p -> p.mapColor(MapColor.TERRACOTTA_BLACK)) + .transform(axeOnly()) + .blockstate((c, p) -> p.getVariantBuilder(c.get()) + .forAllStatesExcept(state -> { + String armrest = state.getValue(ChairBlock.ARMRESTS).getSerializedName(); + String cropped_state = state.getValue(ChairBlock.CROPPED_BACK) ? "_cropped" : ""; + + int rotation = facing(state); + + return ConfiguredModel.builder().modelFile(p.models() + .withExistingParent("block/chair/kelp_floor_chair_" + armrest + cropped_state, + p.modLoc("block/floor_chair/" + armrest + cropped_state))) + .rotationY(rotation) + .build(); + }, WATERLOGGED)) + .onRegister(movementBehaviour(new SeatMovementBehaviour())) + .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) + .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.interiors.chair")) + .item() + .model(AssetLookup.customBlockItemModel("chair", "kelp_floor_chair_" + ChairBlock.ArmrestConfiguration.DEFAULT.getSerializedName())) + .build() + .register(); public static final BlockEntry KELP_SEAT = REGISTRATE.block("kelp_seat", p -> new DirectionalSeatBlock(p, DyeColor.BLACK)) - .initialProperties(SharedProperties::wooden) - .properties(p -> p.mapColor(DyeColor.BLACK)) - .transform(axeOnly()) - .blockstate((context, provider) -> provider.getVariantBuilder(context.get()) - .forAllStatesExcept(state -> { - String facing = state.getValue(ChairBlock.FACING).getSerializedName(); - int rotation = facing(state); + .initialProperties(SharedProperties::wooden) + .properties(p -> p.mapColor(MapColor.TERRACOTTA_BLACK)) + .transform(axeOnly()) + .blockstate((context, provider) -> provider.getVariantBuilder(context.get()) + .forAllStatesExcept(state -> { + String facing = state.getValue(ChairBlock.FACING).getSerializedName(); + int rotation = facing(state); + + return ConfiguredModel.builder() + .modelFile(provider.models().getExistingFile(provider.modLoc("block/kelp_seat"))).rotationY(rotation) + .build(); + }, WATERLOGGED)) + .onRegister(movementBehaviour(new SeatMovementBehaviour())) + .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) + .onRegister(AllDisplayBehaviours.assignDataBehaviour(new EntityNameDisplaySource(), "entity_name")) + .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.create.seat")) + .simpleItem() + .register(); - return ConfiguredModel.builder() - .modelFile(provider.models().getExistingFile(provider.modLoc("block/kelp_seat"))).rotationY(rotation) - .build(); - }, WATERLOGGED)) - .onRegister(movementBehaviour(new SeatMovementBehaviour())) - .onRegister(interactionBehaviour(new SeatInteractionBehaviour())) - .onRegister(assignDataBehaviour(new EntityNameDisplaySource(), "entity_name")) - .onRegisterAfter(Registries.ITEM, v -> ItemDescription.useKey(v, "block.create.seat")) - .simpleItem() - .register(); + static { + REGISTRATE.defaultCreativeTab(CITab.INTERIORS_TAB); + } public static void register() { CreateInteriors.LOGGER.info("Registering blocks!"); diff --git a/src/main/java/com/sudolev/interiors/content/registry/CIEntities.java b/src/main/java/com/sudolev/interiors/content/registry/CIEntities.java index c40817a5..4862497a 100644 --- a/src/main/java/com/sudolev/interiors/content/registry/CIEntities.java +++ b/src/main/java/com/sudolev/interiors/content/registry/CIEntities.java @@ -2,20 +2,18 @@ import com.simibubi.create.foundation.data.CreateEntityBuilder; import com.simibubi.create.foundation.utility.Lang; - -import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.client.renderer.entity.EntityRendererProvider.Context; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType.Builder; -import net.minecraft.world.entity.EntityType.EntityFactory; -import net.minecraft.world.entity.MobCategory; - import com.sudolev.interiors.CreateInteriors; import com.sudolev.interiors.content.entity.BigSeatEntity; import com.tterrag.registrate.util.entry.EntityEntry; import com.tterrag.registrate.util.nullness.NonNullConsumer; import com.tterrag.registrate.util.nullness.NonNullFunction; import com.tterrag.registrate.util.nullness.NonNullSupplier; +import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererProvider; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType.EntityFactory; +import net.minecraft.world.entity.MobCategory; @SuppressWarnings("unused") public final class CIEntities { @@ -24,11 +22,22 @@ public final class CIEntities { .register(); @SuppressWarnings("SameParameterValue") - private static CreateEntityBuilder register(String name, EntityFactory factory, NonNullSupplier>> renderer, MobCategory group, int range, int updateFrequency, boolean sendVelocity, boolean immuneToFire, NonNullConsumer> propertyBuilder) { + private static CreateEntityBuilder register(String name, EntityFactory factory, + NonNullSupplier>> renderer, + MobCategory group, int range, int updateFrequency, boolean sendVelocity, boolean immuneToFire, + NonNullConsumer> propertyBuilder) { String id = Lang.asId(name); - return (CreateEntityBuilder) CreateInteriors.REGISTRATE.entity(id, factory, group).properties(b -> b.setTrackingRange(range).setUpdateInterval(updateFrequency).setShouldReceiveVelocityUpdates(sendVelocity)).properties(propertyBuilder).properties(b -> { - if(immuneToFire) b.fireImmune(); - }).renderer(renderer); + return (CreateEntityBuilder) CreateInteriors.REGISTRATE + .entity(id, factory, group) + .properties(b -> b.trackRangeChunks(range) + .trackedUpdateRate(updateFrequency) + .forceTrackedVelocityUpdates(sendVelocity)) + .properties(propertyBuilder) + .properties(b -> { + if (immuneToFire) + b.fireImmune(); + }) + .renderer(renderer); } public static void register() { } diff --git a/src/main/java/com/sudolev/interiors/content/registry/CITab.java b/src/main/java/com/sudolev/interiors/content/registry/CITab.java index 7709faf5..0d3028b3 100644 --- a/src/main/java/com/sudolev/interiors/content/registry/CITab.java +++ b/src/main/java/com/sudolev/interiors/content/registry/CITab.java @@ -1,31 +1,36 @@ package com.sudolev.interiors.content.registry; -import com.simibubi.create.foundation.utility.Components; - +import com.simibubi.create.AllCreativeModeTabs; +import com.simibubi.create.Create; +import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.DyeColor; -import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.registries.DeferredRegister; -import net.minecraftforge.registries.RegistryObject; - -import com.sudolev.interiors.CreateInteriors; +import java.util.function.Supplier; public final class CITab { - private static final DeferredRegister REGISTER = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, CreateInteriors.ID); - public static final RegistryObject TAB = REGISTER.register("main", - CreativeModeTab.builder() - .title(Components.literal(CreateInteriors.NAME)) - .icon(() -> CIBlocks.CHAIRS.get(DyeColor.RED).asItem().getDefaultInstance()) - .displayItems((parameters, output) -> CreateInteriors.REGISTRATE - .getAll(Registries.BLOCK).stream() - .map(entry -> entry.get().asItem()) - .forEach(output::accept)) - ::build); + public static final AllCreativeModeTabs.TabInfo INTERIORS_TAB = register("base", + () -> FabricItemGroup.builder() + .title(Component.translatable("itemGroup.create.base")) + .icon(() -> CIBlocks.CHAIRS.get(DyeColor.RED).asStack()) + .build()); - public static void register(IEventBus modEventBus) { - REGISTER.register(modEventBus); + private static AllCreativeModeTabs.TabInfo register(String name, Supplier supplier) { + ResourceLocation id = Create.asResource(name); + ResourceKey key = ResourceKey.create(Registries.CREATIVE_MODE_TAB, id); + CreativeModeTab tab = supplier.get(); + Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, key, tab); + return new AllCreativeModeTabs.TabInfo(key, tab); } -} + + public static void register() { + // fabric: just load the class + } +}; diff --git a/src/main/java/com/sudolev/interiors/content/registry/CITags.java b/src/main/java/com/sudolev/interiors/content/registry/CITags.java index be7aa5da..f743b4c0 100644 --- a/src/main/java/com/sudolev/interiors/content/registry/CITags.java +++ b/src/main/java/com/sudolev/interiors/content/registry/CITags.java @@ -1,21 +1,176 @@ package com.sudolev.interiors.content.registry; -import net.minecraft.tags.BlockTags; -import net.minecraft.tags.ItemTags; +import com.simibubi.create.AllTags; +import com.simibubi.create.Create; +import com.simibubi.create.foundation.data.TagGen; +import com.simibubi.create.foundation.utility.Lang; +import com.tterrag.registrate.builders.BlockBuilder; +import com.tterrag.registrate.builders.ItemBuilder; +import com.tterrag.registrate.util.nullness.NonNullFunction; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; import net.minecraft.tags.TagKey; +import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; -import com.sudolev.interiors.CreateInteriors; +import static com.simibubi.create.AllTags.NameSpace.MOD; -public final class CITags { - public static final class Blocks { - public static final TagKey CHAIRS = BlockTags.create(CreateInteriors.asResource("chairs")); - public static final TagKey FLOOR_CHAIRS = BlockTags.create(CreateInteriors.asResource("floor_chairs")); +public class CITags { + public static TagKey optionalTag(Registry registry, + ResourceLocation id) { + return TagKey.create(registry.key(), id); } - public static final class Items { - public static final TagKey CHAIRS = ItemTags.create(CreateInteriors.asResource("chairs")); - public static final TagKey FLOOR_CHAIRS = ItemTags.create(CreateInteriors.asResource("floor_chairs")); + public static TagKey forgeTag(Registry registry, String path) { + return optionalTag(registry, new ResourceLocation("c", path)); } -} + + public static TagKey forgeBlockTag(String path) { + return forgeTag(BuiltInRegistries.BLOCK, path); + } + + public static TagKey forgeItemTag(String path) { + return forgeTag(BuiltInRegistries.ITEM, path); + } + + @Deprecated(forRemoval = true) + public static NonNullFunction, BlockBuilder> axeOrPickaxe() { + return TagGen.axeOrPickaxe(); + } + + @Deprecated(forRemoval = true) + public static NonNullFunction, BlockBuilder> axeOnly() { + return TagGen.axeOnly(); + } + + @Deprecated(forRemoval = true) + public static NonNullFunction, BlockBuilder> pickaxeOnly() { + return TagGen.pickaxeOnly(); + } + + @Deprecated(forRemoval = true) + public static NonNullFunction, ItemBuilder>> tagBlockAndItem( + String... path) { + return TagGen.tagBlockAndItem(path); + } + + public static void register() { + BlockTags.init(); + ItemTags.init(); + } + + public enum NameSpace { + MOD(Create.ID, false, true), + + + ; + + public final String id; + public final boolean optionalDefault; + public final boolean alwaysDatagenDefault; + + NameSpace(String id) { + this(id, true, false); + } + + NameSpace(String id, boolean optionalDefault, boolean alwaysDatagenDefault) { + this.id = id; + this.optionalDefault = optionalDefault; + this.alwaysDatagenDefault = alwaysDatagenDefault; + } + } + + public enum BlockTags { + CHAIRS, + FLOOR_CHAIRS, + + ; + + public final TagKey tag; + public final boolean alwaysDatagen; + + BlockTags() { + this(MOD); + } + + BlockTags(AllTags.NameSpace namespace) { + this(namespace, namespace.optionalDefault, namespace.alwaysDatagenDefault); + } + + BlockTags(AllTags.NameSpace namespace, String path) { + this(namespace, path, namespace.optionalDefault, namespace.alwaysDatagenDefault); + } + + BlockTags(AllTags.NameSpace namespace, boolean optional, boolean alwaysDatagen) { + this(namespace, null, optional, alwaysDatagen); + } + + BlockTags(AllTags.NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) { + ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path); + tag = optionalTag(BuiltInRegistries.BLOCK, id); + this.alwaysDatagen = alwaysDatagen; + } + + private static void init() { + } + + @SuppressWarnings("deprecation") + public boolean matches(Block block) { + return block.builtInRegistryHolder() + .is(tag); + } + + public boolean matches(BlockState state) { + return state.is(tag); + } + } + + + public enum ItemTags { + CHAIRS, + FLOOR_CHAIRS; + + public final TagKey tag; + public final boolean alwaysDatagen; + + ItemTags() { + this(MOD); + } + + ItemTags(AllTags.NameSpace namespace) { + this(namespace, namespace.optionalDefault, namespace.alwaysDatagenDefault); + } + + ItemTags(AllTags.NameSpace namespace, String path) { + this(namespace, path, namespace.optionalDefault, namespace.alwaysDatagenDefault); + } + + ItemTags(AllTags.NameSpace namespace, boolean optional, boolean alwaysDatagen) { + this(namespace, null, optional, alwaysDatagen); + } + + ItemTags(AllTags.NameSpace namespace, String path, boolean optional, boolean alwaysDatagen) { + ResourceLocation id = new ResourceLocation(namespace.id, path == null ? Lang.asId(name()) : path); + tag = optionalTag(BuiltInRegistries.ITEM, id); + + this.alwaysDatagen = alwaysDatagen; + } + + private static void init() { + } + + @SuppressWarnings("deprecation") + public boolean matches(Item item) { + return item.builtInRegistryHolder() + .is(tag); + } + + public boolean matches(ItemStack stack) { + return stack.is(tag); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/sudolev/interiors/foundation/data/CIDatagen.java b/src/main/java/com/sudolev/interiors/foundation/data/CIDatagen.java deleted file mode 100644 index 658ff3d8..00000000 --- a/src/main/java/com/sudolev/interiors/foundation/data/CIDatagen.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.sudolev.interiors.foundation.data; - -import com.simibubi.create.foundation.utility.FilesHelper; - -import net.minecraft.data.DataGenerator; - -import net.minecraftforge.data.event.GatherDataEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; - -import com.google.common.base.Preconditions; -import com.google.gson.JsonObject; -import com.sudolev.interiors.CreateInteriors; - -public class CIDatagen { - - @SubscribeEvent - public static void gatherData(GatherDataEvent event) { - CreateInteriors.LOGGER.info("Generating data for Create Interiors"); - DataGenerator gen = event.getGenerator(); - genLang(); - } - - private static void genLang() { - provideDefaultLang("tooltips"); - } - - private static void provideDefaultLang(String fileName) { - String path = "assets/" + CreateInteriors.ID + "/lang/default/" + fileName + ".json"; - - JsonObject jsonObject = Preconditions.checkNotNull(FilesHelper.loadJsonResource(path), - "Could not find default lang file: %s", path).getAsJsonObject(); - - jsonObject.entrySet().forEach(entry -> - CreateInteriors.REGISTRATE.addRawLang(entry.getKey(), entry.getValue().getAsString()) - ); - } -} diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml deleted file mode 100644 index 255383fd..00000000 --- a/src/main/resources/META-INF/mods.toml +++ /dev/null @@ -1,45 +0,0 @@ -modLoader = "javafml" -loaderVersion = "[${neo_version},)" -license = "GPL-3.0" -issueTrackerURL = "https://github.com/sudolev/CreateInteriorsMod/issues" - -[[mods]] -modId = "interiors" -version = "${version}" -displayName = "Create: Interiors" -# https://docs.neoforged.net/docs/misc/updatechecker/ -#updateJSONURL="https://change.me.example.invalid/updates.json" -displayURL = "https://sudolev.github.io/CreateInteriorsMod/" -issueTrackerURL = "https://github.com/sudolev/CreateInteriorsMod/issues" -logoFile="mod_banner.png" -credits = "rdh" -authors = "sudolev" -description = ''' -Create: Interiors is a new take on furniture, adding functional blocks that mesh seamlessly with the aesthetic and principles of the Create mod. -''' - -[[dependencies.interiors]] -modId = "forge" -mandatory = true -versionRange = "[${neo_version},)" -ordering = "NONE" -side = "BOTH" - -[[dependencies.interiors]] -modId = "minecraft" -mandatory = true -versionRange = "${minecraft_version}" -ordering = "NONE" -side = "BOTH" - -[[dependencies.interiors]] -modId = "create" -mandatory = true -versionRange = "[${create_version},)" -ordering = "NONE" -side = "BOTH" - -[modproperties.interiors] -catalogueImageIcon="icon.png" -catalogueBackground="mod_banner.png" -configuredBackground="create:textures/block/seat/top_red.png" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..da8d57f3 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,36 @@ +{ + "schemaVersion": 1, + "id": "interiors", + "version": "${version}", + "name": "Create: Interiors", + "description": "Extend Create's furnishing possibilities.", + "authors": [ + "sudolev" + ], + "contributors": [ + "rdh" + ], + "contact": { + "homepage": "https://modrinth.com/mod/interiors", + "issues": "https://github.com/sudolev/CreateInteriorsMod/issues", + "email": "i@sudolev.com", + "sources": "https://github.com/sudolev/CreateInteriorsMod" + }, + "license": "GPL-3.0", + "icon": "icon.png", + "environment": "*", + "entrypoints": { + "main": [ + "com.sudolev.interiors.CreateInteriors" + ] + }, + "mixins": [ + "interiors.mixins.json" + ], + "depends": { + "fabricloader": ">=${fabric_loader_version}", + "fabric-api": ">=${fabric_api_version}", + "create": "${create_version}", + "minecraft": "${minecraft_version}" + } +} \ No newline at end of file