Compare commits
No commits in common. "b00f500e3622691c4ceadb17ff1570fd06a6577a" and "adb3a652f68c50dfaff9793e5ca21d5f910e7fb3" have entirely different histories.
b00f500e36
...
adb3a652f6
27 changed files with 549 additions and 585 deletions
16
Changelog.md
16
Changelog.md
|
@ -1,21 +1,5 @@
|
|||
# Upcoming changes
|
||||
|
||||
# Version NeoForge-1.24.0
|
||||
|
||||
Update to NeoForge 1.20.2-20.2.88.
|
||||
|
||||
Allow use of Crossbows in battle (it should behave identically to Bows).
|
||||
|
||||
# Version Forge-1.24.0
|
||||
|
||||
Update to Forge 1.20.2-48.1.0.
|
||||
|
||||
The `master` branch of this repository will track the build for Minecraft Forge.
|
||||
|
||||
The `neoforge` branch of this repo. will track the build for NeoForge.
|
||||
|
||||
Allow use of Crossbows in battle (it should behave identically to Bows).
|
||||
|
||||
# Version 1.23.1
|
||||
|
||||
More robust handling of disallowed Damage Sources in battle (via config).
|
||||
|
|
212
build.gradle
212
build.gradle
|
@ -2,88 +2,168 @@ plugins {
|
|||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.57'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
}
|
||||
|
||||
version = "1.24.0"
|
||||
version = "1.23.1"
|
||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
||||
archivesBaseName = "TurnBasedMinecraft-NeoForge"
|
||||
archivesBaseName = "TurnBasedMinecraft"
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
jarJar.enable()
|
||||
minecraft {
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||
// stable_# Stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: mapping_channel, version: mapping_version
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
// applies to all the run configs below
|
||||
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'
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// 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
|
||||
systemProperty 'forge.logging.console.level', 'debug'
|
||||
// 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
|
||||
|
||||
modSource project.sourceSets.main
|
||||
}
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
server {
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
programArgument '--nogui'
|
||||
}
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// 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 {
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
|
||||
data {
|
||||
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||
// workingDirectory project.file('run-data')
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
|
||||
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
|
||||
server {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This run config launches GameTestServer and runs all registered gametests, then exits.
|
||||
// By default, the server will crash when no gametests are provided.
|
||||
// The gametest system is also enabled by default for other run configs under the /test command.
|
||||
gameTestServer {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// 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'
|
||||
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
|
||||
// Recommended logging data for a userdev environment
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
|
||||
// Recommended logging level for the console
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
args '--mod', 'TurnBasedMinecraftMod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources')
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
dir 'libs'
|
||||
}
|
||||
//repositories {
|
||||
// // Put repositories for dependencies here
|
||||
// // ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
//
|
||||
// // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
||||
// // flatDir {
|
||||
// // dir 'libs'
|
||||
// // }
|
||||
// mavenCentral()
|
||||
// jcenter()
|
||||
//
|
||||
// dependencies {
|
||||
// classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
||||
// }
|
||||
//}
|
||||
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
configurations {
|
||||
shade
|
||||
impelmentation.extendsFrom shade
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Specify the version of Minecraft to use.
|
||||
// Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
|
||||
// The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
|
||||
// You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
|
||||
// And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
|
||||
// For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
|
||||
implementation "net.neoforged:neoforge:${neo_version}"
|
||||
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
|
||||
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
|
||||
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
|
||||
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
|
||||
|
||||
// implementation files('libs/javamp3-1.0.3.jar')
|
||||
implementation 'fr.delthas:javamp3:1.0.3'
|
||||
// Real mod deobf dependency examples - these get remapped to your current mappings
|
||||
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
|
||||
// runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}") // Adds the full JEI mod as a runtime dependency
|
||||
// implementation fg.deobf("com.tterrag.registrate:Registrate:MC${mc_version}-${registrate_version}") // Adds registrate as a dependency
|
||||
|
||||
jarJar(group: 'fr.delthas', name: 'javamp3', version: '[1.0.0,2.0.0)') {
|
||||
jarJar.pin(it, '1.0.3')
|
||||
}
|
||||
// Examples using mod jars from ./libs
|
||||
// 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
|
||||
implementation files('libs/javamp3-1.0.3.jar')
|
||||
|
||||
shade files('libs/javamp3-1.0.3.jar')
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
|
@ -93,7 +173,7 @@ dependencies {
|
|||
tasks.named('processResources', ProcessResources).configure {
|
||||
var replaceProperties = [
|
||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
neo_version : neo_version, neo_version_range: neo_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,
|
||||
|
@ -123,16 +203,26 @@ jar {
|
|||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier = ''
|
||||
//project.configurations.shadow.setTransitive(true);
|
||||
configurations = [project.configurations.shade]
|
||||
relocate 'fr.delthas', 'com.burnedkirby.tbm_repack.fr.delthas'
|
||||
finalizedBy 'reobfShadowJar'
|
||||
}
|
||||
|
||||
assemble.dependsOn shadowJar
|
||||
|
||||
reobf {
|
||||
shadowJar {} // reobfuscate the shadowed jar
|
||||
}
|
||||
|
||||
// Reproducible Builds
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
|
||||
}
|
||||
|
||||
// Example configuration to allow publishing using the maven-publish task
|
||||
// we define a custom artifact that is sourced from the reobfJar output task
|
||||
// and then declare that to be published
|
||||
|
|
|
@ -4,17 +4,35 @@ org.gradle.daemon=false
|
|||
## Environment Properties
|
||||
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=1.20.2
|
||||
minecraft_version=1.20.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.2,1.21)
|
||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||
neo_version=20.2.86
|
||||
# The Neo version range can use any version of Neo as bounds or match the loader version range
|
||||
neo_version_range=[20.2,)
|
||||
# The loader version range can only use the major version of Neo/FML as bounds
|
||||
loader_version_range=[1,)
|
||||
minecraft_version_range=[1.20.1,1.21)
|
||||
# The Forge version must agree with the Minecraft version to get a valid artifact
|
||||
forge_version=47.1.0
|
||||
# The Forge version range can use any version of Forge as bounds or match the loader version range
|
||||
forge_version_range=[47,)
|
||||
# The loader version range can only use the major version of Forge/FML as bounds
|
||||
loader_version_range=[47,)
|
||||
# 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.
|
||||
#
|
||||
# | 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 Minecraft Forge.
|
||||
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
|
||||
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
|
||||
|
||||
## Mod Properties
|
||||
|
||||
|
@ -26,7 +44,7 @@ mod_name=TurnBasedMinecraftMod
|
|||
# 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.24.0
|
||||
mod_version=1.23.1
|
||||
# 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
|
||||
|
@ -35,5 +53,3 @@ mod_version=1.24.0
|
|||
mod_authors=BurnedKirby a.k.a. Stephen Seo
|
||||
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
|
||||
mod_description=Implements turn-based-battle in Minecraft.
|
||||
# Pack version - this changes each minecraft release, in general.
|
||||
pack_format_number=18
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
11
gradlew
vendored
11
gradlew
vendored
|
@ -85,9 +85,6 @@ done
|
|||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
|
@ -144,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
|
@ -152,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
|
|
184
gradlew.bat
vendored
184
gradlew.bat
vendored
|
@ -1,92 +1,92 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
|
|
@ -2,7 +2,8 @@ pluginManagement {
|
|||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
name = 'MinecraftForge'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
}
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
|
|
|
@ -368,9 +368,4 @@ public class BattleGui extends Screen {
|
|||
public void setTurnTimerMax(int timerMax) {
|
||||
this.timerMax = timerMax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(GuiGraphics p_283688_, int p_296369_, int p_296477_, float p_294317_) {
|
||||
// Prevent graying of background.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
private BattleGui battleGui = null;
|
||||
|
@ -222,7 +224,7 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <MSG> void handlePacket(MSG msg, NetworkEvent.Context ctx) {
|
||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
if (msg.getClass() == PacketBattleMessage.class) {
|
||||
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
||||
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
||||
|
@ -433,11 +435,6 @@ public class ClientProxy extends CommonProxy {
|
|||
parentComponent.getSiblings().add(message);
|
||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
}
|
||||
case CROSSBOW_NO_AMMO: {
|
||||
parentComponent.getSiblings().add(from);
|
||||
parentComponent.getSiblings().add(Component.literal(" tried to use their crossbow but ran out of ammo!"));
|
||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (msg.getClass() == PacketGeneralMessage.class) {
|
||||
|
|
|
@ -9,10 +9,10 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage
|
|||
import net.minecraft.world.damagesource.DamageTypes;
|
||||
import net.minecraft.world.entity.monster.Creeper;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
public class AttackEventHandler
|
||||
{
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleInfo;
|
|||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -14,8 +13,8 @@ import net.minecraft.world.entity.monster.Creeper;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.*;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.common.CreativeModeTabRegistry;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -794,28 +793,6 @@ public class Battle {
|
|||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getId(), 0, 0);
|
||||
}
|
||||
continue;
|
||||
} else if (heldItemStack.getItem() instanceof CrossbowItem) {
|
||||
debugLog += " with crossbow";
|
||||
if (Utility.doesPlayerHaveArrows((Player) next.entity)) {
|
||||
final Entity nextEntity = next.entity;
|
||||
final Entity targetEntity = target.entity;
|
||||
final float yawDirection = Utility.yawDirection(next.entity.getX(), next.entity.getZ(), target.entity.getX(), target.entity.getZ());
|
||||
final float pitchDirection = Utility.pitchDirection(next.entity.getX(), next.entity.getY(), next.entity.getZ(), target.entity.getX(), target.entity.getY(), target.entity.getZ());
|
||||
if (TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) {
|
||||
next.yaw = yawDirection;
|
||||
next.pitch = pitchDirection;
|
||||
}
|
||||
// have player look at attack target
|
||||
((ServerPlayer) nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
|
||||
CrossbowItem itemCrossbow = (CrossbowItem) heldItemStack.getItem();
|
||||
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
|
||||
itemCrossbow.releaseUsing(heldItemStack, nextEntity.level(), (LivingEntity)nextEntity, -100);
|
||||
itemCrossbow.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND);
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
|
||||
} else {
|
||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.CROSSBOW_NO_AMMO, next.entity.getId(), 0, 0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
debugLog += " without bow";
|
||||
int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
|
||||
|
|
|
@ -7,10 +7,10 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.monster.Creeper;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
|
@ -32,7 +32,7 @@ public class BattleManager
|
|||
recentlyLeftBattle = new HashMap<Integer, Combatant>();
|
||||
battleUpdater = new BattleUpdater(this);
|
||||
entityToBattleMap = new HashMap<EntityIDDimPair, Integer>();
|
||||
NeoForge.EVENT_BUS.register(battleUpdater);
|
||||
MinecraftForge.EVENT_BUS.register(battleUpdater);
|
||||
tempIDPair = new EntityIDDimPair();
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ public class BattleManager
|
|||
public void cleanup()
|
||||
{
|
||||
battleUpdater.setRunning(false);
|
||||
NeoForge.EVENT_BUS.unregister(battleUpdater);
|
||||
MinecraftForge.EVENT_BUS.unregister(battleUpdater);
|
||||
battleMap.clear();
|
||||
battleUpdater = null;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
|
|
@ -5,14 +5,15 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CommonProxy
|
||||
{
|
||||
|
@ -172,5 +173,5 @@ public class CommonProxy
|
|||
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
||||
}
|
||||
|
||||
public <MSG> void handlePacket(MSG msg, NetworkEvent.Context ctx) {}
|
||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
|
||||
}
|
||||
|
|
|
@ -1521,7 +1521,7 @@ public class Config
|
|||
possibleIgnoreHurtDamageSources.clear();
|
||||
|
||||
try {
|
||||
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.value().msgId()));
|
||||
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.get().msgId()));
|
||||
} catch (Exception e) {
|
||||
logger.warn("Config failed to load possible DamageSources! Undesired things may happen, like Zombies dying from Fire during battle!");
|
||||
logger.warn(e);
|
||||
|
|
|
@ -2,9 +2,9 @@ package com.burnedkirby.TurnBasedMinecraft.common;
|
|||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.neoforge.event.entity.EntityTravelToDimensionEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.minecraftforge.event.entity.EntityTravelToDimensionEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
|
||||
public class DimensionChangedHandler {
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class HurtEventHandler {
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
public class PlayerJoinEventHandler
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import ca.weblite.objc.Client;
|
||||
import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
|
||||
import com.mojang.brigadier.LiteralMessage;
|
||||
|
@ -19,20 +18,20 @@ import net.minecraft.network.chat.HoverEvent;
|
|||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.RegisterCommandsEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStartingEvent;
|
||||
import net.neoforged.neoforge.event.server.ServerStoppingEvent;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.neoforged.neoforge.network.NetworkRegistry;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.network.simple.SimpleChannel;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.RegisterCommandsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -40,7 +39,7 @@ import org.apache.logging.log4j.Logger;
|
|||
public class TurnBasedMinecraftMod {
|
||||
public static final String MODID = "com_burnedkirby_turnbasedminecraft";
|
||||
public static final String NAME = "Turn Based Minecraft Mod";
|
||||
public static final String VERSION = "1.24.0";
|
||||
public static final String VERSION = "1.23.1";
|
||||
public static final String CONFIG_FILENAME = "TBM_Config.toml";
|
||||
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
|
||||
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
|
||||
|
@ -51,7 +50,7 @@ public class TurnBasedMinecraftMod {
|
|||
public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
|
||||
public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
|
||||
|
||||
private static final String PROTOCOL_VERSION = Integer.toString(3);
|
||||
private static final String PROTOCOL_VERSION = Integer.toString(2);
|
||||
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
||||
private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
|
||||
.named(HANDLER_ID)
|
||||
|
@ -76,15 +75,11 @@ public class TurnBasedMinecraftMod {
|
|||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
|
||||
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
private void firstInit(final FMLCommonSetupEvent event) {
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
proxy = new ClientProxy();
|
||||
} else {
|
||||
proxy = new CommonProxy();
|
||||
}
|
||||
proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
|
||||
proxy.setLogger(logger);
|
||||
proxy.initialize();
|
||||
|
||||
|
@ -93,45 +88,45 @@ public class TurnBasedMinecraftMod {
|
|||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleInfo.class,
|
||||
new PacketBattleInfo.Encoder(),
|
||||
new PacketBattleInfo.Decoder(),
|
||||
new PacketBattleInfo.Consumer());
|
||||
PacketBattleInfo::encode,
|
||||
PacketBattleInfo::decode,
|
||||
PacketBattleInfo::handle);
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleRequestInfo.class,
|
||||
new PacketBattleRequestInfo.Encoder(),
|
||||
new PacketBattleRequestInfo.Decoder(),
|
||||
new PacketBattleRequestInfo.Consumer());
|
||||
PacketBattleRequestInfo::encode,
|
||||
PacketBattleRequestInfo::decode,
|
||||
PacketBattleRequestInfo::handle);
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleDecision.class,
|
||||
new PacketBattleDecision.Encoder(),
|
||||
new PacketBattleDecision.Decoder(),
|
||||
new PacketBattleDecision.Consumer());
|
||||
PacketBattleDecision::encode,
|
||||
PacketBattleDecision::decode,
|
||||
PacketBattleDecision::handle);
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleMessage.class,
|
||||
new PacketBattleMessage.Encoder(),
|
||||
new PacketBattleMessage.Decoder(),
|
||||
new PacketBattleMessage.Consumer());
|
||||
PacketBattleMessage::encode,
|
||||
PacketBattleMessage::decode,
|
||||
PacketBattleMessage::handle);
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketGeneralMessage.class,
|
||||
new PacketGeneralMessage.Encoder(),
|
||||
new PacketGeneralMessage.Decoder(),
|
||||
new PacketGeneralMessage.Consumer());
|
||||
PacketGeneralMessage::encode,
|
||||
PacketGeneralMessage::decode,
|
||||
PacketGeneralMessage::handle);
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketEditingMessage.class,
|
||||
new PacketEditingMessage.Encoder(),
|
||||
new PacketEditingMessage.Decoder(),
|
||||
new PacketEditingMessage.Consumer());
|
||||
PacketEditingMessage::encode,
|
||||
PacketEditingMessage::decode,
|
||||
PacketEditingMessage::handle);
|
||||
|
||||
// register event handler(s)
|
||||
NeoForge.EVENT_BUS.register(new AttackEventHandler());
|
||||
NeoForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||
NeoForge.EVENT_BUS.register(new DimensionChangedHandler());
|
||||
NeoForge.EVENT_BUS.register(new HurtEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new DimensionChangedHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new HurtEventHandler());
|
||||
|
||||
logger.debug("Init com_burnedkirby_turnbasedminecraft");
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
public class PacketBattleDecision
|
||||
{
|
||||
|
@ -23,41 +24,26 @@ public class PacketBattleDecision
|
|||
this.decision = decision;
|
||||
this.targetIDOrItemID = targetIDOrItemID;
|
||||
}
|
||||
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleDecision> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
buf.writeInt(pkt.decision.getValue());
|
||||
buf.writeInt(pkt.targetIDOrItemID);
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
buf.writeInt(pkt.decision.getValue());
|
||||
buf.writeInt(pkt.targetIDOrItemID);
|
||||
}
|
||||
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleDecision> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleDecision decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
||||
}
|
||||
|
||||
public static PacketBattleDecision decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
||||
}
|
||||
|
||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleDecision> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void handle(PacketBattleDecision pkt, NetworkEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b != null)
|
||||
{
|
||||
ServerPlayer player = ctx.getSender();
|
||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||
}
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b != null)
|
||||
{
|
||||
ServerPlayer player = ctx.get().getSender();
|
||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
public class PacketBattleInfo
|
||||
{
|
||||
|
@ -38,80 +38,65 @@ public class PacketBattleInfo
|
|||
this.turnTimerEnabled = turnTimerEnabled;
|
||||
}
|
||||
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleInfo> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
|
||||
buf.writeInt(msg.sideA.size());
|
||||
buf.writeInt(msg.sideB.size());
|
||||
for(Integer id : msg.sideA) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
for(Integer id : msg.sideB) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
buf.writeLong(msg.decisionNanos);
|
||||
buf.writeLong(msg.maxDecisionNanos);
|
||||
buf.writeBoolean(msg.turnTimerEnabled);
|
||||
}
|
||||
public static void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
|
||||
buf.writeInt(msg.sideA.size());
|
||||
buf.writeInt(msg.sideB.size());
|
||||
for(Integer id : msg.sideA) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
for(Integer id : msg.sideB) {
|
||||
buf.writeInt(id);
|
||||
}
|
||||
buf.writeLong(msg.decisionNanos);
|
||||
buf.writeLong(msg.maxDecisionNanos);
|
||||
buf.writeBoolean(msg.turnTimerEnabled);
|
||||
}
|
||||
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleInfo> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleInfo decode(FriendlyByteBuf buf) {
|
||||
int sideACount = buf.readInt();
|
||||
int sideBCount = buf.readInt();
|
||||
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
||||
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
||||
for(int i = 0; i < sideACount; ++i) {
|
||||
sideA.add(buf.readInt());
|
||||
}
|
||||
for(int i = 0; i < sideBCount; ++i) {
|
||||
sideB.add(buf.readInt());
|
||||
}
|
||||
long decisionNanos = buf.readLong();
|
||||
long maxDecisionNanos = buf.readLong();
|
||||
boolean turnTimerEnabled = buf.readBoolean();
|
||||
return new PacketBattleInfo(sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
||||
}
|
||||
public static PacketBattleInfo decode(FriendlyByteBuf buf) {
|
||||
int sideACount = buf.readInt();
|
||||
int sideBCount = buf.readInt();
|
||||
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
||||
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
||||
for(int i = 0; i < sideACount; ++i) {
|
||||
sideA.add(buf.readInt());
|
||||
}
|
||||
for(int i = 0; i < sideBCount; ++i) {
|
||||
sideB.add(buf.readInt());
|
||||
}
|
||||
long decisionNanos = buf.readLong();
|
||||
long maxDecisionNanos = buf.readLong();
|
||||
boolean turnTimerEnabled = buf.readBoolean();
|
||||
return new PacketBattleInfo(sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
||||
}
|
||||
|
||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleInfo> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void handle(PacketBattleInfo pkt, NetworkEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||
|
||||
public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
|
||||
for(Integer id : pkt.sideA)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
{
|
||||
return;
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().clearCombatants();
|
||||
for(Integer id : pkt.sideA)
|
||||
}
|
||||
for(Integer id : pkt.sideB)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideA(e);
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
|
||||
}
|
||||
for(Integer id : pkt.sideB)
|
||||
{
|
||||
Entity e = Minecraft.getInstance().level.getEntity(id);
|
||||
if(e != null)
|
||||
{
|
||||
TurnBasedMinecraftMod.proxy.getLocalBattle().addCombatantToSideB(e);
|
||||
}
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTime((int)(pkt.decisionNanos / 1000000000L));
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
|
@ -9,9 +10,9 @@ import com.burnedkirby.TurnBasedMinecraft.common.Utility;
|
|||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
public class PacketBattleMessage
|
||||
{
|
||||
|
@ -38,8 +39,7 @@ public class PacketBattleMessage
|
|||
BOW_NO_AMMO(18),
|
||||
CREEPER_WAIT(19),
|
||||
CREEPER_WAIT_FINAL(20),
|
||||
CREEPER_EXPLODE(21),
|
||||
CROSSBOW_NO_AMMO(22);
|
||||
CREEPER_EXPLODE(21);
|
||||
|
||||
private int value;
|
||||
private static Map<Integer, MessageType> map = new HashMap<Integer, MessageType>();
|
||||
|
@ -153,48 +153,31 @@ public class PacketBattleMessage
|
|||
this.amount = amount;
|
||||
this.custom = custom;
|
||||
}
|
||||
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleMessage> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.messageType.getValue());
|
||||
buf.writeInt(pkt.entityIDFrom);
|
||||
buf.writeInt(pkt.entityIDTo);
|
||||
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
||||
buf.writeInt(pkt.amount);
|
||||
buf.writeUtf(pkt.custom);
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.messageType.getValue());
|
||||
buf.writeInt(pkt.entityIDFrom);
|
||||
buf.writeInt(pkt.entityIDTo);
|
||||
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
||||
buf.writeInt(pkt.amount);
|
||||
buf.writeUtf(pkt.custom);
|
||||
}
|
||||
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleMessage(
|
||||
MessageType.valueOf(
|
||||
buf.readInt()),
|
||||
buf.readInt(),
|
||||
buf.readInt(),
|
||||
Utility.deserializeDimension(buf.readUtf()),
|
||||
buf.readInt(),
|
||||
buf.readUtf());
|
||||
}
|
||||
|
||||
public static PacketBattleMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleMessage(
|
||||
MessageType.valueOf(
|
||||
buf.readInt()),
|
||||
buf.readInt(),
|
||||
buf.readInt(),
|
||||
Utility.deserializeDimension(buf.readUtf()),
|
||||
buf.readInt(),
|
||||
buf.readUtf());
|
||||
}
|
||||
|
||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleMessage> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void handle(PacketBattleMessage pkt, NetworkEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||
}
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
public class PacketBattleRequestInfo
|
||||
{
|
||||
|
@ -17,38 +18,23 @@ public class PacketBattleRequestInfo
|
|||
{
|
||||
this.battleID = battleID;
|
||||
}
|
||||
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleRequestInfo> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
}
|
||||
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleRequestInfo> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleRequestInfo(buf.readInt());
|
||||
}
|
||||
|
||||
public static PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleRequestInfo(buf.readInt());
|
||||
}
|
||||
|
||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleRequestInfo> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void handle(PacketBattleRequestInfo pkt, NetworkEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b == null) {
|
||||
return;
|
||||
}
|
||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx);
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||
if(b == null) {
|
||||
return;
|
||||
}
|
||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx.get());
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,13 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
|||
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketEditingMessage
|
||||
{
|
||||
|
@ -86,76 +87,59 @@ public class PacketEditingMessage
|
|||
this.entityInfo = entityInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketEditingMessage> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.type.getValue());
|
||||
if(pkt.entityInfo.classType != null) {
|
||||
buf.writeUtf(pkt.entityInfo.classType.getName());
|
||||
} else {
|
||||
buf.writeUtf("unknown");
|
||||
}
|
||||
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
||||
buf.writeInt(pkt.entityInfo.attackPower);
|
||||
buf.writeInt(pkt.entityInfo.attackProbability);
|
||||
buf.writeInt(pkt.entityInfo.attackVariance);
|
||||
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
||||
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamage);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
||||
buf.writeInt(pkt.entityInfo.evasion);
|
||||
buf.writeInt(pkt.entityInfo.speed);
|
||||
buf.writeUtf(pkt.entityInfo.category);
|
||||
buf.writeInt(pkt.entityInfo.decisionAttack);
|
||||
buf.writeInt(pkt.entityInfo.decisionDefend);
|
||||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
||||
buf.writeUtf(pkt.entityInfo.customName);
|
||||
}
|
||||
|
||||
public static void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.type.getValue());
|
||||
if(pkt.entityInfo.classType != null) {
|
||||
buf.writeUtf(pkt.entityInfo.classType.getName());
|
||||
} else {
|
||||
buf.writeUtf("unknown");
|
||||
}
|
||||
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
||||
buf.writeInt(pkt.entityInfo.attackPower);
|
||||
buf.writeInt(pkt.entityInfo.attackProbability);
|
||||
buf.writeInt(pkt.entityInfo.attackVariance);
|
||||
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
||||
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamage);
|
||||
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
||||
buf.writeInt(pkt.entityInfo.evasion);
|
||||
buf.writeInt(pkt.entityInfo.speed);
|
||||
buf.writeUtf(pkt.entityInfo.category);
|
||||
buf.writeInt(pkt.entityInfo.decisionAttack);
|
||||
buf.writeInt(pkt.entityInfo.decisionDefend);
|
||||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
||||
buf.writeUtf(pkt.entityInfo.customName);
|
||||
}
|
||||
|
||||
public static PacketEditingMessage decode(FriendlyByteBuf buf) {
|
||||
Type type = Type.valueOf(buf.readInt());
|
||||
EntityInfo einfo = new EntityInfo();
|
||||
try {
|
||||
einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
||||
} catch (ClassNotFoundException e) { /* ignored */ }
|
||||
einfo.ignoreBattle = buf.readBoolean();
|
||||
einfo.attackPower = buf.readInt();
|
||||
einfo.attackProbability = buf.readInt();
|
||||
einfo.attackVariance = buf.readInt();
|
||||
einfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
||||
einfo.attackEffectProbability = buf.readInt();
|
||||
einfo.defenseDamage = buf.readInt();
|
||||
einfo.defenseDamageProbability = buf.readInt();
|
||||
einfo.evasion = buf.readInt();
|
||||
einfo.speed = buf.readInt();
|
||||
einfo.category = buf.readUtf();
|
||||
einfo.decisionAttack = buf.readInt();
|
||||
einfo.decisionDefend = buf.readInt();
|
||||
einfo.decisionFlee = buf.readInt();
|
||||
einfo.customName = buf.readUtf();
|
||||
return new PacketEditingMessage(type, einfo);
|
||||
}
|
||||
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketEditingMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketEditingMessage decode(FriendlyByteBuf buf) {
|
||||
Type type = Type.valueOf(buf.readInt());
|
||||
EntityInfo einfo = new EntityInfo();
|
||||
try {
|
||||
einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
||||
} catch (ClassNotFoundException e) { /* ignored */ }
|
||||
einfo.ignoreBattle = buf.readBoolean();
|
||||
einfo.attackPower = buf.readInt();
|
||||
einfo.attackProbability = buf.readInt();
|
||||
einfo.attackVariance = buf.readInt();
|
||||
einfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
||||
einfo.attackEffectProbability = buf.readInt();
|
||||
einfo.defenseDamage = buf.readInt();
|
||||
einfo.defenseDamageProbability = buf.readInt();
|
||||
einfo.evasion = buf.readInt();
|
||||
einfo.speed = buf.readInt();
|
||||
einfo.category = buf.readUtf();
|
||||
einfo.decisionAttack = buf.readInt();
|
||||
einfo.decisionDefend = buf.readInt();
|
||||
einfo.decisionFlee = buf.readInt();
|
||||
einfo.customName = buf.readUtf();
|
||||
return new PacketEditingMessage(type, einfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketEditingMessage> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void handle(PacketEditingMessage pkt, NetworkEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||
}
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.DistExecutor;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
public class PacketGeneralMessage
|
||||
{
|
||||
|
@ -26,36 +26,19 @@ public class PacketGeneralMessage
|
|||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketGeneralMessage> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeUtf(pkt.message);
|
||||
}
|
||||
|
||||
public static void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeUtf(pkt.message);
|
||||
}
|
||||
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketGeneralMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketGeneralMessage(buf.readUtf());
|
||||
}
|
||||
|
||||
public static PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketGeneralMessage(buf.readUtf());
|
||||
}
|
||||
|
||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketGeneralMessage> {
|
||||
public Consumer() {}
|
||||
|
||||
@Override
|
||||
public void handle(PacketGeneralMessage pkt, NetworkEvent.Context ctx) {
|
||||
ctx.enqueueWork(() -> {
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||
}
|
||||
});
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ Implements turn-based-battle in Minecraft.
|
|||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
||||
# the modid of the dependency
|
||||
modId="neoforge" #mandatory
|
||||
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="${neo_version_range}" #mandatory
|
||||
versionRange="${forge_version_range}" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"modid": "com_burnedkirby_turnbasedminecraft",
|
||||
"name": "Turn Based Minecraft",
|
||||
"description": "Changes battles to be turn-based.",
|
||||
"version": "1.24.0",
|
||||
"version": "1.23.1",
|
||||
"mcversion": "1.20.1",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
|
|
Loading…
Reference in a new issue