Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3dc05dc6d0 | ||
|
|
99f5a85404 | ||
|
|
b269b12ea2 | ||
|
|
5582f593aa | ||
|
|
d3fed02fda | ||
|
|
f70415c49c | ||
|
|
36521b1cba | ||
|
|
784cae8e9c | ||
|
|
e908e2f5e1 | ||
|
|
b1c67f3e6b | ||
|
|
21d9716bcc |
269
build.gradle
269
build.gradle
@@ -1,21 +1,17 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
|
||||
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
id 'net.neoforged.moddev' version '2.0.89'
|
||||
}
|
||||
tasks.named('wrapper', Wrapper).configure {
|
||||
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
|
||||
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
|
||||
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
|
||||
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
|
||||
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
|
||||
distributionType = Wrapper.DistributionType.BIN
|
||||
}
|
||||
|
||||
apply plugin: 'org.spongepowered.mixin'
|
||||
|
||||
group = mod_group_id
|
||||
version = mod_version
|
||||
@@ -24,106 +20,71 @@ base {
|
||||
archivesName = minecraft_version + "-" + mod_id
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
java.withSourcesJar()
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time and must be in the following format.
|
||||
// Channel: Version:
|
||||
// official MCVersion Official field/method names from Mojang mapping files
|
||||
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
|
||||
//
|
||||
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
|
||||
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
|
||||
//
|
||||
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
|
||||
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
|
||||
//
|
||||
// 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: mapping_channel, version: mapping_version
|
||||
neoForge {
|
||||
// Specify the version of NeoForge to use.
|
||||
version = project.neo_version
|
||||
|
||||
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
|
||||
// In most cases, it is not necessary to enable.
|
||||
// enableEclipsePrepareRuns = true
|
||||
// enableIdeaPrepareRuns = true
|
||||
|
||||
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
|
||||
// It is REQUIRED to be set to true for this template to function.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
copyIdeResources = true
|
||||
|
||||
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
|
||||
// The folder name can be set on a run configuration using the "folderName" property.
|
||||
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
|
||||
// generateRunFolders = true
|
||||
|
||||
// This property enables access transformers for use in development.
|
||||
// They will be applied to the Minecraft artifact.
|
||||
// The access transformer file can be anywhere in the project.
|
||||
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
|
||||
// This default location is a best practice to automatically put the file in the right place in the final jar.
|
||||
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
|
||||
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
// applies to all the run configs below
|
||||
configureEach {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be added/remove as needed separated by commas.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
|
||||
jvmArg "-XX:+AllowEnhancedClassRedefinition"
|
||||
}
|
||||
|
||||
client {
|
||||
client()
|
||||
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
server {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
args '--nogui'
|
||||
server()
|
||||
programArgument '--nogui'
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
// 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 {
|
||||
property 'forge.enabledGameTestNamespaces', mod_id
|
||||
type = "gameTestServer"
|
||||
systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
data {
|
||||
// example of overriding the workingDirectory set in configureEach above
|
||||
workingDirectory project.file('run-data')
|
||||
data()
|
||||
|
||||
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||
// gameDirectory = project.file('run-data')
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||
}
|
||||
|
||||
// applies to all the run configs above
|
||||
configureEach {
|
||||
// Recommended logging data for a userdev environment
|
||||
// The markers can be added/remove as needed separated by commas.
|
||||
// "SCAN": For mods scan.
|
||||
// "REGISTRIES": For firing of registry events.
|
||||
// "REGISTRYDUMP": For getting the contents of all registries.
|
||||
systemProperty 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
// You can set various levels here.
|
||||
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
|
||||
logLevel = org.slf4j.event.Level.DEBUG
|
||||
}
|
||||
}
|
||||
mods {
|
||||
// define mod <-> source bindings
|
||||
// these are used to tell the game which sources are for which mod
|
||||
// mostly optional in a single mod project
|
||||
// but multi mod projects should define one per mod
|
||||
"${mod_id}" {
|
||||
sourceSet(sourceSets.main)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mixin {
|
||||
add sourceSets.main, "${mod_id}.refmap.json"
|
||||
|
||||
config "${mod_id}.mixins.json"
|
||||
}
|
||||
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
@@ -133,94 +94,74 @@ repositories {
|
||||
|
||||
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver
|
||||
// flatDir {
|
||||
// dir 'libs'
|
||||
// }
|
||||
flatDir {
|
||||
dir 'libs'
|
||||
}
|
||||
maven {
|
||||
url "https://cursemaven.com"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use.
|
||||
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
|
||||
// The "userdev" classifier will be requested and setup by ForgeGradle.
|
||||
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
|
||||
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
compileOnly "curse.maven:touhou-little-maid-355044:6988538"
|
||||
runtimeOnly "curse.maven:touhou-little-maid-355044:6988538"
|
||||
// compileOnly "libs:touhoulittlemaid-${minecraft_version}-release:1.3.7"
|
||||
// runtimeOnly "libs:touhoulittlemaid-${minecraft_version}-release:1.3.7"
|
||||
|
||||
// Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings
|
||||
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
|
||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}")
|
||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}")
|
||||
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}")
|
||||
|
||||
// Example mod dependency using a mod jar from ./libs with a flat dir repository
|
||||
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
|
||||
// The group id is ignored when searching -- in this case, it is "blank"
|
||||
// implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_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
|
||||
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
|
||||
compileOnly fg.deobf("curse.maven:touhou-little-maid-355044:6596061")
|
||||
compileOnly fg.deobf("curse.maven:playerrevive-266890:6048921")
|
||||
compileOnly fg.deobf("curse.maven:creativecore-257814:6383884")
|
||||
compileOnly fg.deobf("curse.maven:natures-compass-252848:4712189")
|
||||
compileOnly fg.deobf("curse.maven:explorers-compass-491794:4712194")
|
||||
runtimeOnly fg.deobf("curse.maven:touhou-little-maid-355044:6596061")
|
||||
runtimeOnly fg.deobf("curse.maven:maid-storage-manager-1210244:6455832")
|
||||
runtimeOnly fg.deobf("curse.maven:playerrevive-266890:6048921")
|
||||
runtimeOnly fg.deobf("curse.maven:creativecore-257814:6383884")
|
||||
// runtimeOnly fg.deobf("curse.maven:natures-compass-252848:4712189")
|
||||
// runtimeOnly fg.deobf("curse.maven:explorers-compass-491794:4712194")
|
||||
|
||||
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1"))
|
||||
implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.4.1")) {
|
||||
jarJar.ranged(it, "[0.4.1,)")
|
||||
}
|
||||
compileOnly "curse.maven:playerrevive-266890:6383797"
|
||||
compileOnly "curse.maven:creativecore-257814:6690762"
|
||||
compileOnly "curse.maven:natures-compass-252848:5696042"
|
||||
compileOnly "curse.maven:explorers-compass-491794:5756947"
|
||||
// runtimeOnly "curse.maven:playerrevive-266890:6383797"
|
||||
runtimeOnly "curse.maven:creativecore-257814:6690762"
|
||||
// runtimeOnly "curse.maven:natures-compass-252848:5696042"
|
||||
// runtimeOnly "curse.maven:explorers-compass-491794:5756947"
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
|
||||
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
|
||||
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
|
||||
tasks.named('processResources', ProcessResources).configure {
|
||||
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
|
||||
var replaceProperties = [
|
||||
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version : forge_version, forge_version_range: forge_version_range,
|
||||
loader_version_range: loader_version_range,
|
||||
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
|
||||
mod_authors : mod_authors, mod_description: mod_description,
|
||||
minecraft_version : minecraft_version,
|
||||
minecraft_version_range: minecraft_version_range,
|
||||
neo_version : neo_version,
|
||||
neo_version_range : neo_version_range,
|
||||
loader_version_range : loader_version_range,
|
||||
mod_id : mod_id,
|
||||
mod_name : mod_name,
|
||||
mod_license : mod_license,
|
||||
mod_version : mod_version,
|
||||
mod_authors : mod_authors,
|
||||
mod_description : mod_description
|
||||
]
|
||||
|
||||
inputs.properties replaceProperties
|
||||
|
||||
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
|
||||
expand replaceProperties + [project: project]
|
||||
}
|
||||
expand replaceProperties
|
||||
from "src/main/templates"
|
||||
into "build/generated/sources/modMetadata"
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading at runtime.
|
||||
tasks.named('jar', Jar).configure {
|
||||
manifest {
|
||||
attributes([
|
||||
"Specification-Title" : mod_id,
|
||||
"Specification-Vendor" : mod_authors,
|
||||
"Specification-Version" : "1", // We are version 1 of ourselves
|
||||
"Implementation-Title" : project.name,
|
||||
"Implementation-Version" : project.jar.archiveVersion,
|
||||
"Implementation-Vendor" : mod_authors,
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
])
|
||||
}
|
||||
sourceSets.main.resources.srcDir generateModMetadata
|
||||
neoForge.ideSyncTask generateModMetadata
|
||||
|
||||
// This is the preferred method to reobfuscate your jar file
|
||||
finalizedBy 'reobfJar'
|
||||
publishing {
|
||||
publications {
|
||||
register('mavenJava', MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
url "file://${project.projectDir}/repo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
|
||||
idea {
|
||||
module {
|
||||
downloadSources = true
|
||||
downloadJavadoc = true
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
org.gradle.jvmargs=-Xmx3G
|
||||
org.gradle.daemon=false
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=1.20.1
|
||||
minecraft_version=1.21.1
|
||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
||||
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||
# as they do not follow standard versioning conventions.
|
||||
minecraft_version_range=[1.20.1,1.21)
|
||||
minecraft_version_range=[1.21,1.22)
|
||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||
forge_version=47.3.0
|
||||
neo_version=21.1.194
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[47,)
|
||||
neo_version_range=[21.1,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[47,)
|
||||
loader_version_range=[4,)
|
||||
# The mapping channel to use for mappings.
|
||||
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
|
||||
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
|
||||
@@ -29,7 +29,7 @@ loader_version_range=[47,)
|
||||
mapping_channel=official
|
||||
# The mapping version to query from the mapping channel.
|
||||
# This must match the format required by the mapping channel.
|
||||
mapping_version=1.20.1
|
||||
mapping_version=1.21.1
|
||||
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
|
||||
# Must match the String constant located in the main mod class annotated with @Mod.
|
||||
mod_id=maid_useful_task
|
||||
@@ -38,7 +38,7 @@ mod_name=maid useful task
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=MIT
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=1.3.5
|
||||
mod_version=1.3.7
|
||||
# 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.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,15 +1,13 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'MinecraftForge'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
maven { url = 'https://maven.neoforged.net/releases' }
|
||||
}
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
|
||||
}
|
||||
|
||||
rootProject.name = 'maid_useful_task'
|
||||
|
||||
@@ -1,37 +1,43 @@
|
||||
package studio.fantasyit.maid_useful_task;
|
||||
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.fml.event.config.ModConfigEvent;
|
||||
import net.neoforged.neoforge.common.ModConfigSpec;
|
||||
|
||||
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
|
||||
// Demonstrates how to use Forge's config APIs
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
@EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = EventBusSubscriber.Bus.MOD)
|
||||
public class Config {
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
private static final ModConfigSpec.Builder BUILDER = new ModConfigSpec.Builder();
|
||||
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_LOGGING = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue SELF_RESCUE = BUILDER
|
||||
.define("misc.self_rescue", true);
|
||||
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_LOGGING = BUILDER
|
||||
.define("functions.logging", true);
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_REVIVE = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_REVIVE = BUILDER
|
||||
.define("functions.revive", true);
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_LOCATE = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_LOCATE = BUILDER
|
||||
.define("functions.locate", true);
|
||||
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_REVIVE_AGGRO = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_REVIVE_AGGRO = BUILDER
|
||||
.define("revive.aggro", false);
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_REVIVE_TOTEM = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_REVIVE_TOTEM = BUILDER
|
||||
.define("revive.totem", true);
|
||||
|
||||
private static final ForgeConfigSpec.BooleanValue LOGGING_DISABLE_BLOCKUP = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue LOGGING_DISABLE_BLOCKUP = BUILDER
|
||||
.define("logging.disable_blockup", false);
|
||||
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_VEHICLE_CONTROL_FULL = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_VEHICLE_CONTROL_FULL = BUILDER
|
||||
.define("vehicle_control.full", true);
|
||||
private static final ForgeConfigSpec.BooleanValue ENABLE_VEHICLE_CONTROL_ROTATE = BUILDER
|
||||
private static final ModConfigSpec.BooleanValue ENABLE_VEHICLE_CONTROL_ROTATE = BUILDER
|
||||
.define("vehicle_control.rotate", true);
|
||||
|
||||
static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
static final ModConfigSpec SPEC = BUILDER.build();
|
||||
|
||||
public static boolean enableSelfRescue = false;
|
||||
|
||||
public static boolean enableLoggingTask = false;
|
||||
public static boolean enableReviveTask = false;
|
||||
@@ -47,6 +53,7 @@ public class Config {
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event) {
|
||||
enableSelfRescue = SELF_RESCUE.get();
|
||||
enableLoggingTask = ENABLE_LOGGING.get();
|
||||
enableReviveTask = ENABLE_REVIVE.get();
|
||||
enableLocateTask = ENABLE_LOCATE.get();
|
||||
|
||||
@@ -1,33 +1,9 @@
|
||||
package studio.fantasyit.maid_useful_task;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.slf4j.Logger;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.config.ModConfig;
|
||||
import studio.fantasyit.maid_useful_task.registry.GuiRegistry;
|
||||
import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleManager;
|
||||
@@ -39,10 +15,9 @@ public class MaidUsefulTask {
|
||||
// Define mod id in a common place for everything to reference
|
||||
public static final String MODID = "maid_useful_task";
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public MaidUsefulTask() {
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||
IEventBus modEventBus = ModLoadingContext.get().getActiveContainer().getEventBus();
|
||||
ModLoadingContext.get().getActiveContainer().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||
MemoryModuleRegistry.register(modEventBus);
|
||||
GuiRegistry.init(modEventBus);
|
||||
MaidVehicleManager.register();
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.github.tartaricacid.touhoulittlemaid.api.LittleMaidExtension;
|
||||
import com.github.tartaricacid.touhoulittlemaid.api.entity.ai.IExtraMaidBrain;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.ExtraMaidBrainManager;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.data.TaskDataRegister;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.item.control.BroomControlManager;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.task.TaskManager;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import studio.fantasyit.maid_useful_task.compat.PlayerRevive;
|
||||
@@ -15,6 +16,7 @@ import studio.fantasyit.maid_useful_task.registry.MemoryModuleRegistry;
|
||||
import studio.fantasyit.maid_useful_task.task.MaidLocateTask;
|
||||
import studio.fantasyit.maid_useful_task.task.MaidRevivePlayerTask;
|
||||
import studio.fantasyit.maid_useful_task.task.MaidTreeTask;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.broom.BroomController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -60,4 +62,9 @@ public class UsefulTaskExtension implements ILittleMaid {
|
||||
MaidReviveConfig.KEY = register.register(new MaidReviveConfig()),
|
||||
MaidReviveConfig.Data::getDefault);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBroomControl(BroomControlManager register) {
|
||||
register.register(BroomController::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package studio.fantasyit.maid_useful_task.api;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.bus.api.Event;
|
||||
import net.neoforged.bus.api.ICancellableEvent;
|
||||
|
||||
public class ItemLocateEvent extends Event implements ICancellableEvent {
|
||||
public final ItemStack itemStack;
|
||||
public final EntityMaid maid;
|
||||
public final BlockPos cache;
|
||||
public BlockPos target = null;
|
||||
|
||||
public ItemLocateEvent(ItemStack itemStack, EntityMaid maid, BlockPos cache) {
|
||||
this.itemStack = itemStack;
|
||||
this.maid = maid;
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public BlockPos getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(BlockPos target) {
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package studio.fantasyit.maid_useful_task.behavior;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.sensor.MaidNearestLivingEntitySensor;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class DestoryBlockBehavior extends Behavior<EntityMaid> {
|
||||
BlockTargetMemory blockTargetMemory = MemoryUtil.getDestroyTargetMemory(maid);
|
||||
if (blockTargetMemory != null) {
|
||||
blockPosSet = new ArrayList<>(blockTargetMemory.getBlockPosSet());
|
||||
blockPosSet.sort((o1, o2) -> (int) (o1.distSqr(maid.blockPosition()) - o2.distSqr(maid.blockPosition())));
|
||||
blockPosSet.sort((o1, o2) -> (int) (o1.distSqr(maid.blockPosition().above()) - o2.distSqr(maid.blockPosition().above())));
|
||||
}
|
||||
index = 0;
|
||||
task = (IMaidBlockDestroyTask) maid.getTask();
|
||||
@@ -65,6 +65,8 @@ public class DestoryBlockBehavior extends Behavior<EntityMaid> {
|
||||
|
||||
@Override
|
||||
protected boolean canStillUse(ServerLevel p_22545_, EntityMaid p_22546_, long p_22547_) {
|
||||
if (MemoryUtil.getCurrent(p_22546_) != CurrentWork.DESTROY && MemoryUtil.getCurrent(p_22546_) != CurrentWork.BLOCKUP_DESTROY)
|
||||
return false;
|
||||
return (blockPosSet != null && index < blockPosSet.size()) || targetPos != null;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ public class DestoryBlockMoveBehavior extends MaidCenterMoveToBlockTask {
|
||||
protected boolean shouldMoveTo(@NotNull ServerLevel serverLevel, @NotNull EntityMaid entityMaid, @NotNull BlockPos blockPos) {
|
||||
if (!task.shouldDestroyBlock(entityMaid, blockPos.immutable())) return false;
|
||||
targetPos = blockPos.immutable();
|
||||
BlockPos startPos = entityMaid.blockPosition();
|
||||
if (blockPos instanceof BlockPos.MutableBlockPos mb) {
|
||||
for (int dx = 0; dx < task.reachDistance(); dx = dx <= 0 ? 1 - dx : -dx) {
|
||||
for (int dy = 0; dy < task.reachDistance(); dy = dy <= 0 ? 1 - dy : -dy) {
|
||||
@@ -61,6 +62,9 @@ public class DestoryBlockMoveBehavior extends MaidCenterMoveToBlockTask {
|
||||
if (!PosUtils.isSafePos(serverLevel, pos)) continue;
|
||||
if (!Conditions.isGlobalValidTarget(entityMaid, pos, targetPos)) continue;
|
||||
if (pos.distSqr(targetPos) > task.reachDistance() * task.reachDistance()) continue;
|
||||
if (Math.abs(startPos.getY() - pos.getY()) >= task.reachDistance()) continue;
|
||||
if (Math.abs(startPos.getX() - pos.getX()) >= task.reachDistance()) continue;
|
||||
if (Math.abs(startPos.getZ() - pos.getZ()) >= task.reachDistance()) continue;
|
||||
if (pos.equals(entityMaid.blockPosition()) || (entityMaid.isWithinRestriction(pos) && pathfindingBFS.canPathReach(pos))) {
|
||||
blockPosSet = task.toDestroyFromStanding(entityMaid, targetPos, pos);
|
||||
if (blockPosSet != null) {
|
||||
@@ -81,9 +85,9 @@ public class DestoryBlockMoveBehavior extends MaidCenterMoveToBlockTask {
|
||||
protected @NotNull MaidPathFindingBFS getOrCreateArrivalMap(@NotNull ServerLevel worldIn, @NotNull EntityMaid maid) {
|
||||
if (this.pathfindingBFS == null)
|
||||
if (maid.hasRestriction())
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, 14, (int) maid.getRestrictRadius());
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, (int) maid.getRestrictRadius() + 1, task.reachDistance() + 2);
|
||||
else
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, 14);
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, task.reachDistance() + 1, task.reachDistance() + 2);
|
||||
return this.pathfindingBFS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package studio.fantasyit.maid_useful_task.behavior.common;
|
||||
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.ai.brain.task.MaidCheckRateTask;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.MaidPathFindingBFS;
|
||||
import com.github.tartaricacid.touhoulittlemaid.init.InitEntities;
|
||||
@@ -41,9 +40,11 @@ abstract public class MaidCenterMoveToBlockTask extends Behavior<EntityMaid> {
|
||||
this.verticalSearchRange = verticalSearchRange;
|
||||
this.searchRange = defaultSearchRange;
|
||||
}
|
||||
|
||||
public void setSearchRange(int searchRange) {
|
||||
this.searchRange = searchRange;
|
||||
}
|
||||
|
||||
protected final void searchForDestination(ServerLevel worldIn, EntityMaid maid) {
|
||||
MaidPathFindingBFS pathFinding = this.getOrCreateArrivalMap(worldIn, maid);
|
||||
BlockPos centrePos = this.getWorkSearchPos(maid);
|
||||
@@ -73,7 +74,7 @@ abstract public class MaidCenterMoveToBlockTask extends Behavior<EntityMaid> {
|
||||
}
|
||||
|
||||
protected MaidPathFindingBFS getOrCreateArrivalMap(ServerLevel worldIn, EntityMaid maid) {
|
||||
return new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid);
|
||||
return new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, maid.searchRadius(), 9);
|
||||
}
|
||||
|
||||
private BlockPos getWorkSearchPos(EntityMaid maid) {
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package studio.fantasyit.maid_useful_task.behavior.common;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.ai.behavior.Behavior;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import studio.fantasyit.maid_useful_task.Config;
|
||||
import studio.fantasyit.maid_useful_task.memory.CurrentWork;
|
||||
import studio.fantasyit.maid_useful_task.task.IMaidBlockDestroyTask;
|
||||
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MaidSelfRescueBehavior extends Behavior<EntityMaid> {
|
||||
public MaidSelfRescueBehavior() {
|
||||
super(Map.of(), 600);
|
||||
}
|
||||
|
||||
boolean started = false;
|
||||
|
||||
private static boolean isNotSafeAndCanTryToDestroy(ServerLevel level, EntityMaid maid, BlockPos pos, IMaidBlockDestroyTask task) {
|
||||
BlockState bs = level.getBlockState(pos);
|
||||
if (bs.isAir()) return false;
|
||||
VoxelShape collision = bs.getCollisionShape(level, pos);
|
||||
if (collision.isEmpty()) return false;
|
||||
return maid.getBoundingBox().intersects(collision.bounds().move(pos)) && bs.isSuffocating(level, pos) && task.mayDestroy(maid, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkExtraStartConditions(ServerLevel level, EntityMaid maid) {
|
||||
if (!Config.enableSelfRescue) return false;
|
||||
if (!(maid.getTask() instanceof IMaidBlockDestroyTask ibdt)) return false;
|
||||
if (isNotSafeAndCanTryToDestroy(level, maid, maid.blockPosition(), ibdt) || isNotSafeAndCanTryToDestroy(level, maid, maid.blockPosition().above(), ibdt))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canStillUse(ServerLevel p_22545_, EntityMaid p_22546_, long p_22547_) {
|
||||
return started && checkExtraStartConditions(p_22545_, p_22546_);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void start(ServerLevel p_22540_, EntityMaid maid, long p_22542_) {
|
||||
started = false;
|
||||
if (MemoryUtil.getCurrent(maid) == CurrentWork.DESTROY) {
|
||||
//如果执行中破坏任务,则立刻停止。用以清空相关状态
|
||||
MemoryUtil.setCurrent(maid, CurrentWork.IDLE);
|
||||
return;
|
||||
}
|
||||
//等待上一个任务结束
|
||||
if (MemoryUtil.getDestroyTargetMemory(maid) != null)
|
||||
return;
|
||||
if (!(maid.getTask() instanceof IMaidBlockDestroyTask task))
|
||||
return;
|
||||
|
||||
started = true;
|
||||
|
||||
List<BlockPos> list = new ArrayList<>();
|
||||
if (isNotSafeAndCanTryToDestroy(p_22540_, maid, maid.blockPosition(), task)) {
|
||||
list.add(maid.blockPosition());
|
||||
}
|
||||
if (isNotSafeAndCanTryToDestroy(p_22540_, maid, maid.blockPosition().above(), task)) {
|
||||
list.add(maid.blockPosition().above());
|
||||
}
|
||||
MemoryUtil.setDestroyTargetMemory(maid, list);
|
||||
MemoryUtil.setTarget(maid, maid.blockPosition(), 0.5f);
|
||||
MemoryUtil.setCurrent(maid, CurrentWork.DESTROY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void stop(ServerLevel p_22548_, EntityMaid p_22549_, long p_22550_) {
|
||||
MemoryUtil.clearTarget(p_22549_);
|
||||
MemoryUtil.setCurrent(p_22549_, CurrentWork.IDLE);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import net.neoforged.neoforge.items.wrapper.CombinedInvWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import studio.fantasyit.maid_useful_task.memory.CurrentWork;
|
||||
@@ -89,9 +89,9 @@ public class PlaceBlockMoveBehavior extends MaidCenterMoveToBlockTask {
|
||||
protected @NotNull MaidPathFindingBFS getOrCreateArrivalMap(@NotNull ServerLevel worldIn, @NotNull EntityMaid maid) {
|
||||
if (this.pathfindingBFS == null)
|
||||
if (maid.hasRestriction())
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, 14, (int) maid.getRestrictRadius());
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, (int) maid.getRestrictRadius(), 9);
|
||||
else
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, 14);
|
||||
this.pathfindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), worldIn, maid, 7, 9);
|
||||
return this.pathfindingBFS;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,19 +3,18 @@ package studio.fantasyit.maid_useful_task.client;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.event.InputEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.InputEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.network.MaidAllowHandleVehicle;
|
||||
import studio.fantasyit.maid_useful_task.network.Network;
|
||||
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
|
||||
|
||||
import static studio.fantasyit.maid_useful_task.client.KeyMapping.KEY_SWITCH_VEHICLE_CONTROL;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = EventBusSubscriber.Bus.GAME, value = Dist.CLIENT)
|
||||
public class KeyEvents {
|
||||
@SubscribeEvent
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -32,7 +31,7 @@ public class KeyEvents {
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
if (maid == null) return;
|
||||
Network.INSTANCE.sendToServer(new MaidAllowHandleVehicle(maid));
|
||||
PacketDistributor.sendToServer(new MaidAllowHandleVehicle(maid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package studio.fantasyit.maid_useful_task.client;
|
||||
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.common.util.Lazy;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.neoforged.neoforge.common.util.Lazy;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class KeyMapping {
|
||||
|
||||
public static final Lazy<net.minecraft.client.KeyMapping> KEY_SWITCH_VEHICLE_CONTROL = Lazy.of(() -> new net.minecraft.client.KeyMapping(
|
||||
|
||||
@@ -3,7 +3,7 @@ package studio.fantasyit.maid_useful_task.compat;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
public class CompatEntry {
|
||||
public static BlockPos getLocateTarget(EntityMaid maid, ItemStack itemStack) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.chaosthedude.naturescompass.NaturesCompass;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
public class NatureCompass {
|
||||
public static BlockPos getCompassTarget(EntityMaid maid, ItemStack itemStack) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package studio.fantasyit.maid_useful_task.compat;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
|
||||
import net.neoforged.fml.ModList;
|
||||
|
||||
public class PlayerRevive {
|
||||
public static boolean isEnable(){
|
||||
|
||||
@@ -69,7 +69,7 @@ public class MaidLoggingConfig implements TaskDataKey<MaidLoggingConfig.Data> {
|
||||
}
|
||||
|
||||
public static TaskDataKey<Data> KEY = null;
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation(MaidUsefulTask.MODID, "logging");
|
||||
public static final ResourceLocation LOCATION = ResourceLocation.fromNamespaceAndPath(MaidUsefulTask.MODID, "logging");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getKey() {
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MaidReviveConfig implements TaskDataKey<MaidReviveConfig.Data> {
|
||||
}
|
||||
|
||||
public static TaskDataKey<Data> KEY = null;
|
||||
public static final ResourceLocation LOCATION = new ResourceLocation(MaidUsefulTask.MODID, "revive");
|
||||
public static final ResourceLocation LOCATION = ResourceLocation.fromNamespaceAndPath(MaidUsefulTask.MODID, "revive");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getKey() {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package studio.fantasyit.maid_useful_task.event;
|
||||
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.task.IMaidVehicleControlTask;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleManager;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
|
||||
@EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = EventBusSubscriber.Bus.GAME)
|
||||
public class MaidTickEvent {
|
||||
@SubscribeEvent
|
||||
public static void onTick(com.github.tartaricacid.touhoulittlemaid.api.event.MaidTickEvent event) {
|
||||
@@ -15,7 +15,7 @@ public class MaidTickEvent {
|
||||
if (event.getMaid().getTask() instanceof IMaidVehicleControlTask imvc && event.getMaid().getVehicle() != null) {
|
||||
imvc.tick(sl, event.getMaid());
|
||||
MaidVehicleManager.syncVehicleParameter(event.getMaid());
|
||||
}else if(event.getMaid().getVehicle() != null){
|
||||
} else if (event.getMaid().getVehicle() != null) {
|
||||
MaidVehicleManager.stopControlling(event.getMaid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
package studio.fantasyit.maid_useful_task.mixin;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.item.AbstractEntityFromItem;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityBroom;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.IVirtualControl;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
|
||||
@Mixin(EntityBroom.class)
|
||||
abstract public class VehicleBroomMixin extends AbstractEntityFromItem implements IVirtualControl {
|
||||
public VehicleBroomMixin(EntityType<? extends LivingEntity> type, Level worldIn) {
|
||||
super(type, worldIn);
|
||||
}
|
||||
|
||||
@Unique
|
||||
public MaidVehicleControlType maid_useful_tasks$vc_type = MaidVehicleControlType.NONE;
|
||||
@Unique
|
||||
public float maid_useful_tasks$vc_xRot;
|
||||
@Unique
|
||||
public float maid_useful_tasks$vc_yRot;
|
||||
@Unique
|
||||
public float maid_useful_tasks$vc_speed;
|
||||
|
||||
@Override
|
||||
public void maid_useful_tasks$setControlParam(float xRot, float yRot, float speed, MaidVehicleControlType type) {
|
||||
this.maid_useful_tasks$vc_xRot = xRot;
|
||||
this.maid_useful_tasks$vc_yRot = yRot;
|
||||
this.maid_useful_tasks$vc_speed = speed;
|
||||
this.maid_useful_tasks$vc_type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag maid_useful_tasks$getControlParam() {
|
||||
CompoundTag result = new CompoundTag();
|
||||
result.putFloat("xRot", maid_useful_tasks$vc_xRot);
|
||||
result.putFloat("yRot", maid_useful_tasks$vc_yRot);
|
||||
result.putFloat("speed", maid_useful_tasks$vc_speed);
|
||||
result.putString("type", maid_useful_tasks$vc_type.name());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maid_useful_tasks$setControlParam(CompoundTag target) {
|
||||
if (target.contains("type")) {
|
||||
this.maid_useful_tasks$vc_type = MaidVehicleControlType.valueOf(target.getString("type"));
|
||||
}
|
||||
if (target.contains("xRot")) {
|
||||
this.maid_useful_tasks$vc_xRot = target.getFloat("xRot");
|
||||
}
|
||||
if (target.contains("yRot")) {
|
||||
this.maid_useful_tasks$vc_yRot = target.getFloat("yRot");
|
||||
}
|
||||
if (target.contains("speed")) {
|
||||
this.maid_useful_tasks$vc_speed = target.getFloat("speed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maid_useful_tasks$stopControl() {
|
||||
this.maid_useful_tasks$vc_type = MaidVehicleControlType.NONE;
|
||||
}
|
||||
|
||||
@Inject(method = "tickRidden", at = @At(value = "TAIL"))
|
||||
public void maid_useful_tasks$tickRidden(CallbackInfo ci) {
|
||||
if (maid_useful_tasks$vc_type == MaidVehicleControlType.NONE) {
|
||||
return;
|
||||
}
|
||||
this.setRot(maid_useful_tasks$vc_yRot, maid_useful_tasks$vc_xRot);
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "travel", at = @At(value = "STORE"), name = "strafe")
|
||||
float maid_useful_tasks$travel_s(float strafe) {
|
||||
if (maid_useful_tasks$vc_type != MaidVehicleControlType.FULL) {
|
||||
return strafe;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "travel", at = @At(value = "STORE"), name = "vertical")
|
||||
float maid_useful_tasks$travel_v(float vertical) {
|
||||
if (maid_useful_tasks$vc_type != MaidVehicleControlType.FULL) {
|
||||
return vertical;
|
||||
}
|
||||
return -(maid_useful_tasks$vc_xRot - 10.0F) / 22.5F;
|
||||
}
|
||||
|
||||
@ModifyVariable(method = "travel", at = @At(value = "STORE"), name = "forward")
|
||||
float maid_useful_tasks$travel_f(float forward) {
|
||||
if (maid_useful_tasks$vc_type != MaidVehicleControlType.FULL) {
|
||||
return forward;
|
||||
}
|
||||
return maid_useful_tasks$vc_speed;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,58 @@
|
||||
package studio.fantasyit.maid_useful_task.network;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import studio.fantasyit.maid_useful_task.Config;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
public class MaidAllowHandleVehicle implements CustomPacketPayload {
|
||||
public static final CustomPacketPayload.Type<MaidAllowHandleVehicle> TYPE = new CustomPacketPayload.Type<>(
|
||||
ResourceLocation.fromNamespaceAndPath(
|
||||
MaidUsefulTask.MODID, "allow_handle_vehicle"
|
||||
)
|
||||
);
|
||||
|
||||
@Override
|
||||
public CustomPacketPayload.Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public class MaidAllowHandleVehicle {
|
||||
final int maidId;
|
||||
|
||||
public MaidAllowHandleVehicle(EntityMaid maid) {
|
||||
this.maidId = maid.getId();
|
||||
}
|
||||
|
||||
public MaidAllowHandleVehicle(FriendlyByteBuf buffer) {
|
||||
maidId = buffer.readInt();
|
||||
public MaidAllowHandleVehicle(int maidId) {
|
||||
this.maidId = maidId;
|
||||
}
|
||||
|
||||
public void toBytes(FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(maidId);
|
||||
}
|
||||
|
||||
public static void handle(MaidAllowHandleVehicle msg, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
ServerPlayer sender = context.getSender();
|
||||
public static Codec<MaidAllowHandleVehicle> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group(
|
||||
Codec.INT.fieldOf("maidId").forGetter(packet -> packet.maidId)
|
||||
).apply(instance, MaidAllowHandleVehicle::new)
|
||||
);
|
||||
public static StreamCodec<ByteBuf, MaidAllowHandleVehicle> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT,
|
||||
t -> t.maidId,
|
||||
MaidAllowHandleVehicle::new
|
||||
);
|
||||
|
||||
public static void handle(MaidAllowHandleVehicle msg, IPayloadContext context) {
|
||||
ServerPlayer sender = (ServerPlayer) context.player();
|
||||
Entity entity = sender.level().getEntity(msg.maidId);
|
||||
if (entity instanceof EntityMaid maid) {
|
||||
MaidVehicleControlType[] values = MaidVehicleControlType.values();
|
||||
|
||||
@@ -1,21 +1,36 @@
|
||||
package studio.fantasyit.maid_useful_task.network;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.data.IConfigSetter;
|
||||
import studio.fantasyit.maid_useful_task.data.MaidConfigKeys;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MaidConfigurePacket {
|
||||
public class MaidConfigurePacket implements CustomPacketPayload {
|
||||
final public int maidId;
|
||||
final public String name;
|
||||
final public String value;
|
||||
final public ResourceLocation key;
|
||||
public static final CustomPacketPayload.Type<MaidConfigurePacket> TYPE = new CustomPacketPayload.Type<>(
|
||||
ResourceLocation.fromNamespaceAndPath(
|
||||
MaidUsefulTask.MODID, "maid_config"
|
||||
)
|
||||
);
|
||||
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public MaidConfigurePacket(int maidId, ResourceLocation key, String name, String value) {
|
||||
this.maidId = maidId;
|
||||
@@ -24,33 +39,37 @@ public class MaidConfigurePacket {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public MaidConfigurePacket(FriendlyByteBuf buffer) {
|
||||
this.maidId = buffer.readInt();
|
||||
this.key = ResourceLocation.tryParse(buffer.readUtf());
|
||||
this.name = buffer.readUtf();
|
||||
this.value = buffer.readUtf();
|
||||
public static Codec<MaidConfigurePacket> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group(
|
||||
Codec.INT.fieldOf("maidId").forGetter(packet -> packet.maidId),
|
||||
ResourceLocation.CODEC.fieldOf("key").forGetter(packet -> packet.key),
|
||||
Codec.STRING.fieldOf("name").forGetter(packet -> packet.name),
|
||||
Codec.STRING.fieldOf("value").forGetter(packet -> packet.value)
|
||||
).apply(instance, MaidConfigurePacket::new)
|
||||
);
|
||||
public static StreamCodec<ByteBuf, MaidConfigurePacket> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT,
|
||||
t -> t.maidId,
|
||||
ResourceLocation.STREAM_CODEC,
|
||||
t -> t.key,
|
||||
ByteBufCodecs.STRING_UTF8,
|
||||
t -> t.name,
|
||||
ByteBufCodecs.STRING_UTF8,
|
||||
t -> t.value,
|
||||
MaidConfigurePacket::new
|
||||
);
|
||||
|
||||
public static void send(EntityMaid maid, ResourceLocation key, String name, String value) {
|
||||
PacketDistributor.sendToServer(new MaidConfigurePacket(maid.getId(), key, name, value));
|
||||
}
|
||||
|
||||
public void toBytes(FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(maidId);
|
||||
buffer.writeUtf(key.toString());
|
||||
buffer.writeUtf(name);
|
||||
buffer.writeUtf(value);
|
||||
}
|
||||
|
||||
public static void handle(MaidConfigurePacket msg, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
@Nullable ServerPlayer sender = context.getSender();
|
||||
if (sender != null) {
|
||||
if (sender.level().getEntity(msg.maidId) instanceof EntityMaid entityMaid) {
|
||||
if (MaidConfigKeys.getValue(entityMaid, msg.key) instanceof IConfigSetter ics) {
|
||||
ics.setConfigValue(msg.name, msg.value);
|
||||
}
|
||||
public static void handle(MaidConfigurePacket msg, IPayloadContext context) {
|
||||
@Nullable ServerPlayer sender = (ServerPlayer) context.player();
|
||||
if (sender.level().getEntity(msg.maidId) instanceof EntityMaid entityMaid) {
|
||||
if (MaidConfigKeys.getValue(entityMaid, msg.key) instanceof IConfigSetter ics) {
|
||||
ics.setConfigValue(msg.name, msg.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void send(EntityMaid maid, ResourceLocation key, String name, String value) {
|
||||
Network.INSTANCE.sendToServer(new MaidConfigurePacket(maid.getId(), key, name, value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
package studio.fantasyit.maid_useful_task.network;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.ByteBufCodecs;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
import net.neoforged.neoforge.network.handling.IPayloadContext;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleManager;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
public class MaidSyncVehiclePacket implements CustomPacketPayload {
|
||||
|
||||
public static final CustomPacketPayload.Type<MaidSyncVehiclePacket> TYPE = new CustomPacketPayload.Type<>(
|
||||
ResourceLocation.fromNamespaceAndPath(
|
||||
MaidUsefulTask.MODID, "sync_vehicle"
|
||||
)
|
||||
);
|
||||
|
||||
@Override
|
||||
public Type<? extends CustomPacketPayload> type() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public class MaidSyncVehiclePacket {
|
||||
final CompoundTag tag;
|
||||
final int maidId;
|
||||
|
||||
@@ -22,19 +36,23 @@ public class MaidSyncVehiclePacket {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public MaidSyncVehiclePacket(FriendlyByteBuf buffer) {
|
||||
this.maidId = buffer.readInt();
|
||||
this.tag = buffer.readNbt();
|
||||
}
|
||||
public static Codec<MaidSyncVehiclePacket> CODEC = RecordCodecBuilder.create(instance ->
|
||||
instance.group(
|
||||
Codec.INT.fieldOf("maidId").forGetter(packet -> packet.maidId),
|
||||
CompoundTag.CODEC.fieldOf("tag").forGetter(packet -> packet.tag)
|
||||
).apply(instance, MaidSyncVehiclePacket::new)
|
||||
);
|
||||
public static StreamCodec<RegistryFriendlyByteBuf, MaidSyncVehiclePacket> STREAM_CODEC = StreamCodec.composite(
|
||||
ByteBufCodecs.INT,
|
||||
t -> t.maidId,
|
||||
ByteBufCodecs.COMPOUND_TAG,
|
||||
t -> t.tag,
|
||||
MaidSyncVehiclePacket::new
|
||||
);
|
||||
|
||||
public void toBytes(FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(maidId);
|
||||
buffer.writeNbt(tag);
|
||||
}
|
||||
|
||||
public static void handle(MaidSyncVehiclePacket msg, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
Entity entity = Network.getLocalPlayer().level().getEntity(msg.maidId);
|
||||
public static void handle(MaidSyncVehiclePacket msg, IPayloadContext context) {
|
||||
Entity entity = context.player().level().getEntity(msg.maidId);
|
||||
if (entity instanceof EntityMaid maid) {
|
||||
MaidVehicleManager.getControllableVehicle(maid).ifPresent(vehicle -> {
|
||||
vehicle.syncVehicleParameter(maid, msg.tag);
|
||||
|
||||
@@ -1,76 +1,36 @@
|
||||
package studio.fantasyit.maid_useful_task.network;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
|
||||
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
|
||||
public class Network {
|
||||
private static final String PROTOCOL_VERSION = "1";
|
||||
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
|
||||
new ResourceLocation(MaidUsefulTask.MODID, "mut_packets"),
|
||||
() -> PROTOCOL_VERSION,
|
||||
(v) -> true,
|
||||
(v) -> true
|
||||
);
|
||||
|
||||
private static void registerMessage() {
|
||||
Network.INSTANCE.registerMessage(0,
|
||||
MaidConfigurePacket.class,
|
||||
MaidConfigurePacket::toBytes,
|
||||
MaidConfigurePacket::new,
|
||||
(msg, context) -> {
|
||||
context.get().enqueueWork(() -> MaidConfigurePacket.handle(msg, context));
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
private static void registerMessage(PayloadRegistrar registrar) {
|
||||
registrar.playToServer(
|
||||
MaidConfigurePacket.TYPE,
|
||||
MaidConfigurePacket.STREAM_CODEC,
|
||||
MaidConfigurePacket::handle
|
||||
);
|
||||
Network.INSTANCE.registerMessage(1,
|
||||
MaidAllowHandleVehicle.class,
|
||||
MaidAllowHandleVehicle::toBytes,
|
||||
MaidAllowHandleVehicle::new,
|
||||
(msg, context) -> {
|
||||
context.get().enqueueWork(() -> MaidAllowHandleVehicle.handle(msg, context));
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
registrar.playToServer(
|
||||
MaidAllowHandleVehicle.TYPE,
|
||||
MaidAllowHandleVehicle.STREAM_CODEC,
|
||||
MaidAllowHandleVehicle::handle
|
||||
);
|
||||
Network.INSTANCE.registerMessage(2,
|
||||
MaidSyncVehiclePacket.class,
|
||||
MaidSyncVehiclePacket::toBytes,
|
||||
MaidSyncVehiclePacket::new,
|
||||
(msg, context) -> {
|
||||
context.get().enqueueWork(() -> MaidSyncVehiclePacket.handle(msg, context));
|
||||
context.get().setPacketHandled(true);
|
||||
}
|
||||
registrar.playToClient(
|
||||
MaidSyncVehiclePacket.TYPE,
|
||||
MaidSyncVehiclePacket.STREAM_CODEC,
|
||||
MaidSyncVehiclePacket::handle
|
||||
);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static Player getLocalPlayer() {
|
||||
return Minecraft.getInstance().player;
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.DEDICATED_SERVER)
|
||||
public static class Server {
|
||||
@SubscribeEvent
|
||||
public static void FMLClientSetupEvent(FMLDedicatedServerSetupEvent event) {
|
||||
registerMessage();
|
||||
@EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = EventBusSubscriber.Bus.MOD)
|
||||
public static class Event {
|
||||
@net.neoforged.bus.api.SubscribeEvent
|
||||
public static void regis(RegisterPayloadHandlersEvent event) {
|
||||
registerMessage(event.registrar(PROTOCOL_VERSION));
|
||||
}
|
||||
}
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public static class Client {
|
||||
@SubscribeEvent
|
||||
public static void FMLClientSetupEvent(FMLClientSetupEvent event) {
|
||||
registerMessage();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
package studio.fantasyit.maid_useful_task.registry;
|
||||
|
||||
import net.minecraft.client.gui.screens.MenuScreens;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.common.EventBusSubscriber;
|
||||
import net.neoforged.neoforge.client.event.RegisterMenuScreensEvent;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.menu.MaidLoggingConfigGui;
|
||||
import studio.fantasyit.maid_useful_task.menu.MaidReviveConfigGui;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(modid = MaidUsefulTask.MODID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public class ClientGuiRegistry {
|
||||
@SubscribeEvent
|
||||
public static void init(FMLClientSetupEvent event) {
|
||||
event.enqueueWork(() -> {
|
||||
MenuScreens.register(GuiRegistry.MAID_LOGGING_CONFIG_GUI.get(), MaidLoggingConfigGui::new);
|
||||
});
|
||||
event.enqueueWork(() -> {
|
||||
MenuScreens.register(GuiRegistry.MAID_REVIVE_CONFIG_GUI.get(), MaidReviveConfigGui::new);
|
||||
});
|
||||
public static void init(RegisterMenuScreensEvent event) {
|
||||
event.register(GuiRegistry.MAID_LOGGING_CONFIG_GUI.get(), MaidLoggingConfigGui::new);
|
||||
event.register(GuiRegistry.MAID_REVIVE_CONFIG_GUI.get(), MaidReviveConfigGui::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package studio.fantasyit.maid_useful_task.registry;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.menu.MaidLoggingConfigGui;
|
||||
import studio.fantasyit.maid_useful_task.menu.MaidReviveConfigGui;
|
||||
|
||||
public class GuiRegistry {
|
||||
public static final DeferredRegister<MenuType<?>> MENU_TYPES = DeferredRegister.create(ForgeRegistries.MENU_TYPES, MaidUsefulTask.MODID);
|
||||
public static final RegistryObject<MenuType<MaidLoggingConfigGui.Container>> MAID_LOGGING_CONFIG_GUI = MENU_TYPES.register("maid_logging_config_gui",
|
||||
() -> IForgeMenuType.create((windowId, inv, data) -> new MaidLoggingConfigGui.Container(windowId, inv, data.readInt())));
|
||||
public static final RegistryObject<MenuType<MaidReviveConfigGui.Container>> MAID_REVIVE_CONFIG_GUI = MENU_TYPES.register("maid_revive_config_gui",
|
||||
() -> IForgeMenuType.create((windowId, inv, data) -> new MaidReviveConfigGui.Container(windowId, inv, data.readInt())));
|
||||
public static final DeferredRegister<MenuType<?>> MENU_TYPES = DeferredRegister.create(Registries.MENU, MaidUsefulTask.MODID);
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<MaidLoggingConfigGui.Container>> MAID_LOGGING_CONFIG_GUI = MENU_TYPES.register("maid_logging_config_gui",
|
||||
() -> IMenuTypeExtension.create((windowId, inv, data) -> new MaidLoggingConfigGui.Container(windowId, inv, data.readInt())));
|
||||
public static final DeferredHolder<MenuType<?>, MenuType<MaidReviveConfigGui.Container>> MAID_REVIVE_CONFIG_GUI = MENU_TYPES.register("maid_revive_config_gui",
|
||||
() -> IMenuTypeExtension.create((windowId, inv, data) -> new MaidReviveConfigGui.Container(windowId, inv, data.readInt())));
|
||||
|
||||
public static void init(IEventBus modEventBus) {
|
||||
MENU_TYPES.register(modEventBus);
|
||||
|
||||
@@ -4,12 +4,14 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.memory.*;
|
||||
import studio.fantasyit.maid_useful_task.util.WrappedMaidFakePlayer;
|
||||
import studio.fantasyit.maid_useful_task.memory.BlockTargetMemory;
|
||||
import studio.fantasyit.maid_useful_task.memory.BlockUpContext;
|
||||
import studio.fantasyit.maid_useful_task.memory.BlockValidationMemory;
|
||||
import studio.fantasyit.maid_useful_task.memory.CurrentWork;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -17,19 +19,20 @@ import java.util.Optional;
|
||||
public class MemoryModuleRegistry {
|
||||
public static final DeferredRegister<MemoryModuleType<?>> REGISTER
|
||||
= DeferredRegister.create(Registries.MEMORY_MODULE_TYPE, MaidUsefulTask.MODID);
|
||||
public static final RegistryObject<MemoryModuleType<BlockTargetMemory>> DESTROY_TARGET
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<BlockTargetMemory>> DESTROY_TARGET
|
||||
= REGISTER.register("block_targets", () -> new MemoryModuleType<>(Optional.of(BlockTargetMemory.CODEC)));
|
||||
public static final RegistryObject<MemoryModuleType<BlockPos>> PLACE_TARGET
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<BlockPos>> PLACE_TARGET
|
||||
= REGISTER.register("place_target", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final RegistryObject<MemoryModuleType<BlockUpContext>> BLOCK_UP_TARGET
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<BlockUpContext>> BLOCK_UP_TARGET
|
||||
= REGISTER.register("block_up", () -> new MemoryModuleType<>(Optional.of(BlockUpContext.CODEC)));
|
||||
public static final RegistryObject<MemoryModuleType<BlockValidationMemory>> BLOCK_VALIDATION
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<BlockValidationMemory>> BLOCK_VALIDATION
|
||||
= REGISTER.register("block_validation", () -> new MemoryModuleType<>(Optional.of(BlockValidationMemory.CODEC)));
|
||||
public static final RegistryObject<MemoryModuleType<BlockPos>> COMMON_BLOCK_CACHE
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<BlockPos>> COMMON_BLOCK_CACHE
|
||||
= REGISTER.register("common_block_cache", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final RegistryObject<MemoryModuleType<ItemStack>> LOCATE_ITEM = REGISTER.register("locate_item", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final RegistryObject<MemoryModuleType<CurrentWork>> CURRENT_WORK = REGISTER.register("current_work", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final RegistryObject<MemoryModuleType<MaidVehicleControlType>> IS_ALLOW_HANDLE_VEHICLE = REGISTER.register("is_allow_handle_vehicle", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<ItemStack>> LOCATE_ITEM = REGISTER.register("locate_item", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<CurrentWork>> CURRENT_WORK = REGISTER.register("current_work", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
public static final DeferredHolder<MemoryModuleType<?>, MemoryModuleType<MaidVehicleControlType>> IS_ALLOW_HANDLE_VEHICLE = REGISTER.register("is_allow_handle_vehicle", () -> new MemoryModuleType<>(Optional.empty()));
|
||||
|
||||
public static void register(IEventBus eventBus) {
|
||||
REGISTER.register(eventBus);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import net.neoforged.neoforge.items.wrapper.CombinedInvWrapper;
|
||||
import oshi.util.tuples.Pair;
|
||||
import studio.fantasyit.maid_useful_task.util.MaidUtils;
|
||||
import studio.fantasyit.maid_useful_task.util.PosUtils;
|
||||
@@ -55,7 +55,7 @@ public interface IMaidBlockUpTask {
|
||||
}
|
||||
};
|
||||
CenterOffsetBlockPosSet notAvailable = new CenterOffsetBlockPosSet(scanRange, scanRange + maxHeight / 2 + 1, scanRange, center.getX(), center.getY() + maxHeight / 2, center.getZ());
|
||||
MaidPathFindingBFS pathFindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), level, maid, 7, scanRange);
|
||||
MaidPathFindingBFS pathFindingBFS = new MaidPathFindingBFS(maid.getNavigation().getNodeEvaluator(), level, maid, 7, scanRange+2);
|
||||
for (int dx = 0; dx < scanRange; dx = dx <= 0 ? 1 - dx : -dx) {
|
||||
for (int dz = 0; dz < scanRange; dz = dz <= 0 ? 1 - dz : -dz) {
|
||||
//计算地面的位置
|
||||
|
||||
@@ -5,8 +5,7 @@ import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -19,21 +18,25 @@ import net.minecraft.world.item.CompassItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.MapItem;
|
||||
import net.minecraft.world.item.component.LodestoneTracker;
|
||||
import net.minecraft.world.item.component.MapDecorations;
|
||||
import net.minecraft.world.level.saveddata.maps.MapDecorationTypes;
|
||||
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import studio.fantasyit.maid_useful_task.Config;
|
||||
import studio.fantasyit.maid_useful_task.MaidUsefulTask;
|
||||
import studio.fantasyit.maid_useful_task.api.ItemLocateEvent;
|
||||
import studio.fantasyit.maid_useful_task.behavior.common.FindTargetMoveBehavior;
|
||||
import studio.fantasyit.maid_useful_task.behavior.common.FindTargetWaitBehavior;
|
||||
import studio.fantasyit.maid_useful_task.compat.CompatEntry;
|
||||
import studio.fantasyit.maid_useful_task.compat.ExplorerCompass;
|
||||
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MaidLocateTask implements IMaidTask, IMaidFindTargetTask {
|
||||
public static final ResourceLocation UID = new ResourceLocation(MaidUsefulTask.MODID, "locate");
|
||||
public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(MaidUsefulTask.MODID, "locate");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
@@ -74,11 +77,15 @@ public class MaidLocateTask implements IMaidTask, IMaidFindTargetTask {
|
||||
BlockPos target = null;
|
||||
ItemStack itemStack = maid.getMainHandItem();
|
||||
ItemStack last = MemoryUtil.getLocateItem(maid);
|
||||
if (!last.isEmpty() && !itemStack.isEmpty() && ItemStack.isSameItemSameTags(last, itemStack)) {
|
||||
if (!last.isEmpty() && !itemStack.isEmpty() && ItemStack.isSameItemSameComponents(last, itemStack)) {
|
||||
MemoryUtil.setLocateItem(maid, itemStack);
|
||||
MemoryUtil.clearCommonBlockCache(maid);
|
||||
}
|
||||
if (maid.getMainHandItem().is(Items.ENDER_EYE)) {
|
||||
ItemLocateEvent event = new ItemLocateEvent(itemStack, maid, MemoryUtil.getCommonBlockCache(maid));
|
||||
ItemLocateEvent posted = NeoForge.EVENT_BUS.post(event);
|
||||
if (posted.isCanceled()) {
|
||||
target = event.getTarget();
|
||||
} else if (maid.getMainHandItem().is(Items.ENDER_EYE)) {
|
||||
target = MemoryUtil.getCommonBlockCache(maid);
|
||||
if (target == null) {
|
||||
BlockPos blockpos = level.findNearestMapStructure(StructureTags.EYE_OF_ENDER_LOCATED, maid.blockPosition(), 100, false);
|
||||
@@ -91,8 +98,9 @@ public class MaidLocateTask implements IMaidTask, IMaidFindTargetTask {
|
||||
target = MemoryUtil.getCommonBlockCache(maid);
|
||||
if (target == null) {
|
||||
GlobalPos globalPos;
|
||||
if (CompassItem.isLodestoneCompass(itemStack)) {
|
||||
globalPos = CompassItem.getLodestonePosition(itemStack.getOrCreateTag());
|
||||
LodestoneTracker lodeData = itemStack.get(DataComponents.LODESTONE_TRACKER);
|
||||
if (lodeData != null && lodeData.target().isPresent()) {
|
||||
globalPos = lodeData.target().get();
|
||||
} else {
|
||||
globalPos = CompassItem.getSpawnPosition(level);
|
||||
}
|
||||
@@ -127,23 +135,21 @@ public class MaidLocateTask implements IMaidTask, IMaidFindTargetTask {
|
||||
if (savedData != null) {
|
||||
BlockPos.MutableBlockPos tmpTarget = new BlockPos.MutableBlockPos(savedData.centerX, level.getSeaLevel(), savedData.centerZ);
|
||||
|
||||
CompoundTag tag = itemStack.getOrCreateTag();
|
||||
savedData.getBanners()
|
||||
.stream()
|
||||
.findFirst()
|
||||
.ifPresent(t -> {
|
||||
tmpTarget.set(t.getPos().immutable());
|
||||
tmpTarget.set(t.pos().immutable());
|
||||
});
|
||||
tag.getList("Decorations", Tag.TAG_COMPOUND)
|
||||
.stream()
|
||||
.filter(t -> ((CompoundTag) t).getByte("type") == 26)
|
||||
.findFirst()
|
||||
.ifPresent(t -> {
|
||||
CompoundTag decoration = (CompoundTag) t;
|
||||
tmpTarget.setX(decoration.getInt("x"));
|
||||
tmpTarget.setZ(decoration.getInt("z"));
|
||||
});
|
||||
|
||||
MapDecorations decoList = itemStack.get(DataComponents.MAP_DECORATIONS);
|
||||
if (decoList != null)
|
||||
decoList.decorations().entrySet().stream()
|
||||
.filter(t -> t.getValue().type() == MapDecorationTypes.RED_X)
|
||||
.findFirst()
|
||||
.ifPresent(t -> {
|
||||
tmpTarget.setX((int) t.getValue().x());
|
||||
tmpTarget.setZ((int) t.getValue().z());
|
||||
});
|
||||
|
||||
target = tmpTarget.immutable();
|
||||
MemoryUtil.setCommonBlockCache(maid, target);
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MaidRevivePlayerTask implements IMaidTask {
|
||||
public static final ResourceLocation UID = new ResourceLocation(MaidUsefulTask.MODID, "revive_player");
|
||||
public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(MaidUsefulTask.MODID, "revive_player");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
|
||||
@@ -20,7 +20,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.LeavesBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import net.neoforged.neoforge.items.wrapper.CombinedInvWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import studio.fantasyit.maid_useful_task.Config;
|
||||
@@ -39,7 +39,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MaidTreeTask implements IMaidTask, IMaidBlockPlaceTask, IMaidBlockDestroyTask, IMaidBlockUpTask {
|
||||
public static final ResourceLocation UID = new ResourceLocation(MaidUsefulTask.MODID, "maid_tree");
|
||||
public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(MaidUsefulTask.MODID, "maid_tree");
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
@@ -184,11 +184,22 @@ public class MaidTreeTask implements IMaidTask, IMaidBlockPlaceTask, IMaidBlockD
|
||||
|
||||
|
||||
protected boolean isValidNatureTree(EntityMaid maid, BlockPos startPos) {
|
||||
return isValidNatureTree(maid, startPos, new HashSet<>(), 0);
|
||||
HashSet<BlockPos> vis = new HashSet<>();
|
||||
BlockValidationMemory validationMemory = MemoryUtil.getBlockValidationMemory(maid);
|
||||
boolean validNatureTree = isValidNatureTree(maid, startPos, vis, 0, validationMemory);
|
||||
for (BlockPos pos : vis) {
|
||||
BlockState blockState = maid.level().getBlockState(pos);
|
||||
if (!blockState.is(BlockTags.LEAVES) && !blockState.is(BlockTags.LOGS))
|
||||
continue;
|
||||
if (validNatureTree)
|
||||
validationMemory.setValid(pos);
|
||||
else
|
||||
validationMemory.setInvalid(pos);
|
||||
}
|
||||
return validNatureTree;
|
||||
}
|
||||
|
||||
protected boolean isValidNatureTree(EntityMaid maid, BlockPos startPos, Set<BlockPos> visited, int depth) {
|
||||
BlockValidationMemory validationMemory = MemoryUtil.getBlockValidationMemory(maid);
|
||||
protected boolean isValidNatureTree(EntityMaid maid, BlockPos startPos, Set<BlockPos> visited, int depth, BlockValidationMemory validationMemory) {
|
||||
if (validationMemory.hasRecord(startPos))
|
||||
return validationMemory.isValid(startPos, false);
|
||||
if (visited.contains(startPos))
|
||||
@@ -205,7 +216,7 @@ public class MaidTreeTask implements IMaidTask, IMaidBlockPlaceTask, IMaidBlockD
|
||||
if (blockState.is(BlockTags.LEAVES) && blockState.hasProperty(LeavesBlock.PERSISTENT) && !blockState.getValue(LeavesBlock.PERSISTENT)) {
|
||||
valid = true;
|
||||
}
|
||||
if (blockState.is(BlockTags.LOGS) && isValidNatureTree(maid, offset, visited, depth + 1)) {
|
||||
if (blockState.is(BlockTags.LOGS) && isValidNatureTree(maid, offset, visited, depth + 1, validationMemory)) {
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
@@ -221,6 +232,7 @@ public class MaidTreeTask implements IMaidTask, IMaidBlockPlaceTask, IMaidBlockD
|
||||
@Override
|
||||
public List<Pair<Integer, BehaviorControl<? super EntityMaid>>> createBrainTasks(EntityMaid entityMaid) {
|
||||
ArrayList<Pair<Integer, BehaviorControl<? super EntityMaid>>> list = new ArrayList<>();
|
||||
list.add(Pair.of(0, new MaidSelfRescueBehavior()));
|
||||
|
||||
list.add(Pair.of(1, new DestoryBlockBehavior()));
|
||||
list.add(Pair.of(1, new DestoryBlockMoveBehavior()));
|
||||
|
||||
@@ -1,16 +1,8 @@
|
||||
package studio.fantasyit.maid_useful_task.util;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class InvUtil {
|
||||
@@ -18,7 +10,7 @@ public class InvUtil {
|
||||
int count = 0;
|
||||
for (int i = 0; i < inv.getSlots(); i++) {
|
||||
ItemStack stackInSlot = inv.getStackInSlot(i);
|
||||
if(stackInSlot.isEmpty()) continue;
|
||||
if (stackInSlot.isEmpty()) continue;
|
||||
if (predicate.test(stackInSlot)) {
|
||||
ItemStack get = inv.extractItem(i, 1, false);
|
||||
if (!get.isEmpty()) {
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package studio.fantasyit.maid_useful_task.util;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import net.minecraft.world.level.ClipContext;
|
||||
@@ -17,11 +16,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
import net.minecraftforge.items.wrapper.RangedWrapper;
|
||||
import net.neoforged.neoforge.items.wrapper.RangedWrapper;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class MaidUtils {
|
||||
@@ -55,9 +51,7 @@ public class MaidUtils {
|
||||
|
||||
public static boolean destroyBlock(EntityMaid maid, BlockPos blockPos) {
|
||||
WrappedMaidFakePlayer fakePlayer = WrappedMaidFakePlayer.get(maid);
|
||||
maid.getMainHandItem().hurtAndBreak(1, fakePlayer, (p_186374_) -> {
|
||||
p_186374_.broadcastBreakEvent(InteractionHand.MAIN_HAND);
|
||||
});
|
||||
maid.getMainHandItem().hurtAndBreak(1, fakePlayer, EquipmentSlot.MAINHAND);
|
||||
ServerLevel level = (ServerLevel) maid.level();
|
||||
BlockState blockState = level.getBlockState(blockPos);
|
||||
if (blockState.isAir()) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package studio.fantasyit.maid_useful_task.util;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -26,9 +27,7 @@ import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
import net.neoforged.neoforge.common.util.FakePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -84,14 +83,14 @@ public class WrappedMaidFakePlayer extends FakePlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeEffect(MobEffect p_21196_) {
|
||||
public boolean removeEffect(Holder<MobEffect> p_21196_) {
|
||||
if (maid == null) return false;
|
||||
return maid.removeEffect(p_21196_);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MobEffectInstance removeEffectNoUpdate(@Nullable MobEffect p_21164_) {
|
||||
public MobEffectInstance removeEffectNoUpdate(@Nullable Holder<MobEffect> p_21164_) {
|
||||
if (maid == null) return super.removeEffectNoUpdate(p_21164_);
|
||||
return maid.removeEffectNoUpdate(p_21164_);
|
||||
}
|
||||
@@ -121,7 +120,7 @@ public class WrappedMaidFakePlayer extends FakePlayer {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MobEffectInstance getEffect(MobEffect p_21125_) {
|
||||
public MobEffectInstance getEffect(Holder<MobEffect> p_21125_) {
|
||||
if (maid == null) return super.getEffect(p_21125_);
|
||||
return maid.getEffect(p_21125_);
|
||||
}
|
||||
@@ -133,13 +132,13 @@ public class WrappedMaidFakePlayer extends FakePlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<MobEffect, MobEffectInstance> getActiveEffectsMap() {
|
||||
public Map<Holder<MobEffect>, MobEffectInstance> getActiveEffectsMap() {
|
||||
if (maid == null) return super.getActiveEffectsMap();
|
||||
return maid.getActiveEffectsMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect(MobEffect p_21024_) {
|
||||
public boolean hasEffect(Holder<MobEffect> p_21024_) {
|
||||
if (maid == null) return super.hasEffect(p_21024_);
|
||||
return maid.hasEffect(p_21024_);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ package studio.fantasyit.maid_useful_task.vehicle;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public interface IVirtualControl {
|
||||
void maid_useful_tasks$setControlParam(float xRot, float yRot, float speed,MaidVehicleControlType type);
|
||||
void maid_useful_tasks$setControlParam(float xRot, float yRot, float speed, MaidVehicleControlType type);
|
||||
|
||||
void maid_useful_tasks$stopControl();
|
||||
|
||||
CompoundTag maid_useful_tasks$getControlParam();
|
||||
|
||||
void maid_useful_tasks$setControlParam(CompoundTag target);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package studio.fantasyit.maid_useful_task.vehicle;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import studio.fantasyit.maid_useful_task.network.MaidSyncVehiclePacket;
|
||||
import studio.fantasyit.maid_useful_task.network.Network;
|
||||
import studio.fantasyit.maid_useful_task.util.MemoryUtil;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.broom.VehicleBroom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -34,8 +33,7 @@ public class MaidVehicleManager {
|
||||
getControllableVehicle(maid).ifPresent(vehicle -> {
|
||||
CompoundTag syncVehicleParameter = vehicle.getSyncVehicleParameter(maid);
|
||||
if (syncVehicleParameter != null) {
|
||||
Network.INSTANCE.send(
|
||||
PacketDistributor.TRACKING_ENTITY_AND_SELF.with(() -> maid),
|
||||
PacketDistributor.sendToPlayersTrackingEntity(maid,
|
||||
new MaidSyncVehiclePacket(maid.getId(), syncVehicleParameter)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package studio.fantasyit.maid_useful_task.vehicle;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityBroom;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Rotations;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import studio.fantasyit.maid_useful_task.util.RotUtil;
|
||||
|
||||
public class VehicleBroom extends AbstractMaidControllableVehicle {
|
||||
@Override
|
||||
public boolean isMaidOnThisVehicle(EntityMaid maid) {
|
||||
return maid.getVehicle() instanceof EntityBroom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maidControlVehicle(EntityMaid maid, MaidVehicleControlType type, BlockPos target) {
|
||||
if (maid.level().isClientSide) return;
|
||||
if (maid.getVehicle() instanceof EntityBroom vehicle) {
|
||||
if (type == MaidVehicleControlType.NONE) {
|
||||
((IVirtualControl) vehicle).maid_useful_tasks$setControlParam(0, 0, 0, type);
|
||||
return;
|
||||
}
|
||||
double xzDistance = maid.distanceToSqr(target.getX(), maid.getY(), target.getZ());
|
||||
double finalXRot = vehicle.getXRot();
|
||||
double finalYRot = vehicle.getYRot();
|
||||
double finalSpeed = 0;
|
||||
if (vehicle.isInWater()) {
|
||||
finalXRot = -10;
|
||||
} else if (xzDistance < Math.pow(maid.getY() - maid.level().getSeaLevel(), 2)) {
|
||||
if (maid.getY() - maid.level().getSeaLevel() < 50 || vehicle.onGround())
|
||||
finalXRot = 15;
|
||||
else
|
||||
finalXRot = 60;
|
||||
} else if (maid.getY() < 100) {
|
||||
finalXRot = -50;
|
||||
} else if (maid.getY() > 160) {
|
||||
finalXRot = 15;
|
||||
} else {
|
||||
finalXRot = 0;
|
||||
}
|
||||
|
||||
finalYRot = RotUtil.getYRot(maid.position(), target.getCenter());
|
||||
|
||||
finalSpeed = type == MaidVehicleControlType.FULL ? 3.0 : 0;
|
||||
if (xzDistance < 5 * 5 && (vehicle.onGround() || vehicle.isInWater()))
|
||||
finalSpeed = 0;
|
||||
|
||||
((IVirtualControl) vehicle).maid_useful_tasks$setControlParam((float) finalXRot, (float) finalYRot, (float) finalSpeed, type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maidStopControlVehicle(EntityMaid maid) {
|
||||
EntityBroom vehicle = (EntityBroom) maid.getVehicle();
|
||||
if (vehicle instanceof IVirtualControl ivc)
|
||||
ivc.maid_useful_tasks$stopControl();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package studio.fantasyit.maid_useful_task.vehicle.broom;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BroomControlParamStore {
|
||||
public record BroomControlParam(float xRot, float yRot, float vertical, float forward,
|
||||
MaidVehicleControlType type) {
|
||||
public static BroomControlParam fromNbt(CompoundTag tag) {
|
||||
return new BroomControlParam(
|
||||
tag.getFloat("xRot"),
|
||||
tag.getFloat("yRot"),
|
||||
tag.getFloat("vertical"),
|
||||
tag.getFloat("forward"),
|
||||
MaidVehicleControlType.valueOf(tag.getString("type"))
|
||||
);
|
||||
}
|
||||
|
||||
public CompoundTag toNbt() {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putFloat("xRot", xRot);
|
||||
tag.putFloat("yRot", yRot);
|
||||
tag.putFloat("vertical", vertical);
|
||||
tag.putFloat("forward", forward);
|
||||
tag.putString("type", type.name());
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
private static final BroomControlParam NONE = new BroomControlParam(0, 0, 0, 0, MaidVehicleControlType.NONE);
|
||||
|
||||
private static final Map<UUID, BroomControlParam> store = new HashMap<>();
|
||||
|
||||
public static void setControlParam(EntityMaid maid, BroomControlParam param) {
|
||||
store.put(maid.getUUID(), param);
|
||||
}
|
||||
|
||||
public static BroomControlParam getControlParam(EntityMaid maid) {
|
||||
if (!store.containsKey(maid.getUUID()))
|
||||
return NONE;
|
||||
return store.get(maid.getUUID());
|
||||
}
|
||||
|
||||
public static void removeControlParam(EntityMaid maid) {
|
||||
store.remove(maid.getUUID());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package studio.fantasyit.maid_useful_task.vehicle.broom;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.api.entity.IBroomControl;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityBroom;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
|
||||
public class BroomController implements IBroomControl {
|
||||
private final EntityBroom broom;
|
||||
|
||||
public BroomController(EntityBroom broom) {
|
||||
this.broom = broom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inControl(Player player, EntityMaid entityMaid) {
|
||||
return BroomControlParamStore.getControlParam(entityMaid).type() != MaidVehicleControlType.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void travel(Player player, EntityMaid entityMaid) {
|
||||
BroomControlParamStore.BroomControlParam param = BroomControlParamStore.getControlParam(entityMaid);
|
||||
|
||||
float forward = 0;
|
||||
float strafe = 0;
|
||||
float vertical = param.vertical();
|
||||
if (param.type() == MaidVehicleControlType.FULL) {
|
||||
forward = param.forward() / 15.0f;
|
||||
} else {
|
||||
boolean keyForward = player.zza > 0;
|
||||
boolean keyBack = player.zza < 0;
|
||||
boolean keyLeft = player.xxa > 0;
|
||||
boolean keyRight = player.xxa < 0;
|
||||
|
||||
if (keyForward || keyBack || keyLeft || keyRight) {
|
||||
strafe = keyLeft ? 0.2f : (keyRight ? -0.2f : 0);
|
||||
forward = keyForward ? 0.375f : (keyBack ? -0.2f : 0);
|
||||
} else {
|
||||
vertical = 0;
|
||||
}
|
||||
}
|
||||
//来自PlayerBroomControl
|
||||
double playerSpeed = player.getAttributeValue(Attributes.MOVEMENT_SPEED);
|
||||
double speed = Math.max(playerSpeed - 0.1, 0) * 2.5 + 0.1;
|
||||
Vec3 targetMotion = new Vec3(strafe, vertical, forward).scale(speed * 20);
|
||||
targetMotion = targetMotion.yRot((float) (-broom.getYRot() * Math.PI / 180.0));
|
||||
|
||||
// 插值到目标速度,而不是直接累加
|
||||
Vec3 currentMotion = broom.getDeltaMovement();
|
||||
Vec3 newMotion = currentMotion.lerp(targetMotion, 0.25f);
|
||||
broom.setDeltaMovement(newMotion);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void tickRot(Player player, EntityMaid entityMaid) {
|
||||
BroomControlParamStore.BroomControlParam param = BroomControlParamStore.getControlParam(entityMaid);
|
||||
|
||||
broom.yRotO = broom.yBodyRot = broom.yHeadRot = broom.getYRot();
|
||||
broom.setRot(param.yRot(), param.xRot());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package studio.fantasyit.maid_useful_task.vehicle.broom;
|
||||
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntityBroom;
|
||||
import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import studio.fantasyit.maid_useful_task.util.RotUtil;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.AbstractMaidControllableVehicle;
|
||||
import studio.fantasyit.maid_useful_task.vehicle.MaidVehicleControlType;
|
||||
|
||||
public class VehicleBroom extends AbstractMaidControllableVehicle {
|
||||
@Override
|
||||
public boolean isMaidOnThisVehicle(EntityMaid maid) {
|
||||
return maid.getVehicle() instanceof EntityBroom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maidControlVehicle(EntityMaid maid, MaidVehicleControlType type, BlockPos target) {
|
||||
if (maid.level().isClientSide) return;
|
||||
if (maid.getVehicle() instanceof EntityBroom vehicle) {
|
||||
if (type == MaidVehicleControlType.NONE) {
|
||||
BroomControlParamStore.removeControlParam(maid);
|
||||
return;
|
||||
}
|
||||
double xzDistance = maid.distanceToSqr(target.getX(), maid.getY(), target.getZ());
|
||||
double finalXRot = vehicle.getXRot();
|
||||
double finalYRot = vehicle.getYRot();
|
||||
double finalVertical = 0;
|
||||
double finalForward;
|
||||
if (vehicle.isInWater()) {
|
||||
finalXRot = 0;
|
||||
finalVertical = 0.1;
|
||||
} else if (xzDistance < Math.pow(maid.getY() - maid.level().getSeaLevel(), 2)) {
|
||||
finalXRot = 0;
|
||||
if (maid.getY() - maid.level().getSeaLevel() < 50 || vehicle.onGround()) {
|
||||
finalXRot = 5;
|
||||
finalVertical = -0.2;
|
||||
} else {
|
||||
finalXRot = 50;
|
||||
finalVertical = -0.35;
|
||||
}
|
||||
} else if (maid.getY() < 100) {
|
||||
finalXRot = -50;
|
||||
finalVertical = 0.2;
|
||||
} else if (maid.getY() > 160) {
|
||||
finalXRot = 0;
|
||||
finalVertical = -0.1;
|
||||
} else {
|
||||
finalXRot = 0;
|
||||
finalVertical = 0.05;
|
||||
}
|
||||
|
||||
finalYRot = RotUtil.getYRot(maid.position(), target.getCenter());
|
||||
|
||||
finalForward = type == MaidVehicleControlType.FULL ? 3.0 : 0;
|
||||
if (xzDistance < 5 * 5)
|
||||
finalForward = 0;
|
||||
|
||||
BroomControlParamStore.setControlParam(maid, new BroomControlParamStore.BroomControlParam((float) finalXRot, (float) finalYRot, (float) finalVertical, (float) finalForward, type));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void maidStopControlVehicle(EntityMaid maid) {
|
||||
BroomControlParamStore.removeControlParam(maid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncVehicleParameter(EntityMaid maid, CompoundTag tag) {
|
||||
BroomControlParamStore.BroomControlParam broomControlParam = BroomControlParamStore.BroomControlParam.fromNbt(tag);
|
||||
BroomControlParamStore.setControlParam(maid, broomControlParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable CompoundTag getSyncVehicleParameter(EntityMaid maid) {
|
||||
return BroomControlParamStore.getControlParam(maid).toNbt();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
public net.minecraft.world.level.BlockGetter m_151361_(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Ljava/lang/Object;Ljava/util/function/BiFunction;Ljava/util/function/Function;)Ljava/lang/Object;
|
||||
public-f net.minecraft.world.entity.player.Player f_36093_
|
||||
public-f net.minecraft.world.entity.player.Player inventory
|
||||
public net.minecraft.world.entity.Entity m_19915_(FF)V
|
||||
@@ -1,80 +0,0 @@
|
||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||
loaderVersion="${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license="${mod_license}"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
# If your mod is purely client-side and has no multiplayer functionality (be it dedicated servers or Open to LAN),
|
||||
# set this to true, and Forge will set the correct displayTest for you and skip loading your mod on dedicated servers.
|
||||
#clientSideOnly=true #optional - defaults to false if absent
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="${mod_id}" #mandatory
|
||||
# The version number of the mod
|
||||
version="${mod_version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="${mod_name}" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.minecraftforge.net/en/latest/misc/updatechecker/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#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
|
||||
#logoFile="maid_useful_task.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
#credits="Thanks for this example mod goes to Java" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="${mod_authors}" #optional
|
||||
# Display Test controls the display for your mod in the server connection screen
|
||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||
# IGNORE_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||
#displayTest="MATCH_VERSION" # if nothing is specified, MATCH_VERSION is the default when clientSideOnly=false, otherwise IGNORE_ALL_VERSION when clientSideOnly=true (#optional)
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''${mod_description}'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies."${mod_id}"]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the dependency is not mandatory
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||
side="BOTH"# Here's another dependency
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="${minecraft_version_range}"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="touhou_little_maid"
|
||||
mandatory=true
|
||||
versionRange="[1.2.2,)"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="playerrevive"
|
||||
mandatory=false
|
||||
versionRange="[2.0.16,)"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
"FollowMaidMixin",
|
||||
"MaidCheckPickupItem",
|
||||
"MaidMoveControlMixin",
|
||||
"MaidRunOneMixin",
|
||||
"VehicleBroomMixin"
|
||||
"MaidRunOneMixin"
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
|
||||
92
src/main/templates/META-INF/neoforge.mods.toml
Normal file
92
src/main/templates/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,92 @@
|
||||
modLoader="javafml" #mandatory
|
||||
|
||||
# A version range to match for said mod loader - for regular FML @Mod it will be the FML version. This is currently 2.
|
||||
loaderVersion="${loader_version_range}" #mandatory
|
||||
|
||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||
license="${mod_license}"
|
||||
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
|
||||
# The modid of the mod
|
||||
modId="${mod_id}" #mandatory
|
||||
|
||||
# The version number of the mod
|
||||
version="${mod_version}" #mandatory
|
||||
|
||||
# A display name for the mod
|
||||
displayName="${mod_name}" #mandatory
|
||||
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://docs.neoforged.net/docs/misc/updatechecker/
|
||||
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
|
||||
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#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
|
||||
#logoFile="examplemod.png" #optional
|
||||
|
||||
# A text field displayed in the mod UI
|
||||
#credits="" #optional
|
||||
|
||||
# A text field displayed in the mod UI
|
||||
authors="${mod_authors}" #optional
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''${mod_description}'''
|
||||
|
||||
# The [[mixins]] block allows you to declare your mixin config to FML so that it gets loaded.
|
||||
[[mixins]]
|
||||
config="${mod_id}.mixins.json"
|
||||
|
||||
# The [[accessTransformers]] block allows you to declare where your AT file is.
|
||||
# If this block is omitted, a fallback attempt will be made to load an AT from META-INF/accesstransformer.cfg
|
||||
[[accessTransformers]]
|
||||
file="META-INF/accesstransformer.cfg"
|
||||
|
||||
# The coremods config file path is not configurable and is always loaded from META-INF/coremods.json
|
||||
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.${mod_id}]] #optional
|
||||
# the modid of the dependency
|
||||
modId="neoforge" #mandatory
|
||||
# The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive).
|
||||
# 'required' requires the mod to exist, 'optional' does not
|
||||
# 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning
|
||||
type="required" #mandatory
|
||||
# Optional field describing why the dependency is required or why it is incompatible
|
||||
# reason="..."
|
||||
# The version range of the dependency
|
||||
versionRange="${neo_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency.
|
||||
# BEFORE - This mod is loaded BEFORE the dependency
|
||||
# AFTER - This mod is loaded AFTER the dependency
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||
side="BOTH"
|
||||
|
||||
# Here's another dependency
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="minecraft"
|
||||
type="required" #mandatory
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange="${minecraft_version_range}"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="touhou_little_maid"
|
||||
type="required" #mandatory
|
||||
versionRange="[1.3.7,)"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
[[dependencies."${mod_id}"]]
|
||||
modId="playerrevive"
|
||||
type="optional" #mandatory
|
||||
versionRange="[2.0.16,)"
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
Reference in New Issue
Block a user