pre修改:添加对事件的支持&API方法的修正
This commit is contained in:
parent
6553f04b4e
commit
44bc1ad92a
376
build.gradle
376
build.gradle
|
|
@ -1,3 +1,5 @@
|
||||||
|
//noinspection GroovyAssignabilityCheck
|
||||||
|
//file:noinspection GroovyAssignabilityCheck
|
||||||
import proguard.gradle.ProGuardTask
|
import proguard.gradle.ProGuardTask
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
|
@ -14,11 +16,11 @@ plugins {
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'org.jetbrains.dokka' version '1.9.10'
|
|
||||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||||
id 'net.neoforged.moddev.legacyforge' version '2.0.103'
|
id 'net.neoforged.moddev.legacyforge' version '2.0.103'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================== 基础配置 =====================
|
||||||
def enableProguard = project.hasProperty("enableProguard") && project.enableProguard.toBoolean()
|
def enableProguard = project.hasProperty("enableProguard") && project.enableProguard.toBoolean()
|
||||||
|
|
||||||
tasks.named('wrapper', Wrapper).configure {
|
tasks.named('wrapper', Wrapper).configure {
|
||||||
|
|
@ -38,68 +40,65 @@ base {
|
||||||
|
|
||||||
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
|
||||||
|
|
||||||
|
// ===================== 仓库配置 =====================
|
||||||
repositories {
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
maven { url = "https://libraries.minecraft.net/" }
|
maven { url = "https://libraries.minecraft.net/" }
|
||||||
maven { url = "https://neoforged.forgecdn.net/releases" }
|
maven { url = "https://neoforged.forgecdn.net/releases" }
|
||||||
maven { url = "https://neoforged.forgecdn.net/mojang-meta" }
|
maven { url = "https://neoforged.forgecdn.net/mojang-meta" }
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url "https://cursemaven.com"
|
url "https://cursemaven.com"
|
||||||
content {
|
content { includeGroup "curse.maven" }
|
||||||
includeGroup "curse.maven"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
// location of the maven that hosts JEI files before January 2023
|
name = "Progwml6"
|
||||||
name = "Progwml6's maven"
|
|
||||||
url = "https://dvs1.progwml6.com/files/maven/"
|
url = "https://dvs1.progwml6.com/files/maven/"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
// location of the maven that hosts JEI files since January 2023
|
name = "BlameJared"
|
||||||
name = "Jared's maven"
|
|
||||||
url = "https://maven.blamejared.com/"
|
url = "https://maven.blamejared.com/"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
// location of a maven mirror for JEI files, as a fallback
|
|
||||||
name = "ModMaven"
|
name = "ModMaven"
|
||||||
url = "https://modmaven.dev"
|
url = "https://modmaven.dev"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name 'luck-repo'
|
name = "Lucko"
|
||||||
url 'https://repo.lucko.me/'
|
url = "https://repo.lucko.me/"
|
||||||
content {
|
content { includeModule 'me.lucko', 'spark-api' }
|
||||||
includeModule 'me.lucko', 'spark-api'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name "KosmX's maven"
|
name = "KosmX"
|
||||||
url 'https://maven.kosmx.dev/'
|
url = "https://maven.kosmx.dev/"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = "Curios"
|
name = "Curios"
|
||||||
url = uri("https://maven.theillusivec4.top/")
|
url = "https://maven.theillusivec4.top/"
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = 'GeckoLib'
|
name = "GeckoLib"
|
||||||
url 'https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/'
|
url = "https://dl.cloudsmith.io/public/geckolib3/geckolib/maven/"
|
||||||
content {
|
content {
|
||||||
includeGroupByRegex("software\\.bernie.*")
|
includeGroupByRegex("software\\.bernie.*")
|
||||||
includeGroup("com.eliotlash.mclib")
|
includeGroup("com.eliotlash.mclib")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mavenCentral()
|
maven {
|
||||||
flatDir {
|
name = "LTD Maven"
|
||||||
dir "libs"
|
url = "https://nexus.bot.leisuretimedock.top/repository/maven-public/"
|
||||||
}
|
}
|
||||||
|
flatDir { dir "libs" }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================== Forge 配置 =====================
|
||||||
legacyForge {
|
legacyForge {
|
||||||
version = "${minecraft_version}-${forge_version}"
|
version = "${minecraft_version}-${forge_version}"
|
||||||
accessTransformers = project.files "src/main/resources/META-INF/accesstransformer.cfg"
|
accessTransformers = files("src/main/templates/META-INF/accesstransformer.cfg")
|
||||||
|
|
||||||
parchment {
|
parchment {
|
||||||
minecraftVersion = "${minecraft_version}"
|
minecraftVersion = minecraft_version
|
||||||
mappingsVersion = "${mapping_lasting_version}"
|
mappingsVersion = mapping_lasting_version
|
||||||
}
|
}
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
|
|
@ -108,57 +107,52 @@ legacyForge {
|
||||||
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
||||||
logLevel = org.slf4j.event.Level.DEBUG
|
logLevel = org.slf4j.event.Level.DEBUG
|
||||||
}
|
}
|
||||||
|
client {
|
||||||
|
client()
|
||||||
|
systemProperty 'forge.enabledGameTestNamespaces', mod_id
|
||||||
|
}
|
||||||
clientAuth {
|
clientAuth {
|
||||||
devLogin = true
|
devLogin = true
|
||||||
client()
|
client()
|
||||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
systemProperty 'forge.enabledGameTestNamespaces', mod_id
|
||||||
// // 设置 RenderDoc library 路径
|
|
||||||
// // 系统属性,使用项目相对路径
|
|
||||||
// systemProperty 'neoforged.rendernurse.renderdoc.library', file('RenderDoc_1.40_64/renderdoc.dll').absolutePath
|
|
||||||
//
|
|
||||||
// // JVM 参数
|
|
||||||
// jvmArgument "-javaagent:${file('libs/RenderNurse-0.0.9.jar').absolutePath}"
|
|
||||||
// jvmArgument "--enable-preview"
|
|
||||||
// jvmArgument "--enable-native-access=ALL-UNNAMED"
|
|
||||||
|
|
||||||
}
|
|
||||||
client {
|
|
||||||
client()
|
|
||||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
|
||||||
}
|
|
||||||
gameTestServer {
|
|
||||||
type = "gameTestServer"
|
|
||||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
|
||||||
}
|
|
||||||
data {
|
|
||||||
systemProperty('gradle.task', 'runData')
|
|
||||||
data()
|
|
||||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
|
||||||
programArguments.addAll '--mod', project.mod_id, '--all',
|
|
||||||
'--output', file('src/generated/resources/').getAbsolutePath(),
|
|
||||||
'--existing', file('src/main/resources/').getAbsolutePath()
|
|
||||||
}
|
}
|
||||||
server {
|
server {
|
||||||
server()
|
server()
|
||||||
}
|
}
|
||||||
|
data {
|
||||||
|
data()
|
||||||
|
programArguments.addAll '--mod', mod_id, '--all',
|
||||||
|
'--output', file('src/generated/resources/').absolutePath,
|
||||||
|
'--existing', file('src/main/resources/').absolutePath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
"${mod_id}" {
|
"${mod_id}" {
|
||||||
sourceSet(sourceSets.main)
|
sourceSet sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 源码资源目录
|
// ===================== 源码与资源 =====================
|
||||||
sourceSets.main.resources {
|
sourceSets.main.resources {
|
||||||
srcDir 'src/generated/resources'
|
srcDir 'src/generated/resources'
|
||||||
srcDir 'src/main/resources' // 记得加这一行,把 coremods 包含进去
|
srcDir 'src/main/resources'
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 依赖 ==========
|
// ===================== 编译配置 =====================
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 依赖 =====================
|
||||||
configurations {
|
configurations {
|
||||||
runtimeClasspath.extendsFrom localRuntime
|
runtimeClasspath.extendsFrom localRuntime
|
||||||
|
proguardLibs {
|
||||||
|
canBeResolved = true
|
||||||
|
canBeConsumed = false
|
||||||
|
extendsFrom modCompileOnly
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
@ -184,57 +178,107 @@ dependencies {
|
||||||
implementation 'org.ow2.asm:asm-tree:9.6'
|
implementation 'org.ow2.asm:asm-tree:9.6'
|
||||||
implementation 'org.ow2.asm:asm-commons:9.6'
|
implementation 'org.ow2.asm:asm-commons:9.6'
|
||||||
implementation 'org.ow2.asm:asm-util:9.6'
|
implementation 'org.ow2.asm:asm-util:9.6'
|
||||||
|
modCompileOnly("top.r3944realms.lib39:lib39:1.20.1-0.0.15:all@jar")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 编译配置 ==========
|
// ===================== 修复 Javadoc 任务 =====================
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.named('javadoc', Javadoc).configure {
|
||||||
|
group = 'documentation'
|
||||||
|
description = 'Generates full Javadoc for the mod.'
|
||||||
|
destinationDir = file("$buildDir/docs/javadoc")
|
||||||
|
|
||||||
|
// 明确指定源与类路径
|
||||||
|
source = sourceSets.main.allJava
|
||||||
|
classpath = sourceSets.main.compileClasspath
|
||||||
|
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
|
options.charSet = 'UTF-8'
|
||||||
|
options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
|
||||||
|
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||||
|
options.addBooleanOption('Xdoclint:none', true)
|
||||||
|
options.addStringOption('doctitle', "${mod_id} ${mod_version} Javadoc")
|
||||||
}
|
}
|
||||||
|
|
||||||
dokkaJavadoc {
|
// ===================== 普通 Javadoc =====================
|
||||||
outputDirectory = file("$buildDir/javadoc")
|
tasks.register('javadocJar', Jar) {
|
||||||
|
archiveClassifier.set('javadoc')
|
||||||
|
from tasks.javadoc
|
||||||
|
dependsOn tasks.javadoc
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== API Jar 配置 ==========
|
tasks.register('apiJavadocJar', Jar) {
|
||||||
|
archiveClassifier.set('api-javadoc')
|
||||||
|
from tasks.javadoc
|
||||||
|
include "top/r3944realms/superleadrope/api/**/*"
|
||||||
|
dependsOn tasks.javadoc
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ===================== API Jar(class + java 混杂) =====================
|
||||||
tasks.register('apiJar', Jar) {
|
tasks.register('apiJar', Jar) {
|
||||||
archiveClassifier.set('api')
|
archiveClassifier.set('api')
|
||||||
from sourceSets.main.output
|
|
||||||
include "top/r3944realms/superleadrope/api/**/*"
|
|
||||||
include "top/r3944realms/superleadrope/SuperLeadRopeAPI.class"
|
|
||||||
|
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes 'FMLModType': 'GAMELIBRARY'
|
||||||
'Specification-Title' : "${mod_id}-api",
|
|
||||||
'Specification-Vendor' : mod_authors,
|
|
||||||
'Specification-Version' : '1',
|
|
||||||
'Implementation-Title' : "${project.name}-api",
|
|
||||||
'Implementation-Version' : archiveVersion,
|
|
||||||
'Implementation-Vendor' : mod_authors,
|
|
||||||
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
|
||||||
'FMLModType' : 'GAMELIBRARY'
|
|
||||||
])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 确保包含 API 相关的源文件
|
// 打包 class 和 java
|
||||||
|
from(sourceSets.main.allSource) // java
|
||||||
|
from(sourceSets.main.output) { // class
|
||||||
|
exclude 'assets/**', 'data/**'
|
||||||
|
}
|
||||||
|
|
||||||
|
include "top/r3944realms/superleadrope/api/**/*"
|
||||||
|
include "top/r3944realms/superleadrope/SuperLeadRopeAPI.*"
|
||||||
|
|
||||||
dependsOn classes
|
dependsOn classes
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建包含源码的 API Jar
|
tasks.register('apiJavadoc', Javadoc) {
|
||||||
tasks.register('sourcesApiJar', Jar) {
|
group = 'documentation'
|
||||||
archiveClassifier.set('api-sources')
|
description = 'Generates Javadoc for API package only.'
|
||||||
from sourceSets.main.allSource
|
destinationDir = file("$buildDir/docs/api-javadoc")
|
||||||
|
|
||||||
|
source = sourceSets.main.allJava.matching {
|
||||||
include "top/r3944realms/superleadrope/api/**/*"
|
include "top/r3944realms/superleadrope/api/**/*"
|
||||||
include "top/r3944realms/superleadrope/SuperLeadRopeAPI.java"
|
include "top/r3944realms/superleadrope/SuperLeadRopeAPI.java"
|
||||||
}
|
}
|
||||||
|
classpath = sourceSets.main.compileClasspath
|
||||||
// 创建 API Javadoc Jar
|
options.encoding = 'UTF-8'
|
||||||
tasks.register('javadocApiJar', Jar) {
|
options.charSet = 'UTF-8'
|
||||||
archiveClassifier.set('api-javadoc')
|
options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
|
||||||
from dokkaJavadoc
|
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||||
dependsOn dokkaJavadoc
|
options.addBooleanOption('Xdoclint:none', true)
|
||||||
|
options.addStringOption('doctitle', "${mod_name} API ${mod_version} Javadoc")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 打包配置 ==========
|
tasks.register('javadocApiJar', Jar) {
|
||||||
|
archiveClassifier.set('api-javadoc')
|
||||||
|
from tasks.apiJavadoc
|
||||||
|
dependsOn tasks.apiJavadoc
|
||||||
|
}
|
||||||
|
// ===================== 主包完整 Jar(class + java) =====================
|
||||||
|
tasks.register('fullJar', Jar) {
|
||||||
|
archiveClassifier.set('all') // Maven 上会是 -all.jar
|
||||||
|
from(sourceSets.main.allSource) // java
|
||||||
|
from(sourceSets.main.output) // class
|
||||||
|
// === 避免重复打包资源(即使混入其他 jar 时也不会重复) ===
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
manifest {
|
||||||
|
attributes([
|
||||||
|
'Specification-Title' : mod_id,
|
||||||
|
'Specification-Vendor' : mod_authors,
|
||||||
|
'Specification-Version' : '1',
|
||||||
|
'Implementation-Title' : project.name,
|
||||||
|
'Implementation-Version' : archiveVersion,
|
||||||
|
'Implementation-Vendor' : mod_authors,
|
||||||
|
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
dependsOn classes
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================== 主 Jar 与混淆 =====================
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes([
|
||||||
|
|
@ -255,9 +299,36 @@ jar {
|
||||||
finalizedBy 'proguard'
|
finalizedBy 'proguard'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源处理
|
tasks.register('proguard', ProGuardTask) {
|
||||||
|
onlyIf { enableProguard }
|
||||||
|
dependsOn tasks.jar
|
||||||
|
configuration 'proguard.pro'
|
||||||
|
|
||||||
|
libraryjars "${System.getProperty('java.home')}/jmods"
|
||||||
|
configurations.proguardLibs.resolve().each { file ->
|
||||||
|
libraryjars file.absolutePath
|
||||||
|
}
|
||||||
|
|
||||||
|
def inputJar = tasks.jar.archiveFile.get().asFile
|
||||||
|
injars inputJar
|
||||||
|
outjars "${buildDir}/libs/[NOTUSE]${mod_id}-${minecraft_version}-${mod_version}-proguard.jar"
|
||||||
|
|
||||||
|
doFirst {
|
||||||
|
copy {
|
||||||
|
from inputJar
|
||||||
|
into "${buildDir}/libs"
|
||||||
|
rename { "[NOTUSE]${mod_id}-${minecraft_version}-${mod_version}-origin.jar" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inputs.files tasks.jar.archiveFile
|
||||||
|
finalizedBy 'reobfJar'
|
||||||
|
}
|
||||||
processResources {
|
processResources {
|
||||||
def props = [
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
}
|
||||||
|
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
|
||||||
|
var replaceProperties = [
|
||||||
minecraft_version : minecraft_version,
|
minecraft_version : minecraft_version,
|
||||||
minecraft_version_range : minecraft_version_range,
|
minecraft_version_range : minecraft_version_range,
|
||||||
forge_version : forge_version,
|
forge_version : forge_version,
|
||||||
|
|
@ -268,158 +339,119 @@ processResources {
|
||||||
mod_license : mod_license,
|
mod_license : mod_license,
|
||||||
mod_version : mod_version,
|
mod_version : mod_version,
|
||||||
mod_authors : mod_authors,
|
mod_authors : mod_authors,
|
||||||
mod_description : mod_description
|
mod_description : mod_description,
|
||||||
|
mod_credits : mod_credits
|
||||||
]
|
]
|
||||||
inputs.properties props
|
|
||||||
|
|
||||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
inputs.properties replaceProperties
|
||||||
expand props + [project: project]
|
expand replaceProperties
|
||||||
}
|
from "src/main/templates"
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
into "build/generated/sources/modMetadata"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShadowJar 禁止缓存优化
|
sourceSets.main.resources.srcDir generateModMetadata
|
||||||
shadowJar {
|
legacyForge.ideSyncTask generateModMetadata
|
||||||
outputs.upToDateWhen { false }
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新建一个可解析配置专门给 ProGuard
|
|
||||||
configurations {
|
|
||||||
proguardLibs {
|
|
||||||
canBeResolved = true
|
|
||||||
canBeConsumed = false
|
|
||||||
extendsFrom modCompileOnly
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== ProGuard 配置 ==========
|
|
||||||
tasks.register('proguard', ProGuardTask) {
|
|
||||||
onlyIf { enableProguard } // 只有 enableProguard=true 才会执行
|
|
||||||
dependsOn(tasks.jar)
|
|
||||||
configuration 'proguard.pro'
|
|
||||||
|
|
||||||
// JDK jmods 库
|
|
||||||
libraryjars "${System.getProperty('java.home')}/jmods"
|
|
||||||
|
|
||||||
// 使用可解析配置
|
|
||||||
configurations.proguardLibs.resolve().each { file ->
|
|
||||||
libraryjars file.absolutePath
|
|
||||||
}
|
|
||||||
|
|
||||||
// 输入输出
|
|
||||||
def inputJar = tasks.jar.archiveFile.get().asFile
|
|
||||||
injars(inputJar)
|
|
||||||
outjars("${project.buildDir}/libs/[NOTUSE]${mod_id}-${minecraft_version}-${mod_version}-proguard.jar")
|
|
||||||
doFirst {
|
|
||||||
copy {
|
|
||||||
from inputJar
|
|
||||||
into "${project.buildDir}/libs"
|
|
||||||
rename { "[NOTUSE]${mod_id}-${minecraft_version}-${mod_version}-origin.jar" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inputs.files(tasks.jar.archiveFile)
|
|
||||||
finalizedBy 'reobfJar'
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== Forge reobf 绑定 ==========
|
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
tasks.named('reobfJar') {
|
tasks.named('reobfJar') {
|
||||||
if (enableProguard) {
|
if (enableProguard) {
|
||||||
dependsOn('proguard')
|
dependsOn 'proguard'
|
||||||
input = file("${buildDir}/libs/[NOTUSE]${mod_id}-${minecraft_version}-${mod_version}-proguard.jar")
|
input = file("${buildDir}/libs/[NOTUSE]${mod_id}-${minecraft_version}-${mod_version}-proguard.jar")
|
||||||
} else {
|
} else {
|
||||||
dependsOn('jar')
|
dependsOn 'jar'
|
||||||
input = tasks.jar.archiveFile.get().asFile
|
input = tasks.jar.archiveFile.get().asFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 发布配置 ==========
|
|
||||||
|
|
||||||
|
// ===================== 发布配置 =====================
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
artifact jar
|
artifactId = mod_id
|
||||||
// 添加 API 相关构件
|
|
||||||
artifact apiJar
|
artifact fullJar
|
||||||
artifact sourcesApiJar
|
artifact apiJar
|
||||||
artifact javadocApiJar
|
// 可选
|
||||||
|
artifact javadocJar
|
||||||
|
artifact apiJavadocJar
|
||||||
|
|
||||||
// POM 配置,便于其他模组依赖
|
|
||||||
pom {
|
pom {
|
||||||
name = "${mod_name} API"
|
name = "${mod_id}"
|
||||||
description = "The API for ${mod_name}"
|
description = "The API for ${mod_name}"
|
||||||
url = "https://github.com/3944Realms/SuperLeadMod"
|
url = "https://github.com/3944Realms/SuperLeadMod"
|
||||||
|
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name = mod_license
|
name = mod_license
|
||||||
url = "https://opensource.org/licenses/MIT"
|
url = "https://www.gnu.org/licenses/gpl-3.0.en.html#license-text"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
developers {
|
developers {
|
||||||
developer {
|
developer {
|
||||||
id = "r3944realms"
|
id = "${mod_id}"
|
||||||
name = mod_authors
|
name = mod_authors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url "file://${project.projectDir}/mcmodsrepo"
|
url "file://${project.projectDir}/mcmodsrepo"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
name = 'LTDNexus'
|
||||||
|
url = 'https://nexus.bot.leisuretimedock.top/repository/maven-releases/'
|
||||||
|
credentials {
|
||||||
|
username = System.getenv('LTDNexusUsername') ?: ''
|
||||||
|
password = System.getenv('LTDNexusPassword') ?: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 构建任务依赖 ==========
|
// ===================== 构建任务依赖 =====================
|
||||||
// 确保构建任务包含 API Jar
|
|
||||||
tasks.named('build') {
|
tasks.named('build') {
|
||||||
dependsOn apiJar, sourcesApiJar, javadocApiJar
|
dependsOn apiJar, javadocApiJar
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理任务
|
|
||||||
tasks.named('clean') {
|
tasks.named('clean') {
|
||||||
delete fileTree(dir: "${project.projectDir}/mcmodsrepo")
|
delete fileTree(dir: "${project.projectDir}/mcmodsrepo")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================== RenderDoc 运行支持 =====================
|
||||||
tasks.register("runWithRenderDoc", Exec) {
|
tasks.register("runWithRenderDoc", Exec) {
|
||||||
group = "minecraft"
|
group = "minecraft"
|
||||||
description = "Run Minecraft with RenderDoc using runClientAuth configuration"
|
description = "Run Minecraft with RenderDoc using runClientAuth configuration"
|
||||||
dependsOn("classes") // 确保源码编译完成
|
dependsOn "classes"
|
||||||
def jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
|
|
||||||
|
|
||||||
def renderDocCmd = file("RenderDoc_1.40_64/renderdoccmd.exe").absolutePath
|
def renderDocCmd = file("RenderDoc_1.40_64/renderdoccmd.exe").absolutePath
|
||||||
def captureDir = file("$buildDir/renderdoc/capture").absolutePath
|
def captureDir = file("$buildDir/renderdoc/capture").absolutePath
|
||||||
|
|
||||||
def runClientTask = tasks.named("runClientAuth", JavaExec).get()
|
def runClientTask = tasks.named("runClientAuth", JavaExec).get()
|
||||||
def javaLauncher = runClientTask.getJavaLauncher().get()
|
def javaExecPath = new File(runClientTask.getJavaLauncher().get().metadata.installationPath.asFile, "bin/java.exe").absolutePath
|
||||||
def javaExecPath = new File(javaLauncher.metadata.installationPath.asFile, "bin/java.exe").absolutePath
|
def jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
|
||||||
|
|
||||||
commandLine = [
|
commandLine renderDocCmd, "capture", "--opt-hook-children", "--wait-for-exit",
|
||||||
renderDocCmd,
|
|
||||||
"capture",
|
|
||||||
"--opt-hook-children",
|
|
||||||
"--wait-for-exit",
|
|
||||||
"--working-dir", "$projectDir/run",
|
"--working-dir", "$projectDir/run",
|
||||||
"--capture-file", "${captureDir}/minecraft_capture",
|
"--capture-file", "${captureDir}/minecraft_capture",
|
||||||
javaExecPath,
|
javaExecPath, jdwpArgs,
|
||||||
jdwpArgs,
|
"@${buildDir}/moddev/clientRunVmArgs.txt",
|
||||||
"@${buildDir}/moddev/clientRunVmArgs.txt", // JVM 参数
|
"@${buildDir}/moddev/clientRunProgramArgs.txt"
|
||||||
"@${buildDir}/moddev/clientRunProgramArgs.txt" // Program 参数
|
|
||||||
]
|
|
||||||
|
|
||||||
environment "MOD_CLASSES", "superleadrope%%${buildDir}/classes/java/main;superleadrope%%${buildDir}/resources/main"
|
environment "MOD_CLASSES", "superleadrope%%${buildDir}/classes/java/main;superleadrope%%${buildDir}/resources/main"
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
println "Using JVM: ${javaExecPath}"
|
println "Using JVM: ${javaExecPath}"
|
||||||
println "RenderDoc capture dir: ${captureDir}"
|
println "RenderDoc capture dir: ${captureDir}"
|
||||||
println "Environment MOD_CLASSES: ${environment['MOD_CLASSES']}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEA 支持
|
// ===================== IDEA 支持 =====================
|
||||||
idea {
|
idea {
|
||||||
module {
|
module {
|
||||||
downloadSources = true
|
downloadSources = true
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ mod_name=Super Lead Rope
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=GPLv3
|
mod_license=GPLv3
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=0.0.0.5
|
mod_version=0.0.0.6-pre4
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||||
# This should match the base package used for the mod sources.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
@ -68,3 +68,5 @@ mod_group_id=top.r3944realms.superleadrope
|
||||||
mod_authors=R3944Realms
|
mod_authors=R3944Realms
|
||||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||||
mod_description= A Lead Rope which is better than Bugjump.
|
mod_description= A Lead Rope which is better than Bugjump.
|
||||||
|
|
||||||
|
mod_credits=Leisure Time Dock
|
||||||
|
|
|
||||||
|
|
@ -117,13 +117,15 @@ public class SuperLeadRopeApi {
|
||||||
/**
|
/**
|
||||||
* Leashable in area list.
|
* Leashable in area list.
|
||||||
*
|
*
|
||||||
|
* @param <T> the type parameter
|
||||||
* @param holder the holder
|
* @param holder the holder
|
||||||
* @param clazz the clazz
|
* @param clazz the clazz
|
||||||
* @param box the box
|
* @param box the box
|
||||||
* @param filter the filter
|
* @param filter the filter
|
||||||
|
*
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public static @NotNull List<Entity> leashableInArea(Entity holder, Class<Entity> clazz, AABB box, Predicate<Entity> filter) {
|
public static <T extends Entity> @NotNull List<T> leashableInArea(Entity holder, Class<T> clazz, AABB box, Predicate<T> filter) {
|
||||||
return Services.WORK_SPACE.leashableInArea(holder.level(), clazz, i -> isLeashHolder(i, holder), box);
|
return Services.WORK_SPACE.leashableInArea(holder.level(), clazz, i -> isLeashHolder(i, holder), box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,27 @@ import java.util.UUID;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
||||||
private final Entity LeashedEntity;
|
private final Entity LeashedEntity;
|
||||||
|
/**
|
||||||
|
* The Has modified.
|
||||||
|
*/
|
||||||
|
protected boolean hasModified;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is modified boolean.
|
||||||
|
*
|
||||||
|
* @return the boolean
|
||||||
|
*/
|
||||||
|
public boolean isModified() {
|
||||||
|
return hasModified;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark modified.
|
||||||
|
*/
|
||||||
|
public void markModified() {
|
||||||
|
this.hasModified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Super lead rope event.
|
* Instantiates a new Super lead rope event.
|
||||||
|
|
@ -64,9 +85,9 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
||||||
public static class AddLeash extends SuperLeadRopeEvent {
|
public static class AddLeash extends SuperLeadRopeEvent {
|
||||||
private final Entity holderEntity;
|
private final Entity holderEntity;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Double maxLeashDistance;
|
private Double maxLeashDistance;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Double elasticDistanceScale;
|
private Double elasticDistanceScale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Add leash.
|
* Instantiates a new Add leash.
|
||||||
|
|
@ -93,6 +114,26 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
||||||
this.elasticDistanceScale = elasticDistanceScale;
|
this.elasticDistanceScale = elasticDistanceScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets elastic distance scale.
|
||||||
|
*
|
||||||
|
* @param elasticDistanceScale the elastic distance scale
|
||||||
|
*/
|
||||||
|
public void setElasticDistanceScale(@Nullable Double elasticDistanceScale) {
|
||||||
|
markModified();
|
||||||
|
this.elasticDistanceScale = elasticDistanceScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets max leash distance.
|
||||||
|
*
|
||||||
|
* @param maxLeashDistance the max leash distance
|
||||||
|
*/
|
||||||
|
public void setMaxLeashDistance(@Nullable Double maxLeashDistance) {
|
||||||
|
markModified();
|
||||||
|
this.maxLeashDistance = maxLeashDistance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets holder entity.
|
* Gets holder entity.
|
||||||
*
|
*
|
||||||
|
|
@ -236,7 +277,7 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Double oldValue;
|
private final Double oldValue;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Double newValue;
|
private Double newValue;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final Scope scope;
|
private final Scope scope;
|
||||||
|
|
||||||
|
|
@ -366,6 +407,15 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets new value.
|
||||||
|
*
|
||||||
|
* @param newValue the new value
|
||||||
|
*/
|
||||||
|
public void setNewValue(@Nullable Double newValue) {
|
||||||
|
markModified();
|
||||||
|
this.newValue = newValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -421,6 +471,7 @@ public abstract class SuperLeadRopeEvent extends Event implements IModBusEvent {
|
||||||
* @param combinedForce the combined force
|
* @param combinedForce the combined force
|
||||||
*/
|
*/
|
||||||
public void setCombinedForce(Vec3 combinedForce) {
|
public void setCombinedForce(Vec3 combinedForce) {
|
||||||
|
markModified();
|
||||||
this.combinedForce = combinedForce;
|
this.combinedForce = combinedForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,9 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<Entity> 持有的实体集合}
|
* @return {@link Set<Entity> 持有的实体集合}
|
||||||
*/
|
*/
|
||||||
default Set<Entity> getLeashEntities (Class<Entity> clazz, AABB box, Predicate<Entity> filter) {
|
@SuppressWarnings("unchecked")
|
||||||
return getLeash(clazz, box, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
default <T extends Entity> Set<T> getLeashEntities (Class<T> clazz, AABB box, Predicate<T> filter) {
|
||||||
|
return (Set<T>) getLeash(clazz, box, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取该实体持有的符合条件实体的拴绳数据能力
|
* 获取该实体持有的符合条件实体的拴绳数据能力
|
||||||
|
|
@ -98,7 +99,7 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||||
*/
|
*/
|
||||||
Set<ILeashData> getLeash(Class<Entity> clazz, AABB box, Predicate<Entity> filter);
|
<T extends Entity> Set<ILeashData> getLeash(Class<T> clazz, AABB box, Predicate<T> filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取该实体持有的符合条件实体实例
|
* 获取该实体持有的符合条件实体实例
|
||||||
|
|
@ -109,8 +110,9 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<Entity> 持有的实体实例}
|
* @return {@link Set<Entity> 持有的实体实例}
|
||||||
*/
|
*/
|
||||||
default Set<Entity> getLeashEntities (Class<Entity> clazz, double fetchDistance, Predicate<Entity> filter) {
|
@SuppressWarnings("unchecked")
|
||||||
return getLeash(clazz, fetchDistance, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
default <T extends Entity> Set<T> getLeashEntities (Class<T> clazz, double fetchDistance, Predicate<T> filter) {
|
||||||
|
return (Set<T>) getLeash(clazz, fetchDistance, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,7 +124,7 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||||
*/
|
*/
|
||||||
default Set<ILeashData> getLeash(Class<Entity> clazz, double fetchDistance, Predicate<Entity> filter) {
|
default <T extends Entity> Set<ILeashData> getLeash(Class<T> clazz, double fetchDistance, Predicate<T> filter) {
|
||||||
return getLeash(clazz, AABB.ofSize(getHolderEntity().position(), fetchDistance, fetchDistance, fetchDistance), filter);
|
return getLeash(clazz, AABB.ofSize(getHolderEntity().position(), fetchDistance, fetchDistance, fetchDistance), filter);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -133,8 +135,9 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<Entity> 持有的实体实例}
|
* @return {@link Set<Entity> 持有的实体实例}
|
||||||
*/
|
*/
|
||||||
default Set<Entity> getLeashEntities (Class<Entity> clazz, Predicate<Entity> filter) {
|
@SuppressWarnings("unchecked")
|
||||||
return getLeash(clazz, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
default <T extends Entity> Set<T> getLeashEntities (Class<T> clazz, Predicate<T> filter) {
|
||||||
|
return (Set<T>) getLeash(clazz, filter).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,7 +148,7 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||||
*/
|
*/
|
||||||
default Set<ILeashData> getLeash(Class<Entity> clazz, Predicate<Entity> filter) {
|
default <T extends Entity> Set<ILeashData> getLeash(Class<T> clazz, Predicate<T> filter) {
|
||||||
return getLeash(clazz, 1024D, filter);
|
return getLeash(clazz, 1024D, filter);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -155,8 +158,9 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<Entity> 持有的实体实例}
|
* @return {@link Set<Entity> 持有的实体实例}
|
||||||
*/
|
*/
|
||||||
default Set<Entity> getLeashEntities (Class<Entity> clazz) {
|
@SuppressWarnings("unchecked")
|
||||||
return getLeash(clazz).stream().map(ILeashData::self).collect(Collectors.toSet());
|
default <T extends Entity> Set<T> getLeashEntities (Class<T> clazz) {
|
||||||
|
return (Set<T>) getLeash(clazz).stream().map(ILeashData::self).collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -166,7 +170,7 @@ public interface ILeashHelper {
|
||||||
*
|
*
|
||||||
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
* @return {@link Set<ILeashData> 持有的实体的拴绳数据能力集合}
|
||||||
*/
|
*/
|
||||||
default Set<ILeashData> getLeash(Class<Entity> clazz) {
|
default <T extends Entity> Set<ILeashData> getLeash(Class<T> clazz) {
|
||||||
return getLeash(clazz, 1024D, null);
|
return getLeash(clazz, 1024D, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,11 @@ public interface IWorkSpaceHelper {
|
||||||
* @param clazz the clazz
|
* @param clazz the clazz
|
||||||
* @param filter the filter
|
* @param filter the filter
|
||||||
* @param box the box
|
* @param box the box
|
||||||
|
* @param <T> 实体类型
|
||||||
|
*
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
@NotNull List<Entity> leashableInArea(@NotNull Level pLevel, Class<Entity> clazz,Predicate<Entity> filter, AABB box);
|
@NotNull <T extends Entity> List<T> leashableInArea(@NotNull Level pLevel, Class<T> clazz,Predicate<T> filter, AABB box);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ public class LeashCommonConfig {
|
||||||
builder.push("LeashSettings");
|
builder.push("LeashSettings");
|
||||||
maxLeashLength = builder
|
maxLeashLength = builder
|
||||||
.comment("Maximum leash distance (in blocks) for any entity")
|
.comment("Maximum leash distance (in blocks) for any entity")
|
||||||
.defineInRange("maxLeashLength", 6.0, 6.0, 256.0);
|
.defineInRange("maxLeashLength", 6.0, 1.0, 256.0);
|
||||||
|
|
||||||
elasticDistanceScale = builder
|
elasticDistanceScale = builder
|
||||||
.comment("Default elastic distance for the Super Lead rope")
|
.comment("Default elastic distance for the Super Lead rope")
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ public class LeashConfigManager {
|
||||||
* The constant MAX_DISTANCE_CHECK.
|
* The constant MAX_DISTANCE_CHECK.
|
||||||
*/
|
*/
|
||||||
// ========== 最值检测 ==========
|
// ========== 最值检测 ==========
|
||||||
public static final Predicate<Double> MAX_DISTANCE_CHECK = distance -> distance == null || (distance >= 6.0 && distance <= 256.0);
|
public static final Predicate<Double> MAX_DISTANCE_CHECK = distance -> distance == null || (distance >= 1.0 && distance <= 256.0);
|
||||||
/**
|
/**
|
||||||
* The constant ELASTIC_DISTANCE_CHECK.
|
* The constant ELASTIC_DISTANCE_CHECK.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,9 @@ public class LeashDataImpl implements ILeashData {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(maxDistance) || !LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(elasticDistanceScale)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(maxDistance) || !LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(elasticDistanceScale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.AddLeash(holder, this.entity, maxDistance, elasticDistanceScale))) return false;
|
SuperLeadRopeEvent.AddLeash event = new SuperLeadRopeEvent.AddLeash(holder, this.entity, maxDistance, elasticDistanceScale);
|
||||||
|
//再次检查
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getMaxLeashDistance()) && LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getElasticDistanceScale()))) return false;
|
||||||
if (!canBeLeashed()) {
|
if (!canBeLeashed()) {
|
||||||
Optional<UUID> uuidOptional = occupyLeash();
|
Optional<UUID> uuidOptional = occupyLeash();
|
||||||
if (uuidOptional.isEmpty()) {
|
if (uuidOptional.isEmpty()) {
|
||||||
|
|
@ -305,8 +307,8 @@ public class LeashDataImpl implements ILeashData {
|
||||||
LeashInfo info = LeashInfo.create(
|
LeashInfo info = LeashInfo.create(
|
||||||
holder,
|
holder,
|
||||||
reserved,
|
reserved,
|
||||||
maxDistance,
|
event.getMaxLeashDistance(),
|
||||||
elasticDistanceScale,
|
event.getElasticDistanceScale(),
|
||||||
maxKeepLeashTicks,
|
maxKeepLeashTicks,
|
||||||
maxKeepLeashTicks
|
maxKeepLeashTicks
|
||||||
);
|
);
|
||||||
|
|
@ -397,13 +399,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setMaxDistance(UUID holderUUID, @Nullable Double newMaxDistance) {
|
public boolean setMaxDistance(UUID holderUUID, @Nullable Double newMaxDistance) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
|
|
@ -419,13 +422,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||||
public void setMaxDistanceInner(UUID holderUUID, @Nullable Double newMaxDistance) {
|
public void setMaxDistanceInner(UUID holderUUID, @Nullable Double newMaxDistance) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return;
|
||||||
updateLeashInfoInner(leashHolders, holderUUID, old -> new LeashInfo(
|
updateLeashInfoInner(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
|
|
@ -436,13 +440,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setMaxDistance(UUID holderUUID, @Nullable Double newMaxDistance, int newMaxKeepLeashTicks) {
|
public boolean setMaxDistance(UUID holderUUID, @Nullable Double newMaxDistance, int newMaxKeepLeashTicks) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
||||||
newMaxKeepLeashTicks
|
newMaxKeepLeashTicks
|
||||||
|
|
@ -453,13 +458,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setMaxDistance(UUID holderUUID, @Nullable Double newMaxDistance, int maxKeepTicks, String reserved) {
|
public boolean setMaxDistance(UUID holderUUID, @Nullable Double newMaxDistance, int maxKeepTicks, String reserved) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
reserved,
|
reserved,
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
Math.min(old.keepLeashTicks(), maxKeepTicks),
|
Math.min(old.keepLeashTicks(), maxKeepTicks),
|
||||||
maxKeepTicks
|
maxKeepTicks
|
||||||
|
|
@ -470,13 +476,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setMaxDistance(BlockPos knotPos, @Nullable Double newMaxDistance) {
|
public boolean setMaxDistance(BlockPos knotPos, @Nullable Double newMaxDistance) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
|
|
@ -492,13 +499,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||||
public void setMaxDistanceInner(BlockPos knotPos, @Nullable Double newMaxDistance) {
|
public void setMaxDistanceInner(BlockPos knotPos, @Nullable Double newMaxDistance) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return;
|
||||||
updateLeashInfoInner(leashKnots, knotPos, old -> new LeashInfo(
|
updateLeashInfoInner(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
|
|
@ -509,13 +517,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setMaxDistance(BlockPos knotPos, @Nullable Double newMaxDistance, int newMaxKeepLeashTicks) {
|
public boolean setMaxDistance(BlockPos knotPos, @Nullable Double newMaxDistance, int newMaxKeepLeashTicks) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
||||||
newMaxKeepLeashTicks
|
newMaxKeepLeashTicks
|
||||||
|
|
@ -526,13 +535,14 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setMaxDistance(BlockPos knotPos, @Nullable Double newMaxDistance, int maxKeepTicks, String reserved) {
|
public boolean setMaxDistance(BlockPos knotPos, @Nullable Double newMaxDistance, int maxKeepTicks, String reserved) {
|
||||||
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
if (!LeashConfigManager.MAX_DISTANCE_CHECK.test(newMaxDistance)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).maxDistance(), newMaxDistance, SuperLeadRopeEvent.ModifyValue.Type.MAX_DISTANCE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.MAX_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
reserved,
|
reserved,
|
||||||
newMaxDistance,
|
event.getNewValue(),
|
||||||
old.elasticDistanceScale(),
|
old.elasticDistanceScale(),
|
||||||
Math.min(old.keepLeashTicks(), maxKeepTicks),
|
Math.min(old.keepLeashTicks(), maxKeepTicks),
|
||||||
maxKeepTicks
|
maxKeepTicks
|
||||||
|
|
@ -551,14 +561,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setElasticDistanceScale(UUID holderUUID, @Nullable Double scale) {
|
public boolean setElasticDistanceScale(UUID holderUUID, @Nullable Double scale) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
));
|
));
|
||||||
|
|
@ -590,14 +601,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setElasticDistanceScale(BlockPos knotPos, @Nullable Double scale) {
|
public boolean setElasticDistanceScale(BlockPos knotPos, @Nullable Double scale) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
));
|
));
|
||||||
|
|
@ -612,14 +624,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||||
public void setElasticDistanceScaleInner(BlockPos knotPos, @Nullable Double scale) {
|
public void setElasticDistanceScaleInner(BlockPos knotPos, @Nullable Double scale) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return;
|
||||||
updateLeashInfoInner(leashKnots, knotPos, old -> new LeashInfo(
|
updateLeashInfoInner(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
));
|
));
|
||||||
|
|
@ -644,14 +657,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setElasticDistanceScale(UUID holderUUID, @Nullable Double scale, int newMaxKeepLeashTicks) {
|
public boolean setElasticDistanceScale(UUID holderUUID, @Nullable Double scale, int newMaxKeepLeashTicks) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
||||||
newMaxKeepLeashTicks
|
newMaxKeepLeashTicks
|
||||||
));
|
));
|
||||||
|
|
@ -661,14 +675,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setElasticDistanceScale(UUID holderUUID, @Nullable Double scale, int maxKeepTicks, String reserved) {
|
public boolean setElasticDistanceScale(UUID holderUUID, @Nullable Double scale, int maxKeepTicks, String reserved) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, holderUUID, leashHolders.get(holderUUID).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
return updateLeashInfo(leashHolders, holderUUID, old -> new LeashInfo(
|
||||||
old.holderUUIDOpt().get(),
|
old.holderUUIDOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
reserved,
|
reserved,
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
Math.min(old.keepLeashTicks(), maxKeepTicks),
|
Math.min(old.keepLeashTicks(), maxKeepTicks),
|
||||||
maxKeepTicks
|
maxKeepTicks
|
||||||
));
|
));
|
||||||
|
|
@ -678,14 +693,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setElasticDistanceScale(BlockPos knotPos, @Nullable Double scale, int newMaxKeepLeashTicks) {
|
public boolean setElasticDistanceScale(BlockPos knotPos, @Nullable Double scale, int newMaxKeepLeashTicks) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
old.reserved(),
|
old.reserved(),
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
old.keepLeashTicks(),
|
old.keepLeashTicks(),
|
||||||
old.maxKeepLeashTicks()
|
old.maxKeepLeashTicks()
|
||||||
));
|
));
|
||||||
|
|
@ -695,14 +711,15 @@ public class LeashDataImpl implements ILeashData {
|
||||||
@Override
|
@Override
|
||||||
public boolean setElasticDistanceScale(BlockPos knotPos, @Nullable Double scale, int newMaxKeepLeashTicks, String reserved) {
|
public boolean setElasticDistanceScale(BlockPos knotPos, @Nullable Double scale, int newMaxKeepLeashTicks, String reserved) {
|
||||||
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
if (!LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(scale)) return false;
|
||||||
if (MinecraftForge.EVENT_BUS.post(new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE))) return false;
|
SuperLeadRopeEvent.ModifyValue event = new SuperLeadRopeEvent.ModifyValue(this.entity, knotPos, leashKnots.get(knotPos).elasticDistanceScale(), scale, SuperLeadRopeEvent.ModifyValue.Type.ELASTIC_DISTANCE_SCALE);
|
||||||
|
if (MinecraftForge.EVENT_BUS.post(event) || event.isModified() && !(LeashConfigManager.ELASTIC_DISTANCE_CHECK.test(event.getNewValue()))) return false;
|
||||||
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
return updateLeashInfo(leashKnots, knotPos, old -> new LeashInfo(
|
||||||
old.blockPosOpt().get(),
|
old.blockPosOpt().get(),
|
||||||
old.holderIdOpt().get(),
|
old.holderIdOpt().get(),
|
||||||
old.marks(),
|
old.marks(),
|
||||||
reserved,
|
reserved,
|
||||||
old.maxDistance(),
|
old.maxDistance(),
|
||||||
scale,
|
event.getNewValue(),
|
||||||
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
Math.min(old.keepLeashTicks(), newMaxKeepLeashTicks),
|
||||||
newMaxKeepLeashTicks
|
newMaxKeepLeashTicks
|
||||||
));
|
));
|
||||||
|
|
@ -1390,7 +1407,7 @@ public class LeashDataImpl implements ILeashData {
|
||||||
);
|
);
|
||||||
} else throw new IllegalArgumentException("Unknown LeashInfo");
|
} else throw new IllegalArgumentException("Unknown LeashInfo");
|
||||||
}
|
}
|
||||||
private static Set<String> getMarks(CompoundTag infoTag) {
|
private static Set<String> getMarks(@NotNull CompoundTag infoTag) {
|
||||||
if (infoTag.contains("Marks")) {
|
if (infoTag.contains("Marks")) {
|
||||||
CompoundTag marks = infoTag.getCompound("Marks");
|
CompoundTag marks = infoTag.getCompound("Marks");
|
||||||
int size = marks.getInt("MarkSize");
|
int size = marks.getInt("MarkSize");
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class LeashHelper implements ILeashHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<ILeashData> getLeash(Class<Entity> clazz, AABB box, Predicate<Entity> filter) {
|
public <T extends Entity> Set<ILeashData> getLeash(Class<T> clazz, AABB box, Predicate<T> filter) {
|
||||||
return SuperLeadRopeApi.leashableInArea(getHolderEntity(), clazz, box, filter)
|
return SuperLeadRopeApi.leashableInArea(getHolderEntity(), clazz, box, filter)
|
||||||
.stream()
|
.stream()
|
||||||
.map(i -> i.getCapability(SLPCapability.LEASH_DATA_CAP).resolve())
|
.map(i -> i.getCapability(SLPCapability.LEASH_DATA_CAP).resolve())
|
||||||
|
|
@ -65,6 +65,7 @@ public class LeashHelper implements ILeashHelper {
|
||||||
@Override
|
@Override
|
||||||
public boolean leashEntity(UUID uuid) {
|
public boolean leashEntity(UUID uuid) {
|
||||||
Entity entity = CommonEventHandler.Game.getServerLevel().getEntity(uuid);
|
Entity entity = CommonEventHandler.Game.getServerLevel().getEntity(uuid);
|
||||||
|
|
||||||
if (entity != null && SuperLeadRopeApi.isLeashable(entity)) {
|
if (entity != null && SuperLeadRopeApi.isLeashable(entity)) {
|
||||||
return LeashDataInnerAPI.getLeashData(entity).map(i-> i.addLeash(entity)).orElse(false);
|
return LeashDataInnerAPI.getLeashData(entity).map(i-> i.addLeash(entity)).orElse(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ public class WorkSpaceHelper implements IWorkSpaceHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<Entity> leashableInArea(@NotNull Level pLevel, Class<Entity> clazz, @Nullable Predicate<Entity> filter, AABB box) {
|
public <T extends Entity> @NotNull List<T> leashableInArea(@NotNull Level pLevel, Class<T> clazz, @Nullable Predicate<T> filter, AABB box) {
|
||||||
return pLevel.getEntitiesOfClass(clazz, box, e -> LeashDataImpl.isLeashable(e) && Objects.requireNonNullElse(filter, entity -> true).test(e));
|
return pLevel.getEntitiesOfClass(clazz, box, e -> LeashDataImpl.isLeashable(e) && Objects.requireNonNullElse(filter, entity -> true).test(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@ displayName="${mod_name}" #mandatory
|
||||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||||
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
|
||||||
# A file name (in the root of the mod JAR) containing a logo for display
|
# A file name (in the root of the mod JAR) containing a logo for display
|
||||||
logoFile="superleadrope_logo.png" #optional
|
logoFile= "../../resources/superleadrope_logo.png" #optional
|
||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
credits="Leisuretimedock"
|
credits="${mod_credits}"
|
||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
authors="${mod_authors}" #optional
|
authors="${mod_authors}" #optional
|
||||||
# Display Test controls the display for your mod in the server connection screen
|
# Display Test controls the display for your mod in the server connection screen
|
||||||
Loading…
Reference in New Issue
Block a user