Using BlockSets. Added filtering and several replace settings.

Overhauled build.gradle based on Create. Added flywheel as jarInJar, no external dependency anymore. New mappings channel from parchment.
Added replace modes: air, air and solid, solid, offhand filtered. Offhand filtering looks in randomizer bag as well.
Protecting tile entities by default.
Other mods can cancel placement through BlockEvent.OnBlockPlaced, such as FTBChunks.
BlockPreviews.drawOutlinesIfNoBlockInHand overhaul.
This commit is contained in:
Christian Knaapen
2023-01-22 20:36:48 +01:00
parent ae75e48c01
commit af4ef73375
36 changed files with 858 additions and 424 deletions

View File

@@ -1,85 +1,66 @@
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
jcenter()
maven { url = 'https://repo.spongepowered.org/repository/maven-public' }
maven { url = 'https://maven.parchmentmc.org' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: "${forgegradle_version}", changing: false
classpath "org.spongepowered:mixingradle:${mixingradle_version}"
classpath "org.parchmentmc:librarian:${librarian_version}"
}
}
plugins {
id 'com.matthewprenger.cursegradle' version "${cursegradle_version}"
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
version = '1.19-2.40'
jarJar.enable()
boolean flywheelInWorkspace = findProject(':Flywheel') != null
ext.buildNumber = System.getenv('BUILD_NUMBER')
version = mod_version
group = 'nl.requios.effortlessbuilding'
archivesBaseName = 'effortlessbuilding'
archivesBaseName = "effortlessbuilding-${artifact_minecraft_version}"
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.19.2'
mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment (SCAN,REGISTRIES,REGISTRYDUMP)
property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'effortlessbuilding'
// Flywheel
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
arg '-mixin.config=flywheel.mixins.json'
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
property 'forge.logging.console.level', 'info'
mods {
effortlessbuilding {
source sourceSets.main
}
if (flywheelInWorkspace) {
flywheel {
source project(":Flywheel").sourceSets.main
}
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'effortlessbuilding'
// Flywheel
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
mods {
effortlessbuilding {
source sourceSets.main
}
}
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'effortlessbuilding'
workingDirectory project.file('run/server')
property 'forge.logging.console.level', 'info'
mods {
effortlessbuilding {
source sourceSets.main
@@ -89,73 +70,107 @@ minecraft {
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', 'effortlessbuilding', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
args '--mod', 'effortlessbuilding', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
mods {
effortlessbuilding {
source sourceSets.main
}
if (flywheelInWorkspace) {
flywheel {
source project(":Flywheel").sourceSets.main
}
}
}
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// flatDir {
// dir 'libs'
// }
//Flywheel
maven {
name "tterrag maven"
url "https://maven.tterrag.com/"
// Location of the maven that hosts JEI files (and TiC)
name 'Progwml6 maven'
url 'https://dvs1.progwml6.com/files/maven'
}
/*maven {
// Location of a maven mirror for JEI files, as a fallback
name 'ModMaven'
url 'https://modmaven.k-4u.nl'
}*/
maven {
// Location of the maven for vazkii's mods
name 'blamejared'
url 'https://maven.blamejared.com'
}
maven {
// Location of the maven for mixed mappings, Registrate, and Flywheel
name 'tterrag maven'
url 'https://maven.tterrag.com'
}
maven {
url 'https://www.cursemaven.com'
content {
includeGroup "curse.maven"
}
}
maven {
//location of the maven for dynamic trees
url 'https://harleyoconnor.com/maven'
}
maven {
//location of the maven for curios api
url = "https://maven.theillusivec4.top/"
}
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
}
dependencies {
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.2-43.1.47'
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
// Real mod deobf dependency examples - these get remapped to your current mappings
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
jarJar(group: 'com.jozufozu.flywheel', name: "flywheel-forge-${flywheel_minecraft_version}", version: '[0.6.8,0.6.9)') {
jarJar.pin(it, project.flywheel_version)
}
// Examples using mod jars from ./libs
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
if (flywheelInWorkspace) {
implementation project(':Flywheel')
} else {
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}")
}
// For more info...
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
//Flywheel
//Versions: https://maven.tterrag.com/com/jozufozu/flywheel/flywheel-forge-1.19.2/
implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-1.19.2:0.6.8-13")
// Prevent Mixin annotation processor from getting into IntelliJ's annotation processor settings
// This allows 'Settings > Build, Execution, and Deployment > Build Tools > Gradle > Build and run using' set to IntelliJ to work correctly
if (System.getProperty('idea.sync.active') != 'true') {
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
}
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
exclude '.cache/'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
compileJava {
options.compilerArgs = ['-Xdiags:verbose']
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "effortlessbuilding",
"Specification-Vendor": "requios",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Specification-Version": "1",
"Implementation-Title": project.jar.baseName,
"Implementation-Version": project.jar.archiveVersion,
"Implementation-Vendor" :"requios",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
@@ -163,25 +178,37 @@ jar {
}
}
// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
task jarJarRelease {
doLast {
tasks.jarJar {
classifier = ''
}
}
finalizedBy tasks.jarJar
}
java {
withSourcesJar()
withJavadocJar()
}
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn('reobfJar')
tasks.jarJar.finalizedBy('reobfJarJar')
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifactId = archivesBaseName
from components.java
fg.component(it)
jarJar.component(it)
}
}
repositories {
maven {
url "file://${project.projectDir}/mcmodsrepo"
if (project.hasProperty('mavendir')) {
maven { url mavendir }
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}