Compare commits
3 commits
adb3a652f6
...
b00f500e36
Author | SHA1 | Date | |
---|---|---|---|
b00f500e36 | |||
a1de902d69 | |||
c9bf87271d |
27 changed files with 585 additions and 549 deletions
16
Changelog.md
16
Changelog.md
|
@ -1,5 +1,21 @@
|
|||
# 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).
|
||||
|
|
190
build.gradle
190
build.gradle
|
@ -2,168 +2,88 @@ plugins {
|
|||
id 'eclipse'
|
||||
id 'idea'
|
||||
id 'maven-publish'
|
||||
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
id 'net.neoforged.gradle.userdev' version '7.0.57'
|
||||
}
|
||||
|
||||
version = "1.23.1"
|
||||
version = "1.24.0"
|
||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
||||
archivesBaseName = "TurnBasedMinecraft"
|
||||
archivesBaseName = "TurnBasedMinecraft-NeoForge"
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
|
||||
|
||||
minecraft {
|
||||
// The mappings can be changed at any time, and must be in the following format.
|
||||
// snapshot_YYYYMMDD Snapshot are built nightly.
|
||||
// stable_# Stables are built at the discretion of the MCP team.
|
||||
// Use non-default mappings at your own risk. they may not always work.
|
||||
// Simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings channel: mapping_channel, version: mapping_version
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
// 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
|
||||
|
||||
// Default run configurations.
|
||||
// These can be tweaked, removed, or duplicated as needed.
|
||||
runs {
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
jarJar.enable()
|
||||
|
||||
// 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
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
// 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
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
// 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'
|
||||
|
||||
modSource project.sourceSets.main
|
||||
}
|
||||
|
||||
client {
|
||||
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
|
||||
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
|
||||
|
||||
mods {
|
||||
TurnBasedMinecraftMod {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
programArgument '--nogui'
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
// example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
|
||||
// workingDirectory project.file('run-data')
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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()
|
||||
}
|
||||
}
|
||||
|
||||
// Include resources generated by data generators.
|
||||
sourceSets.main.resources { srcDir 'src/generated/resources' }
|
||||
|
||||
//repositories {
|
||||
// // Put repositories for dependencies here
|
||||
// // ForgeGradle automatically adds the Forge maven and Maven Central for you
|
||||
//
|
||||
// // If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
|
||||
// // flatDir {
|
||||
// // dir 'libs'
|
||||
// // }
|
||||
// mavenCentral()
|
||||
// jcenter()
|
||||
//
|
||||
// dependencies {
|
||||
// classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
||||
// }
|
||||
//}
|
||||
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
|
||||
configurations {
|
||||
shade
|
||||
impelmentation.extendsFrom shade
|
||||
repositories {
|
||||
flatDir {
|
||||
dir 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// 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}"
|
||||
// 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}"
|
||||
|
||||
// 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
|
||||
// implementation files('libs/javamp3-1.0.3.jar')
|
||||
implementation 'fr.delthas:javamp3: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')
|
||||
jarJar(group: 'fr.delthas', name: 'javamp3', version: '[1.0.0,2.0.0)') {
|
||||
jarJar.pin(it, '1.0.3')
|
||||
}
|
||||
}
|
||||
|
||||
// This block of code expands all declared replace properties in the specified resource targets.
|
||||
|
@ -173,7 +93,7 @@ dependencies {
|
|||
tasks.named('processResources', ProcessResources).configure {
|
||||
var replaceProperties = [
|
||||
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
|
||||
forge_version: forge_version, forge_version_range: forge_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,
|
||||
|
@ -203,26 +123,16 @@ 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,35 +4,17 @@ org.gradle.daemon=false
|
|||
## Environment Properties
|
||||
|
||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||
minecraft_version=1.20.1
|
||||
minecraft_version=1.20.2
|
||||
# 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)
|
||||
# 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
|
||||
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,)
|
||||
|
||||
## Mod Properties
|
||||
|
||||
|
@ -44,7 +26,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.23.1
|
||||
mod_version=1.24.0
|
||||
# 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
|
||||
|
@ -53,3 +35,5 @@ mod_version=1.23.1
|
|||
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.
7
gradlew
vendored
7
gradlew
vendored
|
@ -85,6 +85,9 @@ 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
|
||||
|
||||
|
@ -194,10 +197,6 @@ 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
|
||||
|
|
|
@ -2,8 +2,7 @@ pluginManagement {
|
|||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
name = 'MinecraftForge'
|
||||
url = 'https://maven.minecraftforge.net/'
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
}
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
|
|
|
@ -368,4 +368,9 @@ 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,9 +15,7 @@ import net.minecraft.resources.ResourceKey;
|
|||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
private BattleGui battleGui = null;
|
||||
|
@ -224,7 +222,7 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {
|
||||
public <MSG> void handlePacket(MSG msg, NetworkEvent.Context ctx) {
|
||||
if (msg.getClass() == PacketBattleMessage.class) {
|
||||
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
||||
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
||||
|
@ -435,6 +433,11 @@ 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.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
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;
|
||||
|
||||
public class AttackEventHandler
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ 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;
|
||||
|
@ -13,8 +14,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.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.common.CreativeModeTabRegistry;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -793,6 +794,28 @@ 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.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
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 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>();
|
||||
MinecraftForge.EVENT_BUS.register(battleUpdater);
|
||||
NeoForge.EVENT_BUS.register(battleUpdater);
|
||||
tempIDPair = new EntityIDDimPair();
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ public class BattleManager
|
|||
public void cleanup()
|
||||
{
|
||||
battleUpdater.setRunning(false);
|
||||
MinecraftForge.EVENT_BUS.unregister(battleUpdater);
|
||||
NeoForge.EVENT_BUS.unregister(battleUpdater);
|
||||
battleMap.clear();
|
||||
battleUpdater = null;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.TickEvent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
|
|
@ -5,15 +5,14 @@ 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.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.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
|
||||
{
|
||||
|
@ -173,5 +172,5 @@ public class CommonProxy
|
|||
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
||||
}
|
||||
|
||||
public <MSG> void handlePacket(MSG msg, Supplier<NetworkEvent.Context> ctx) {}
|
||||
public <MSG> void handlePacket(MSG msg, 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.get().msgId()));
|
||||
VanillaRegistries.createLookup().lookupOrThrow(Registries.DAMAGE_TYPE).listElements().forEach(dt -> possibleIgnoreHurtDamageSources.add(dt.value().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.minecraftforge.event.entity.EntityTravelToDimensionEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.neoforged.neoforge.event.entity.EntityTravelToDimensionEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.network.PacketDistributor;
|
||||
|
||||
public class DimensionChangedHandler {
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.entity.living.LivingHurtEvent;
|
||||
|
||||
public class HurtEventHandler {
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.burnedkirby.TurnBasedMinecraft.common;
|
||||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.neoforged.bus.api.SubscribeEvent;
|
||||
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
|
||||
|
||||
public class PlayerJoinEventHandler
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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;
|
||||
|
@ -18,20 +19,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.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 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 org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
@ -39,7 +40,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.23.1";
|
||||
public static final String VERSION = "1.24.0";
|
||||
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/";
|
||||
|
@ -50,7 +51,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(2);
|
||||
private static final String PROTOCOL_VERSION = Integer.toString(3);
|
||||
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
||||
private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
|
||||
.named(HANDLER_ID)
|
||||
|
@ -75,11 +76,15 @@ public class TurnBasedMinecraftMod {
|
|||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
NeoForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
private void firstInit(final FMLCommonSetupEvent event) {
|
||||
proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
|
||||
if (FMLEnvironment.dist.isClient()) {
|
||||
proxy = new ClientProxy();
|
||||
} else {
|
||||
proxy = new CommonProxy();
|
||||
}
|
||||
proxy.setLogger(logger);
|
||||
proxy.initialize();
|
||||
|
||||
|
@ -88,45 +93,45 @@ public class TurnBasedMinecraftMod {
|
|||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleInfo.class,
|
||||
PacketBattleInfo::encode,
|
||||
PacketBattleInfo::decode,
|
||||
PacketBattleInfo::handle);
|
||||
new PacketBattleInfo.Encoder(),
|
||||
new PacketBattleInfo.Decoder(),
|
||||
new PacketBattleInfo.Consumer());
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleRequestInfo.class,
|
||||
PacketBattleRequestInfo::encode,
|
||||
PacketBattleRequestInfo::decode,
|
||||
PacketBattleRequestInfo::handle);
|
||||
new PacketBattleRequestInfo.Encoder(),
|
||||
new PacketBattleRequestInfo.Decoder(),
|
||||
new PacketBattleRequestInfo.Consumer());
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleDecision.class,
|
||||
PacketBattleDecision::encode,
|
||||
PacketBattleDecision::decode,
|
||||
PacketBattleDecision::handle);
|
||||
new PacketBattleDecision.Encoder(),
|
||||
new PacketBattleDecision.Decoder(),
|
||||
new PacketBattleDecision.Consumer());
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketBattleMessage.class,
|
||||
PacketBattleMessage::encode,
|
||||
PacketBattleMessage::decode,
|
||||
PacketBattleMessage::handle);
|
||||
new PacketBattleMessage.Encoder(),
|
||||
new PacketBattleMessage.Decoder(),
|
||||
new PacketBattleMessage.Consumer());
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketGeneralMessage.class,
|
||||
PacketGeneralMessage::encode,
|
||||
PacketGeneralMessage::decode,
|
||||
PacketGeneralMessage::handle);
|
||||
new PacketGeneralMessage.Encoder(),
|
||||
new PacketGeneralMessage.Decoder(),
|
||||
new PacketGeneralMessage.Consumer());
|
||||
HANDLER.registerMessage(
|
||||
packetHandlerID++,
|
||||
PacketEditingMessage.class,
|
||||
PacketEditingMessage::encode,
|
||||
PacketEditingMessage::decode,
|
||||
PacketEditingMessage::handle);
|
||||
new PacketEditingMessage.Encoder(),
|
||||
new PacketEditingMessage.Decoder(),
|
||||
new PacketEditingMessage.Consumer());
|
||||
|
||||
// register event handler(s)
|
||||
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new DimensionChangedHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new HurtEventHandler());
|
||||
NeoForge.EVENT_BUS.register(new AttackEventHandler());
|
||||
NeoForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||
NeoForge.EVENT_BUS.register(new DimensionChangedHandler());
|
||||
NeoForge.EVENT_BUS.register(new HurtEventHandler());
|
||||
|
||||
logger.debug("Init com_burnedkirby_turnbasedminecraft");
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
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.minecraftforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
|
||||
public class PacketBattleDecision
|
||||
{
|
||||
|
@ -25,25 +24,40 @@ public class PacketBattleDecision
|
|||
this.targetIDOrItemID = targetIDOrItemID;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
|
||||
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 PacketBattleDecision decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleDecision pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
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 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.get().getSender();
|
||||
ServerPlayer player = ctx.getSender();
|
||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||
}
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
ctx.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.minecraftforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
|
||||
public class PacketBattleInfo
|
||||
{
|
||||
|
@ -38,7 +38,11 @@ public class PacketBattleInfo
|
|||
this.turnTimerEnabled = turnTimerEnabled;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
|
||||
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) {
|
||||
|
@ -51,8 +55,13 @@ public class PacketBattleInfo
|
|||
buf.writeLong(msg.maxDecisionNanos);
|
||||
buf.writeBoolean(msg.turnTimerEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketBattleInfo decode(FriendlyByteBuf buf) {
|
||||
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);
|
||||
|
@ -68,9 +77,14 @@ public class PacketBattleInfo
|
|||
boolean turnTimerEnabled = buf.readBoolean();
|
||||
return new PacketBattleInfo(sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
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)
|
||||
{
|
||||
return;
|
||||
|
@ -97,6 +111,7 @@ public class PacketBattleInfo
|
|||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ 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;
|
||||
|
||||
|
@ -10,9 +9,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.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
|
||||
public class PacketBattleMessage
|
||||
{
|
||||
|
@ -39,7 +38,8 @@ public class PacketBattleMessage
|
|||
BOW_NO_AMMO(18),
|
||||
CREEPER_WAIT(19),
|
||||
CREEPER_WAIT_FINAL(20),
|
||||
CREEPER_EXPLODE(21);
|
||||
CREEPER_EXPLODE(21),
|
||||
CROSSBOW_NO_AMMO(22);
|
||||
|
||||
private int value;
|
||||
private static Map<Integer, MessageType> map = new HashMap<Integer, MessageType>();
|
||||
|
@ -154,7 +154,11 @@ public class PacketBattleMessage
|
|||
this.custom = custom;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
|
||||
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);
|
||||
|
@ -162,8 +166,13 @@ public class PacketBattleMessage
|
|||
buf.writeInt(pkt.amount);
|
||||
buf.writeUtf(pkt.custom);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketBattleMessage decode(FriendlyByteBuf buf) {
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketBattleMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleMessage(
|
||||
MessageType.valueOf(
|
||||
buf.readInt()),
|
||||
|
@ -173,11 +182,19 @@ public class PacketBattleMessage
|
|||
buf.readInt(),
|
||||
buf.readUtf());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
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.get().setPacketHandled(true);
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
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.minecraftforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
|
||||
public class PacketBattleRequestInfo
|
||||
{
|
||||
|
@ -19,22 +18,37 @@ public class PacketBattleRequestInfo
|
|||
this.battleID = battleID;
|
||||
}
|
||||
|
||||
public static void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleRequestInfo> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
||||
buf.writeInt(pkt.battleID);
|
||||
}
|
||||
|
||||
public static PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
|
||||
return new PacketBattleRequestInfo(buf.readInt());
|
||||
}
|
||||
|
||||
public static void handle(final PacketBattleRequestInfo pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleRequestInfo> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public 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.get());
|
||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx);
|
||||
});
|
||||
ctx.get().setPacketHandled(true);
|
||||
ctx.setPacketHandled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,12 @@ 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.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.neoforged.fml.loading.FMLEnvironment;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PacketEditingMessage
|
||||
{
|
||||
|
@ -88,7 +87,11 @@ public class PacketEditingMessage
|
|||
}
|
||||
}
|
||||
|
||||
public static void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
|
||||
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());
|
||||
|
@ -111,8 +114,13 @@ public class PacketEditingMessage
|
|||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
||||
buf.writeUtf(pkt.entityInfo.customName);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketEditingMessage decode(FriendlyByteBuf buf) {
|
||||
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 {
|
||||
|
@ -135,11 +143,19 @@ public class PacketEditingMessage
|
|||
einfo.customName = buf.readUtf();
|
||||
return new PacketEditingMessage(type, einfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketEditingMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
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.get().setPacketHandled(true);
|
||||
ctx.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.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
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;
|
||||
|
||||
public class PacketGeneralMessage
|
||||
{
|
||||
|
@ -27,18 +27,35 @@ public class PacketGeneralMessage
|
|||
this.message = message;
|
||||
}
|
||||
|
||||
public static void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketGeneralMessage> {
|
||||
public Encoder() {}
|
||||
|
||||
@Override
|
||||
public void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
||||
buf.writeUtf(pkt.message);
|
||||
}
|
||||
}
|
||||
|
||||
public static PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketGeneralMessage> {
|
||||
public Decoder() {}
|
||||
|
||||
@Override
|
||||
public PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
||||
return new PacketGeneralMessage(buf.readUtf());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handle(final PacketGeneralMessage pkt, Supplier<NetworkEvent.Context> ctx) {
|
||||
ctx.get().enqueueWork(() -> {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx));
|
||||
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.get().setPacketHandled(true);
|
||||
ctx.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="forge" #mandatory
|
||||
modId="neoforge" #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
|
||||
versionRange="${neo_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.23.1",
|
||||
"version": "1.24.0",
|
||||
"mcversion": "1.20.1",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
|
|
Loading…
Reference in a new issue