]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Forge 52.0.21 (Minecraft 1.21.1)
authorStephen Seo <seo.disparate@gmail.com>
Tue, 15 Oct 2024 05:41:07 +0000 (14:41 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Tue, 15 Oct 2024 05:41:07 +0000 (14:41 +0900)
Features should be almost the same as the NeoForge branch.

22 files changed:
.forgejo/workflows/build-jar.yaml
build.gradle
gradle.properties
gradle/wrapper/gradle-wrapper.properties
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/BattleMusic.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientConfig.java [new file with mode: 0644]
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientConfigGui.java [new file with mode: 0644]
src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientProxy.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Battle.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/CommonProxy.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Config.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/EntityInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/Utility.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleDecision.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleMessage.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketClientGui.java [new file with mode: 0644]
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketEditingMessage.java
src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketGeneralMessage.java
src/main/resources/assets/com_burnedkirby_turnbasedminecraft/TBM_Config.toml

index dfbfc0312c45e9923ec3a4443243f1ad5e32a792..afff0e24cc81c435e029ec45806aee686ca2aefa 100644 (file)
@@ -25,7 +25,7 @@ jobs:
       - run: cd TurnBasedMinecraftMod && git checkout ${GITHUB_REF_NAME}
       - run: cd TurnBasedMinecraftMod && sed -i '/org.gradle.jvmargs/s/Xmx[0-9]\+m/Xmx1024m/' gradle.properties
       - run: cd TurnBasedMinecraftMod && ./gradlew --console=plain build
-      - run: cd TurnBasedMinecraftMod/build/libs && find . -type f -exec sha256sum '{}' ';' -exec bash -c 'sha256sum {} >> sha256sums.txt' ';' && java --version >> javaVersion.txt && javac --version >> javaVersion.txt
+      - run: cd TurnBasedMinecraftMod/build/libs && find . -regex '.*all.jar$' -exec sha256sum '{}' ';' -exec bash -c 'sha256sum {} >> sha256sums.txt' ';' && java --version >> javaVersion.txt && javac --version >> javaVersion.txt
       - name: Create release and attach jar
         run: |
           curl --fail-with-body -X 'POST' \
index 1b50ba6ee44de91621b5ff0c195424cf300220ac..610193684d6912d301081ed7fd3f178471348110 100644 (file)
@@ -2,34 +2,64 @@ plugins {
     id 'eclipse'
     id 'idea'
     id 'maven-publish'
-    id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
+    id 'net.minecraftforge.gradle' version '[6.0.24,6.2)'
 }
 
 version = mod_version
 group = mod_group_id
-archivesBaseName = "TurnBasedMinecraft-Forge"
 
-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'))
+base {
+    archivesName = "TurnBasedMinecraft-Forge"
+}
+
+// Mojang ships Java 21 to end users in 1.20.5+, so your mod should target Java 21.
+java.toolchain.languageVersion = JavaLanguageVersion.of(21)
+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.
+    // The mappings can be changed at any time and must be in the following format.
+    // Channel:   Version:
+    // official   MCVersion             Official field/method names from Mojang mapping files
+    // parchment  YYYY.MM.DD-MCVersion  Open community-sourced parameter names and javadocs layered on top of official
+    //
+    // You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
+    // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
+    //
+    // Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
+    // Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
+    //
+    // Use non-default mappings at your own risk. They may not always work.
     // Simply re-run your setup task after changing the mappings to update your workspace.
     mappings channel: mapping_channel, version: mapping_version
-    // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
+    
+    // Tell FG to not automtically create the reobf tasks, as we now use Official mappings at runtime, If you don't use them at dev time then you'll have to fix your reobf yourself.
+    reobf = false
 
-    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
+    // When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
+    // In most cases, it is not necessary to enable.
+    // enableEclipsePrepareRuns = true
+    // enableIdeaPrepareRuns = true
 
     // This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
     // It is REQUIRED to be set to true for this template to function.
     // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
     copyIdeResources = true
 
+    // When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
+    // The folder name can be set on a run configuration using the "folderName" property.
+    // By default, the folder name of a run configuration is the name of the Gradle project containing it.
+    // generateRunFolders = true
+
+    // This property enables access transformers for use in development.
+    // They will be applied to the Minecraft artifact.
+    // The access transformer file can be anywhere in the project.
+    // However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
+    // This default location is a best practice to automatically put the file in the right place in the final jar.
+    // See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
+    // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
+
     // Default run configurations.
     // These can be tweaked, removed, or duplicated as needed.
     runs {
@@ -81,6 +111,9 @@ minecraft {
 sourceSets.main.resources { srcDir 'src/generated/resources' }
 
 repositories {
+    // Put repositories for dependencies here
+    // ForgeGradle automatically adds the Forge maven and Maven Central for you
+
     flatDir {
         dir 'libs'
     }
@@ -94,6 +127,24 @@ dependencies {
     // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
     minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
 
+    // Example mod dependency with JEI
+    // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
+    // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
+    // compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
+    // runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"
+
+    // Example mod dependency using a mod jar from ./libs with a flat dir repository
+    // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
+    // The group id is ignored when searching -- in this case, it is "blank"
+    // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}")
+
+    // For more info:
+    // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
+    // http://www.gradle.org/docs/current/userguide/dependency_management.html
+    
+    // Hack fix for now, force jopt-simple to be exactly 5.0.4 because Mojang ships that version, but some transitive dependencies request 6.0+ 
+    implementation('net.sf.jopt-simple:jopt-simple:5.0.4') { version { strictly '5.0.4' } }
+
     implementation 'fr.delthas:javamp3:1.0.3'
 
     implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
@@ -140,7 +191,7 @@ tasks.named('jar', Jar).configure {
     }
 
     // This is the preferred method to reobfuscate your jar file
-    finalizedBy 'reobfJar'
+    //finalizedBy 'reobfJar'
 }
 
 // Reproducible Builds
@@ -162,3 +213,8 @@ sourceSets.each {
     it.output.resourcesDir = dir
     it.java.destinationDirectory = dir
 }
+
+// Ensure "jarJar" is run after "build"
+tasks.named("build").configure {
+    finalizedBy "jarJar"
+}
index efaa773d1f541c4a0c20e3c6d6e33634ae72d479..cae74fcd3ca2b8108d1195b5f82518652e336458 100644 (file)
@@ -1,16 +1,19 @@
-org.gradle.jvmargs=-Xmx4096m
+# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
+# This is required to provide enough memory for the Minecraft decompilation process.
+org.gradle.jvmargs=-Xmx3G
 org.gradle.daemon=false
 
+
 ## Environment Properties
 
 # The Minecraft version must agree with the Forge version to get a valid artifact
-minecraft_version=1.20.4
+minecraft_version=1.21.1
 # The Minecraft version range can use any release version of Minecraft as bounds.
 # Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
 # as they do not follow standard versioning conventions.
-minecraft_version_range=[1.20.4,1.21)
+minecraft_version_range=[1.21.1,1.22)
 # The Forge version must agree with the Minecraft version to get a valid artifact
-forge_version=49.0.19
+forge_version=52.0.21
 # The Forge version range can use any version of Forge as bounds or match the loader version range
 forge_version_range=[0,)
 # The loader version range can only use the major version of Forge/FML as bounds
@@ -32,7 +35,8 @@ loader_version_range=[0,)
 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.4
+mapping_version=1.21.1
+
 
 ## Mod Properties
 
@@ -44,7 +48,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.25.2
+mod_version=1.26.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
index 309b4e18dbc7cb8a7a7d18a3fb70adefb27de513..bb6c19194702fefed855427c04a974a197c0029a 100644 (file)
@@ -1,6 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
 networkTimeout=10000
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
index bccb282c64d92a628d737057d4488adebc94d019..035d87746a8e457b764a3fd4faa4f8df73b0d08b 100644 (file)
@@ -259,7 +259,7 @@ public class BattleMusic
                 
                 // set volume
                 FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
-                gainControl.setValue(volume * 20.0f - 20.0f); // in decibels
+                gainControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
 
                 clip.loop(Clip.LOOP_CONTINUOUSLY);
                 clip.start();
@@ -387,6 +387,16 @@ public class BattleMusic
         return !sillyMusic.isEmpty();
     }
 
+    public static float percentageToDecibels(float percentage) {
+        if (percentage > 1.0F) {
+            return 0.0F;
+        } else if (percentage <= 0.0F) {
+            return Float.NEGATIVE_INFINITY;
+        } else {
+            return (float) (Math.log10(percentage) * 20.0);
+        }
+    }
+
     private class MP3Streamer implements Runnable
     {
         private AtomicBoolean keepPlaying;
@@ -438,7 +448,7 @@ public class BattleMusic
                 sdl.open(audioFormat);
                 {
                     FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
-                    volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
+                    volumeControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
                 }
 
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -536,7 +546,7 @@ public class BattleMusic
                 sdl.open(audioFormat);
                 {
                     FloatControl volumeControl = (FloatControl) sdl.getControl(FloatControl.Type.MASTER_GAIN);
-                    volumeControl.setValue(volume * 20.0f - 20.0f); // in decibels
+                    volumeControl.setValue(BattleMusic.percentageToDecibels(volume)); // in decibels
                 }
 
                 AudioInputStream ais = reader.getAudioInputStream(oggVorbisFile);
diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientConfig.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientConfig.java
new file mode 100644 (file)
index 0000000..20898ec
--- /dev/null
@@ -0,0 +1,68 @@
+package com.burnedkirby.TurnBasedMinecraft.client;
+
+import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
+import net.minecraftforge.common.ForgeConfigSpec;
+import org.apache.commons.lang3.tuple.Pair;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClientConfig {
+    public static final ClientConfig CLIENT;
+    public static final ForgeConfigSpec CLIENT_SPEC;
+
+    static {
+        Pair<ClientConfig, ForgeConfigSpec> pair =
+            new ForgeConfigSpec.Builder().configure(ClientConfig::new);
+        CLIENT = pair.getKey();
+        CLIENT_SPEC = pair.getValue();
+    }
+
+    public final ForgeConfigSpec.ConfigValue<List<? extends String>> battleMusicList;
+    public final ForgeConfigSpec.ConfigValue<List<? extends String>> sillyMusicList;
+    public final ForgeConfigSpec.DoubleValue sillyMusicThreshold;
+    public final ForgeConfigSpec.BooleanValue volumeAffectedByMasterVolume;
+    public final ForgeConfigSpec.BooleanValue volumeAffectedByMusicVolume;
+    public final ForgeConfigSpec.DoubleValue musicVolume;
+
+    ClientConfig(ForgeConfigSpec.Builder builder) {
+        //builder.push("music");
+
+        List<String> battleMusicList = new ArrayList<String>(8);
+        battleMusicList.add("monster");
+        battleMusicList.add("animal");
+        battleMusicList.add("boss");
+        battleMusicList.add("player");
+        this.battleMusicList = builder.comment("What categories of mobs that play \"battle\" music")
+            .translation(TurnBasedMinecraftMod.MODID + ".clientconfig.battle_music_list")
+            .defineList("battleMusicList", battleMusicList, (v) -> v instanceof String);
+
+        List<String> sillyMusicList = new ArrayList<String>(4);
+        sillyMusicList.add("passive");
+        this.sillyMusicList = builder.comment("What categories of mobs that play \"silly\" music")
+            .translation(TurnBasedMinecraftMod.MODID + ".clientconfig.silly_music_list")
+            .defineList("sillyMusicList", sillyMusicList, (v) -> true);
+
+        this.sillyMusicThreshold =
+            builder.comment("Minimum percentage of silly entities in battle to use silly music")
+                .translation(TurnBasedMinecraftMod.MODID + ".clientconfig.silly_percentage")
+                .defineInRange("sillyMusicThreshold", 0.4, 0.0, 1.0);
+
+        this.volumeAffectedByMasterVolume = builder.comment(
+                "If \"true\", music volume will be affected by global Master volume setting")
+            .translation(TurnBasedMinecraftMod.MODID + ".clientconfig.volume_affected_by_master")
+            .define("volumeAffectedByMasterVolume", true);
+
+        this.volumeAffectedByMusicVolume = builder.comment(
+                "If \"true\", music volume will be affected by global Music volume setting")
+            .translation(TurnBasedMinecraftMod.MODID + ".clientconfig.volume_affected_by_volume")
+            .define("volumeAffectedByMusicVolume", true);
+
+        this.musicVolume =
+            builder.comment("Volume of battle/silly music as a percentage between 0.0 and 1.0")
+                .translation(TurnBasedMinecraftMod.MODID + ".clientconfig.music_volume")
+                .defineInRange("musicVolume", 0.7, 0.0, 1.0);
+
+        //builder.pop();
+    }
+}
diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientConfigGui.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/client/ClientConfigGui.java
new file mode 100644 (file)
index 0000000..4857cf1
--- /dev/null
@@ -0,0 +1,263 @@
+package com.burnedkirby.TurnBasedMinecraft.client;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.*;
+import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.network.chat.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ClientConfigGui extends net.minecraft.client.gui.screens.Screen {
+    private final int widget_height = 20;
+    private boolean dirtyFlag;
+    private boolean accepted;
+    private EditBox battleListEditBox = null;
+    private EditBox sillyListEditBox = null;
+    private SliderPercentage sillyMusicThresholdSlider = null;
+    private Checkbox affectedByMasterVolCheckbox = null;
+    private Checkbox affectedByMusicVolCheckbox = null;
+    private SliderPercentage volumeSlider = null;
+
+    public ClientConfigGui() {
+        super(Component.literal("TurnBasedMC Client Config"));
+
+        dirtyFlag = true;
+
+        accepted = false;
+    }
+
+    public void onDirty() {
+        clearWidgets();
+
+        // Initialize GUI elements.
+        int widget_x_offset = 5;
+        int widget_width = this.width / 2 - widget_x_offset * 2;
+        int top_offset = 5;
+
+        addRenderableWidget(
+                new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
+                        widget_width, widget_height, Component.literal("Battle Music Categories"),
+                        font));
+        if (battleListEditBox == null) {
+            battleListEditBox =
+                    new EditBox(font, this.width / 2 + widget_x_offset, top_offset, widget_width,
+                            widget_height, Component.literal("Battle Music Categories Edit Box"));
+        } else {
+            battleListEditBox.setPosition(this.width / 2 + widget_x_offset, top_offset);
+            battleListEditBox.setSize(widget_width, widget_height);
+        }
+        String tempString = "";
+        for (String category : ClientConfig.CLIENT.battleMusicList.get()) {
+            if (tempString.isEmpty()) {
+                tempString = category;
+            } else {
+                tempString += "," + category;
+            }
+        }
+        battleListEditBox.setMaxLength(128);
+        battleListEditBox.setValue(tempString);
+        addRenderableWidget(battleListEditBox);
+
+        top_offset += widget_height;
+
+        addRenderableWidget(
+                new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
+                        widget_width, widget_height, Component.literal("Silly Music Categories"),
+                        font));
+        if (sillyListEditBox == null) {
+            sillyListEditBox =
+                    new EditBox(font, this.width / 2 + widget_x_offset, top_offset, widget_width,
+                            widget_height, Component.literal("Silly Music Categories Edit Box"));
+        } else {
+            sillyListEditBox.setPosition(this.width / 2 + widget_x_offset, top_offset);
+            sillyListEditBox.setSize(widget_width, widget_height);
+        }
+        tempString = "";
+        for (String category : ClientConfig.CLIENT.sillyMusicList.get()) {
+            if (tempString.isEmpty()) {
+                tempString = category;
+            } else {
+                tempString += "," + category;
+            }
+        }
+        sillyListEditBox.setMaxLength(128);
+        sillyListEditBox.setValue(tempString);
+        addRenderableWidget(sillyListEditBox);
+
+        top_offset += widget_height;
+
+        StringWidget stringWidget =
+                new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
+                        widget_width, widget_height, Component.literal("Silly Music Threshold"), font);
+        stringWidget.setTooltip(Tooltip.create(
+                Component.literal("Ratio of minimum of silly mobs in battle to play silly music")));
+        addRenderableWidget(stringWidget);
+        if (sillyMusicThresholdSlider == null) {
+            sillyMusicThresholdSlider =
+                    new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
+                            widget_height, Component.literal("Silly Music Threshold: " +
+                            String.format("%.1f%%", ClientConfig.CLIENT.sillyMusicThreshold.get() * 100.0)),
+                            ClientConfig.CLIENT.sillyMusicThreshold.get(), "Silly Music Threshold: ");
+        } else {
+            sillyMusicThresholdSlider.setPosition(this.width / 2 + widget_x_offset, top_offset);
+            sillyMusicThresholdSlider.setSize(widget_width, widget_height);
+        }
+        addRenderableWidget(sillyMusicThresholdSlider);
+
+        top_offset += widget_height;
+
+        stringWidget =
+                new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
+                        widget_width, widget_height, Component.literal("Affected by Master Vol."),
+                        font);
+        stringWidget.setTooltip(Tooltip.create(
+                Component.literal("If enabled, volume is affected by global master volume.")));
+        addRenderableWidget(stringWidget);
+        if (affectedByMasterVolCheckbox == null) {
+            affectedByMasterVolCheckbox = Checkbox.builder(Component.literal(""), font)
+                    .pos(this.width / 2 + widget_x_offset, top_offset).build();
+        } else {
+            affectedByMasterVolCheckbox.setPosition(this.width / 2 + widget_x_offset,
+                    top_offset);
+        }
+        if ((ClientConfig.CLIENT.volumeAffectedByMasterVolume.get() &&
+                !affectedByMasterVolCheckbox.selected()) ||
+                (!ClientConfig.CLIENT.volumeAffectedByMasterVolume.get() &&
+                        affectedByMasterVolCheckbox.selected())) {
+            affectedByMasterVolCheckbox.onPress();
+        }
+        addRenderableWidget(affectedByMasterVolCheckbox);
+
+        top_offset += widget_height;
+
+        stringWidget =
+                new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
+                        widget_width, widget_height, Component.literal("Affected by Music Vol."), font);
+        stringWidget.setTooltip(Tooltip.create(
+                Component.literal("If enabled, volume is affected by global music volume.")));
+        addRenderableWidget(stringWidget);
+        if (affectedByMusicVolCheckbox == null) {
+            affectedByMusicVolCheckbox = Checkbox.builder(Component.literal(""), font)
+                    .pos(this.width / 2 + widget_x_offset, top_offset).build();
+        } else {
+            affectedByMusicVolCheckbox.setPosition(this.width / 2 + widget_x_offset,
+                    top_offset);
+        }
+        if ((ClientConfig.CLIENT.volumeAffectedByMusicVolume.get() &&
+                !affectedByMusicVolCheckbox.selected()) ||
+                (!ClientConfig.CLIENT.volumeAffectedByMusicVolume.get() &&
+                        affectedByMusicVolCheckbox.selected())) {
+            affectedByMusicVolCheckbox.onPress();
+        }
+        addRenderableWidget(affectedByMusicVolCheckbox);
+
+        top_offset += widget_height;
+
+        stringWidget =
+                new StringWidget(this.width / 2 - widget_width + widget_x_offset, top_offset,
+                        widget_width, widget_height, Component.literal("Music Volume"), font);
+        stringWidget.setTooltip(
+                Tooltip.create(Component.literal("Volume of battle/silly music")));
+        addRenderableWidget(stringWidget);
+        if (volumeSlider == null) {
+            volumeSlider =
+                    new SliderPercentage(this.width / 2 + widget_x_offset, top_offset, widget_width,
+                            widget_height, Component.literal(
+                            "Volume: " + String.format("%.1f%%", ClientConfig.CLIENT.musicVolume.get() * 100.0)),
+                            ClientConfig.CLIENT.musicVolume.get(), "Volume: ");
+        } else {
+            volumeSlider.setPosition(this.width / 2 + widget_x_offset, top_offset);
+            volumeSlider.setSize(widget_width, widget_height);
+        }
+        addRenderableWidget(volumeSlider);
+
+        addRenderableWidget(Button.builder(Component.literal("Cancel"),
+                        (b) -> Minecraft.getInstance().setScreen(null))
+                .bounds(this.width / 2 - widget_width + widget_x_offset,
+                        this.height - widget_height, widget_width, widget_height).build());
+        addRenderableWidget(Button.builder(Component.literal("Accept"), (b) -> {
+            accepted = true;
+        }).bounds(this.width / 2 + widget_x_offset, this.height - widget_height, widget_width,
+                widget_height).build());
+
+        dirtyFlag = false;
+    }
+
+    private void doAccepted() {
+        String temp = battleListEditBox.getValue();
+        {
+            List<String> battleList = new ArrayList<String>();
+            for (String category : temp.split(",")) {
+                battleList.add(category.strip());
+            }
+            ClientConfig.CLIENT.battleMusicList.set(battleList);
+        }
+
+        temp = sillyListEditBox.getValue();
+        {
+            List<String> sillyList = new ArrayList<String>();
+            for (String category : temp.split(",")) {
+                sillyList.add(category.strip());
+            }
+            ClientConfig.CLIENT.sillyMusicList.set(sillyList);
+        }
+
+        ClientConfig.CLIENT.sillyMusicThreshold.set(sillyMusicThresholdSlider.percentage);
+
+        ClientConfig.CLIENT.volumeAffectedByMasterVolume.set(affectedByMasterVolCheckbox.selected());
+
+        ClientConfig.CLIENT.volumeAffectedByMusicVolume.set(affectedByMusicVolCheckbox.selected());
+
+        ClientConfig.CLIENT.musicVolume.set(volumeSlider.percentage);
+
+        ClientConfig.CLIENT_SPEC.save();
+    }
+
+    @Override
+    public boolean isPauseScreen() {
+        return true;
+    }
+
+    @Override
+    public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
+        if (accepted) {
+            doAccepted();
+            Minecraft.getInstance().setScreen(null);
+            return;
+        }
+        if (dirtyFlag) {
+            onDirty();
+        }
+        super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick);
+    }
+
+    @Override
+    public void resize(Minecraft pMinecraft, int pWidth, int pHeight) {
+        dirtyFlag = true;
+        super.resize(pMinecraft, pWidth, pHeight);
+    }
+
+    private static class SliderPercentage extends AbstractSliderButton {
+        private final String messagePrefix;
+        private double percentage;
+
+        public SliderPercentage(int x, int y, int width, int height, Component message, double percentage, String messagePrefix) {
+            super(x, y, width, height, message, percentage);
+            this.percentage = percentage;
+            this.messagePrefix = messagePrefix;
+        }
+
+        @Override
+        protected void updateMessage() {
+            setMessage(
+                    Component.literal(messagePrefix + String.format("%.1f%%", percentage * 100.0)));
+        }
+
+        @Override
+        protected void applyValue() {
+            percentage = value;
+        }
+    }
+}
index 4b5897c4449a2b47765dff3ff066a4b1e2c7a61d..65aa3a800554fa50757328dba1cb49a096582670 100644 (file)
@@ -94,13 +94,27 @@ public class ClientProxy extends CommonProxy {
     @Override
     public void playBattleMusic() {
         Options gs = Minecraft.getInstance().options;
-        battleMusic.playBattle(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
+        float volume = ClientConfig.CLIENT.musicVolume.get().floatValue();
+        if (ClientConfig.CLIENT.volumeAffectedByMasterVolume.get()) {
+            volume *= gs.getSoundSourceVolume(SoundSource.MASTER);
+        }
+        if (ClientConfig.CLIENT.volumeAffectedByMusicVolume.get()) {
+            volume *= gs.getSoundSourceVolume(SoundSource.MUSIC);
+        }
+        battleMusic.playBattle(volume);
     }
 
     @Override
     public void playSillyMusic() {
         Options gs = Minecraft.getInstance().options;
-        battleMusic.playSilly(gs.getSoundSourceVolume(SoundSource.MUSIC) * gs.getSoundSourceVolume(SoundSource.MASTER));
+        float volume = ClientConfig.CLIENT.musicVolume.get().floatValue();
+        if (ClientConfig.CLIENT.volumeAffectedByMasterVolume.get()) {
+            volume *= gs.getSoundSourceVolume(SoundSource.MASTER);
+        }
+        if (ClientConfig.CLIENT.volumeAffectedByMusicVolume.get()) {
+            volume *= gs.getSoundSourceVolume(SoundSource.MUSIC);
+        }
+        battleMusic.playSilly(volume);
     }
 
     @Override
@@ -116,9 +130,9 @@ public class ClientProxy extends CommonProxy {
         if (localBattle == null) {
             return;
         }
-        if (type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
+        if (type == null || type.isEmpty() || ClientConfig.CLIENT.battleMusicList.get().contains(type)) {
             ++battleMusicCount;
-        } else if (getConfig().isSillyMusicType(type)) {
+        } else if (ClientConfig.CLIENT.sillyMusicList.get().contains(type)) {
             ++sillyMusicCount;
         } else {
             ++battleMusicCount;
@@ -132,9 +146,9 @@ public class ClientProxy extends CommonProxy {
             battleMusicCount = 0;
             sillyMusicCount = 0;
             return;
-        } else if (type == null || type.isEmpty() || getConfig().isBattleMusicType(type)) {
+        } else if (type == null || type.isEmpty() || ClientConfig.CLIENT.battleMusicList.get().contains(type)) {
             --battleMusicCount;
-        } else if (getConfig().isSillyMusicType(type)) {
+        } else if (ClientConfig.CLIENT.sillyMusicList.get().contains(type)) {
             --sillyMusicCount;
         } else {
             --battleMusicCount;
@@ -185,7 +199,7 @@ public class ClientProxy extends CommonProxy {
             percentage = 100.0f * (float) sillyMusicCount / (float) (sillyMusicCount + battleMusicCount);
         }
 
-        if (percentage >= (float) getConfig().getSillyMusicThreshold()) {
+        if (percentage >= ClientConfig.CLIENT.sillyMusicThreshold.get().floatValue()) {
             if (battleMusic.isPlaying()) {
                 if (!battleMusic.isPlayingSilly() && battleMusic.hasSillyMusic()) {
                     stopMusic(false);
@@ -1460,4 +1474,9 @@ public class ClientProxy extends CommonProxy {
             }
         }
     }
-}
+
+    @Override
+    public void showClientConfigGui() {
+        Minecraft.getInstance().setScreen(new ClientConfigGui());
+    }
+}
\ No newline at end of file
index f4c17a2dab495d1ce53a6ec52442591b0563a0f7..7fc5ae151ad22c5cb673aafe0473c03aa2135302 100644 (file)
@@ -779,7 +779,7 @@ public class Battle {
                                         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());
-                                        final int randomTimeLeft = random.nextInt(heldItemStack.getItem().getUseDuration(heldItemStack) / 3);
+                                        final int randomTimeLeft = random.nextInt(heldItemStack.getUseDuration((LivingEntity)next.entity) / 3);
                                         if (TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()) {
                                             next.yaw = yawDirection;
                                             next.pitch = pitchDirection;
@@ -1088,7 +1088,7 @@ public class Battle {
                                 debugLog += " null";
                                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_NOTHING.getValue());
                                 break;
-                            } else if (targetItem.isEdible()) {
+                            } else if (Utility.isItemEdible(targetItemStack)) {
                                 debugLog += " food";
                                 sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
                                 final Entity nextEntity = next.entity;
@@ -1097,7 +1097,7 @@ public class Battle {
                             } else {
                                 // then check vanilla foods
                                 final CreativeModeTab foodAndDrinksTab = CreativeModeTabRegistry.getTab(CreativeModeTabs.FOOD_AND_DRINKS.location());
-                                if (foodAndDrinksTab.contains(targetItemStack) && targetItem.isEdible()) {
+                                if (foodAndDrinksTab.contains(targetItemStack) && Utility.isItemEdible(targetItemStack)) {
                                     debugLog += " food";
                                     sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
                                     final Entity nextEntity = next.entity;
index 069e266a8d16b78e726bfdada2250ceef85a1753..1ef973b5e204cec9229c6350806b3c81dda3b682 100644 (file)
@@ -173,4 +173,6 @@ public class CommonProxy
     }
 
     public <MSG> void handlePacket(MSG msg,CustomPayloadEvent.Context ctx) {}
-}
+
+    public void showClientConfigGui() {}
+}
\ No newline at end of file
index 4e27953f04e21624350003543455cb0e20410012..99586448bc479f56bcf88b173b11c2b4927d1cd9 100644 (file)
@@ -37,10 +37,7 @@ public class Config
     private int fleeBadProbability = 35;
     private int minimumHitPercentage = 4;
     private int maxInBattle = 8;
-    private Set<String> musicBattleTypes;
-    private Set<String> musicSillyTypes;
     private boolean freezeCombatantsInBattle = false;
-    private int sillyMusicThreshold = 40;
     private int configVersion = 0;
     private Set<Integer> battleIgnoringPlayers = null;
     private boolean onlyOPsSelfDisableTB = true;
@@ -63,8 +60,6 @@ public class Config
         customEntityInfoMap = new HashMap<String, EntityInfo>();
         ignoreBattleTypes = new HashSet<String>();
         this.logger = logger;
-        musicBattleTypes = new HashSet<String>();
-        musicSillyTypes = new HashSet<String>();
         battleIgnoringPlayers = new HashSet<Integer>();
         possibleIgnoreHurtDamageSources = new HashSet<String>();
         ignoreHurtDamageSources = new HashSet<String>();
@@ -156,56 +151,6 @@ public class Config
     {
         CommentedFileConfig conf = getConfigObj(configFile);
 
-        // client config
-        try {
-            Collection<String> battle_music_categories = conf.get("client_config.battle_music");
-            if (battle_music_categories != null) {
-                for (String category : battle_music_categories) {
-                    musicBattleTypes.add(category);
-                }
-            } else {
-                musicBattleTypes.add("monster");
-                musicBattleTypes.add("animal");
-                musicBattleTypes.add("boss");
-                musicBattleTypes.add("player");
-                logNotFound("client_config.battle_music");
-            }
-        } catch (ClassCastException e) {
-            musicBattleTypes.add("monster");
-            musicBattleTypes.add("animal");
-            musicBattleTypes.add("boss");
-            musicBattleTypes.add("player");
-            logTOMLInvalidValue("client_config.battle_music");
-        }
-
-        try {
-            Collection<String> silly_music_categories = conf.get("client_config.silly_music");
-            if (silly_music_categories != null) {
-                for (String category : silly_music_categories) {
-                    musicSillyTypes.add(category);
-                }
-            } else {
-                musicSillyTypes.add("passive");
-                logNotFound("client_config.silly_music");
-            }
-        } catch (ClassCastException e) {
-            musicSillyTypes.add("passive");
-            logTOMLInvalidValue("client_config.silly_music");
-        }
-
-        try {
-            OptionalInt silly_music_threshold = conf.getOptionalInt("client_config.silly_music_threshold");
-            if(silly_music_threshold.isPresent()) {
-                this.sillyMusicThreshold = silly_music_threshold.getAsInt();
-            } else {
-                this.sillyMusicThreshold = 40;
-                logNotFound("client_config.silly_music_threshold", "40");
-            }
-        } catch (ClassCastException e) {
-            this.sillyMusicThreshold = 40;
-            logTOMLInvalidValue("client_config.silly_music_threshold", "40");
-        }
-
         // server_config
         try {
             OptionalInt leave_battle_cooldown = conf.getOptionalInt("server_config.leave_battle_cooldown");
@@ -1328,16 +1273,6 @@ public class Config
         this.maxInBattle = maxInBattle;
     }
 
-    public boolean isBattleMusicType(String type)
-    {
-        return musicBattleTypes.contains(type.toLowerCase());
-    }
-
-    public boolean isSillyMusicType(String type)
-    {
-        return musicSillyTypes.contains(type.toLowerCase());
-    }
-
     public boolean isFreezeCombatantsEnabled()
     {
         return freezeCombatantsInBattle;
@@ -1347,11 +1282,6 @@ public class Config
         freezeCombatantsInBattle = enabled;
     }
 
-    public int getSillyMusicThreshold()
-    {
-        return sillyMusicThreshold;
-    }
-
     public int getConfigVersion()
     {
         return configVersion;
index 57bd4148006e5c18684adbd1050f1105af49fc08..943af5d87d27795f6569f6fcee464c64447f2c3c 100644 (file)
@@ -276,7 +276,7 @@ public class EntityInfo
         {
             if(this == FIRE)
             {
-                entity.setSecondsOnFire(duration / 20);
+                entity.setRemainingFireTicks(duration / 2);
                 return;
             }
             else if(this != UNKNOWN)
index 96e065fd41adce1e7f30528244b5ab57fa55b596..f35e9d9c9bc9cd4753a9b7b1c90bfc453bf5235e 100644 (file)
@@ -1,5 +1,6 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
+import com.burnedkirby.TurnBasedMinecraft.client.ClientConfig;
 import com.burnedkirby.TurnBasedMinecraft.client.ClientProxy;
 import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
 import com.mojang.brigadier.LiteralMessage;
@@ -25,6 +26,7 @@ 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.config.ModConfig;
 import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
 import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
@@ -48,8 +50,8 @@ public class TurnBasedMinecraftMod {
     public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
     public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
 
-    private static final Integer PROTOCOL_VERSION = 3;
-    private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
+    private static final Integer PROTOCOL_VERSION = 4;
+    private static final ResourceLocation HANDLER_ID = ResourceLocation.fromNamespaceAndPath(MODID, "main_channel");
 
     private static final SimpleChannel HANDLER = ChannelBuilder
         .named(HANDLER_ID)
@@ -69,12 +71,14 @@ public class TurnBasedMinecraftMod {
 
     public static CommonProxy proxy;
 
-    public TurnBasedMinecraftMod() {
-        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::firstInit);
-        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
-        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
+    public TurnBasedMinecraftMod(FMLJavaModLoadingContext ctx) {
+        ctx.getModEventBus().addListener(this::firstInit);
+        ctx.getModEventBus().addListener(this::secondInitClient);
+        ctx.getModEventBus().addListener(this::secondInitServer);
 
         MinecraftForge.EVENT_BUS.register(this);
+
+        ctx.registerConfig(ModConfig.Type.CLIENT, ClientConfig.CLIENT_SPEC);
     }
 
     private void firstInit(final FMLCommonSetupEvent event) {
@@ -113,6 +117,11 @@ public class TurnBasedMinecraftMod {
             .decoder(new PacketEditingMessage.Decoder())
             .consumerNetworkThread(new PacketEditingMessage.Consumer())
             .add();
+        HANDLER.messageBuilder(PacketClientGui.class, NetworkDirection.PLAY_TO_CLIENT)
+            .encoder(new PacketClientGui.Encoder())
+            .decoder(new PacketClientGui.Decoder())
+            .consumerNetworkThread(new PacketClientGui.Consumer())
+            .add();
 
         // register event handler(s)
         MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
@@ -1683,6 +1692,15 @@ public class TurnBasedMinecraftMod {
                         return 1;
                     })))
         );
+
+        // tbm-client-edit
+        event.getDispatcher().register(
+            Commands.literal("tbm-client-edit").executes(c -> {
+                ServerPlayer player = c.getSource().getPlayerOrException();
+                getHandler().send(new PacketClientGui(), PacketDistributor.PLAYER.with(player));
+                return 1;
+            })
+        );
     }
 
     @SubscribeEvent
index b2ccd6ea4f976a87601dafd54bd2924354cd3817..d5cd96e1ca11055d857e5282f6da1fefd6848832 100644 (file)
@@ -1,11 +1,13 @@
 package com.burnedkirby.TurnBasedMinecraft.common;
 
+import net.minecraft.core.component.DataComponents;
 import net.minecraft.core.registries.Registries;
 import net.minecraft.resources.ResourceKey;
 import net.minecraft.resources.ResourceLocation;
 import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.item.ArrowItem;
+import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.level.Level;
 
 public class Utility
@@ -59,7 +61,11 @@ public class Utility
     }
 
     public static ResourceKey<Level> deserializeDimension(String dimString) {
-        ResourceLocation dimRes = new ResourceLocation(dimString);
+        ResourceLocation dimRes = ResourceLocation.parse(dimString);
         return ResourceKey.create(Registries.DIMENSION, dimRes);
     }
+
+    public static boolean isItemEdible(ItemStack itemStack) {
+        return itemStack.get(DataComponents.FOOD) != null;
+    }
 }
index 9b66356763ca191d0e61ed27c397d1f0968fc5ca..3c7b1ed8d1790a724aa466de6074ea8ecff6d00a 100644 (file)
@@ -1,16 +1,15 @@
 package com.burnedkirby.TurnBasedMinecraft.common.networking;
 
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
 import com.burnedkirby.TurnBasedMinecraft.common.Battle;
-import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
 import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
-
+import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
+import net.minecraft.network.RegistryFriendlyByteBuf;
 import net.minecraft.server.level.ServerPlayer;
-import net.minecraft.network.FriendlyByteBuf;
 import net.minecraftforge.event.network.CustomPayloadEvent;
 
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
 public class PacketBattleDecision
 {
     private int battleID;
@@ -26,22 +25,22 @@ public class PacketBattleDecision
         this.targetIDOrItemID = targetIDOrItemID;
     }
 
-    public static class Encoder implements BiConsumer<PacketBattleDecision, FriendlyByteBuf> {
+    public static class Encoder implements BiConsumer<PacketBattleDecision, RegistryFriendlyByteBuf> {
         public Encoder() {}
 
         @Override
-        public void accept(PacketBattleDecision pkt, FriendlyByteBuf buf) {
+        public void accept(PacketBattleDecision pkt, RegistryFriendlyByteBuf buf) {
             buf.writeInt(pkt.battleID);
             buf.writeInt(pkt.decision.getValue());
             buf.writeInt(pkt.targetIDOrItemID);
         }
     }
 
-    public static class Decoder implements Function<FriendlyByteBuf, PacketBattleDecision> {
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleDecision> {
         public Decoder() {}
 
         @Override
-        public PacketBattleDecision apply(FriendlyByteBuf buf) {
+        public PacketBattleDecision apply(RegistryFriendlyByteBuf buf) {
             return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
         }
     }
index fa6e136d74adaa19525e707f2201849ecbc9d706..c97c7993027e675607c6da1fbbfa2e7ec7ec909b 100644 (file)
@@ -1,17 +1,16 @@
 package com.burnedkirby.TurnBasedMinecraft.common.networking;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
-
 import net.minecraft.client.Minecraft;
+import net.minecraft.network.RegistryFriendlyByteBuf;
 import net.minecraft.world.entity.Entity;
-import net.minecraft.network.FriendlyByteBuf;
 import net.minecraftforge.event.network.CustomPayloadEvent;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
 public class PacketBattleInfo
 {
     private Collection<Integer> sideA;
@@ -39,11 +38,11 @@ public class PacketBattleInfo
         this.turnTimerEnabled = turnTimerEnabled;
     }
 
-    public static class Encoder implements BiConsumer<PacketBattleInfo, FriendlyByteBuf> {
+    public static class Encoder implements BiConsumer<PacketBattleInfo, RegistryFriendlyByteBuf> {
         public Encoder() {}
 
         @Override
-        public void accept(PacketBattleInfo msg, FriendlyByteBuf buf) {
+        public void accept(PacketBattleInfo msg, RegistryFriendlyByteBuf buf) {
             buf.writeInt(msg.sideA.size());
             buf.writeInt(msg.sideB.size());
             for(Integer id : msg.sideA) {
@@ -58,11 +57,11 @@ public class PacketBattleInfo
         }
     }
 
-    public static class Decoder implements Function<FriendlyByteBuf, PacketBattleInfo> {
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleInfo> {
         public Decoder() {}
 
         @Override
-        public PacketBattleInfo apply(FriendlyByteBuf buf) {
+        public PacketBattleInfo apply(RegistryFriendlyByteBuf buf) {
             int sideACount = buf.readInt();
             int sideBCount = buf.readInt();
             Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
index 52dfee4d9ef6e3950666a2611038feee9ecab150..9e339e59d229328f15bc0ea4d3a99023c5c07980 100644 (file)
@@ -1,20 +1,19 @@
 package com.burnedkirby.TurnBasedMinecraft.common.networking;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
-
 import com.burnedkirby.TurnBasedMinecraft.common.Utility;
-import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.RegistryFriendlyByteBuf;
 import net.minecraft.resources.ResourceKey;
 import net.minecraft.world.level.Level;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.event.network.CustomPayloadEvent;
 import net.minecraftforge.fml.DistExecutor;
 
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
 public class PacketBattleMessage
 {
     public enum MessageType
@@ -156,11 +155,11 @@ public class PacketBattleMessage
         this.custom = custom;
     }
 
-    public static class Encoder implements BiConsumer<PacketBattleMessage, FriendlyByteBuf> {
+    public static class Encoder implements BiConsumer<PacketBattleMessage, RegistryFriendlyByteBuf> {
         public Encoder() {}
 
         @Override
-        public void accept(PacketBattleMessage pkt, FriendlyByteBuf buf) {
+        public void accept(PacketBattleMessage pkt, RegistryFriendlyByteBuf buf) {
             buf.writeInt(pkt.messageType.getValue());
             buf.writeInt(pkt.entityIDFrom);
             buf.writeInt(pkt.entityIDTo);
@@ -170,11 +169,11 @@ public class PacketBattleMessage
         }
     }
 
-    public static class Decoder implements Function<FriendlyByteBuf, PacketBattleMessage> {
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleMessage> {
         public Decoder() {}
 
         @Override
-        public PacketBattleMessage apply(FriendlyByteBuf buf) {
+        public PacketBattleMessage apply(RegistryFriendlyByteBuf buf) {
             return new PacketBattleMessage(
                 MessageType.valueOf(
                     buf.readInt()),
index 0fa9ff61874ecca9e186a090aa0aeeb13f038f3c..b21175d3125d525884d7679b570fb84c54cf92ec 100644 (file)
@@ -1,14 +1,13 @@
 package com.burnedkirby.TurnBasedMinecraft.common.networking;
 
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
 import com.burnedkirby.TurnBasedMinecraft.common.Battle;
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
-
-import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.RegistryFriendlyByteBuf;
 import net.minecraftforge.event.network.CustomPayloadEvent;
 
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
 public class PacketBattleRequestInfo
 {
     private int battleID;
@@ -20,20 +19,20 @@ public class PacketBattleRequestInfo
         this.battleID = battleID;
     }
 
-    public static class Encoder implements BiConsumer<PacketBattleRequestInfo, FriendlyByteBuf> {
+    public static class Encoder implements BiConsumer<PacketBattleRequestInfo, RegistryFriendlyByteBuf> {
         public Encoder() {}
 
         @Override
-        public void accept(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
+        public void accept(PacketBattleRequestInfo pkt, RegistryFriendlyByteBuf buf) {
             buf.writeInt(pkt.battleID);
         }
     }
 
-    public static class Decoder implements Function<FriendlyByteBuf, PacketBattleRequestInfo> {
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketBattleRequestInfo> {
         public Decoder() {}
 
         @Override
-        public PacketBattleRequestInfo apply(FriendlyByteBuf buf) {
+        public PacketBattleRequestInfo apply(RegistryFriendlyByteBuf buf) {
             return new PacketBattleRequestInfo(buf.readInt());
         }
     }
diff --git a/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketClientGui.java b/src/main/java/com/burnedkirby/TurnBasedMinecraft/common/networking/PacketClientGui.java
new file mode 100644 (file)
index 0000000..0d66b9d
--- /dev/null
@@ -0,0 +1,52 @@
+package com.burnedkirby.TurnBasedMinecraft.common.networking;
+
+import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
+import net.minecraft.network.RegistryFriendlyByteBuf;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.event.network.CustomPayloadEvent;
+import net.minecraftforge.fml.DistExecutor;
+
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
+public class PacketClientGui {
+    int reserved;
+
+    public PacketClientGui() {
+        reserved = 0;
+    }
+
+    public PacketClientGui(int reserved) {
+        this.reserved = reserved;
+    }
+
+    public static class Encoder implements BiConsumer<PacketClientGui, RegistryFriendlyByteBuf> {
+        public Encoder() {}
+
+        @Override
+        public void accept(PacketClientGui pkt, RegistryFriendlyByteBuf buf) {
+            buf.writeInt(pkt.reserved);
+        }
+    }
+
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketClientGui> {
+        public Decoder() {}
+
+        @Override
+        public PacketClientGui apply(RegistryFriendlyByteBuf registryFriendlyByteBuf) {
+            return new PacketClientGui(registryFriendlyByteBuf.readInt());
+        }
+    }
+
+    public static class Consumer implements BiConsumer<PacketClientGui, CustomPayloadEvent.Context> {
+        public Consumer() {}
+
+        @Override
+        public void accept(PacketClientGui pkt, CustomPayloadEvent.Context ctx) {
+            ctx.enqueueWork(() -> {
+                DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> TurnBasedMinecraftMod.proxy.showClientConfigGui());
+            });
+            ctx.setPacketHandled(true);
+        }
+    }
+}
index 711efe992a0aaf8c40e434ac45e99f4b63f8da0c..e339afb0124560e1e4bbfe932a4a781e25f60a49 100644 (file)
@@ -2,7 +2,7 @@ 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.minecraft.network.RegistryFriendlyByteBuf;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.event.network.CustomPayloadEvent;
 import net.minecraftforge.fml.DistExecutor;
@@ -89,11 +89,11 @@ public class PacketEditingMessage
         }
     }
 
-    public static class Encoder implements BiConsumer<PacketEditingMessage, FriendlyByteBuf> {
+    public static class Encoder implements BiConsumer<PacketEditingMessage, RegistryFriendlyByteBuf> {
         public Encoder() {}
 
         @Override
-        public void accept(PacketEditingMessage pkt, FriendlyByteBuf buf) {
+        public void accept(PacketEditingMessage pkt, RegistryFriendlyByteBuf buf) {
             buf.writeInt(pkt.type.getValue());
             if(pkt.entityInfo.classType != null) {
                 buf.writeUtf(pkt.entityInfo.classType.getName());
@@ -118,11 +118,11 @@ public class PacketEditingMessage
         }
     }
 
-    public static class Decoder implements Function<FriendlyByteBuf, PacketEditingMessage> {
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketEditingMessage> {
         public Decoder() {}
 
         @Override
-        public PacketEditingMessage apply(FriendlyByteBuf buf) {
+        public PacketEditingMessage apply(RegistryFriendlyByteBuf buf) {
             Type type = Type.valueOf(buf.readInt());
             EntityInfo einfo = new EntityInfo();
             try {
index 550be99b3e4c9dfa9e229907d90a9f094cf6cb6f..95faac9432208e17debd4283a953e0f22b739aed 100644 (file)
@@ -1,15 +1,14 @@
 package com.burnedkirby.TurnBasedMinecraft.common.networking;
 
-import java.util.function.BiConsumer;
-import java.util.function.Function;
-
 import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
-
-import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.network.RegistryFriendlyByteBuf;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.event.network.CustomPayloadEvent;
 import net.minecraftforge.fml.DistExecutor;
 
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
 public class PacketGeneralMessage
 {
     String message;
@@ -28,20 +27,20 @@ public class PacketGeneralMessage
         this.message = message;
     }
 
-    public static class Encoder implements BiConsumer<PacketGeneralMessage, FriendlyByteBuf> {
+    public static class Encoder implements BiConsumer<PacketGeneralMessage, RegistryFriendlyByteBuf> {
         public Encoder() {}
 
         @Override
-        public void accept(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
+        public void accept(PacketGeneralMessage pkt, RegistryFriendlyByteBuf buf) {
             buf.writeUtf(pkt.message);
         }
     }
 
-    public static class Decoder implements Function<FriendlyByteBuf, PacketGeneralMessage> {
+    public static class Decoder implements Function<RegistryFriendlyByteBuf, PacketGeneralMessage> {
         public Decoder() {}
 
         @Override
-        public PacketGeneralMessage apply(FriendlyByteBuf buf) {
+        public PacketGeneralMessage apply(RegistryFriendlyByteBuf buf) {
             return new PacketGeneralMessage(buf.readUtf());
         }
     }
index dbdae74cf8f2300eb941a0cf2a13748703008c1e..622730bef3e59ca69515ed37776c3eb1a614b5e3 100644 (file)
@@ -1,21 +1,13 @@
 # Please do not change this option, the mod uses this to keep track of what new
 # changes to add to the config.
-version = 10
+version = 11
 # Change this to "true" if you want the config to never be replaced. This means
 # that you will not get new mob listings from future updates unless this remains
 # "false"!
 do_not_overwrite = false
 
-[client_config]
-
-# What categories play this type of music (battle_music). Unknown categories will default to this type.
-battle_music = ["monster", "animal", "boss", "player"]
-# What categories play this type of music (silly_music).
-silly_music = ["passive"]
-
-# Minimum percentage of silly entities in battle to use silly music.
-silly_music_threshold = 40
 
+# Note that client config is no longer stored here but rather in the settings.
 
 [server_config]
 
@@ -138,6 +130,37 @@ decision_defend_probability = 0
 decision_flee_probability = 0
 ignore_battle = false
 
+[[server_config.entity]]
+name = "net.minecraft.world.entity.monster.Bogged"
+attack_power = 3
+attack_probability = 75
+attack_variance = 1
+attack_effect = "poison"
+attack_effect_probability = 50
+defense_damage = 0
+evasion = 10
+category = "monster"
+speed = 20
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+ignore_battle = false
+
+[[server_config.entity]]
+name = "net.minecraft.world.entity.monster.breeze.Breeze"
+attack_power = 1
+attack_probability = 50
+attack_effect = "unknown"
+attack_variance = 0
+defense_damage = 0
+evasion = 45
+category = "monster"
+speed = 45
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+ignore_battle = false
+
 [[server_config.entity]]
 name = "net.minecraft.world.entity.monster.CaveSpider"
 attack_power = 2
@@ -684,6 +707,21 @@ decision_defend_probability = 0
 decision_flee_probability = 100
 ignore_battle = false
 
+[[server_config.entity]]
+name = "net.minecraft.world.entity.animal.armadillo.Armadillo"
+attack_power = 0
+attack_probability = 0
+attack_variance = 0
+attack_effect = "unknown"
+defense_damage = 0
+evasion = 10
+category = "passive"
+speed = 20
+decision_attack_probability = 0
+decision_defend_probability = 50
+decision_flee_probability = 50
+ignore_battle = false
+
 [[server_config.entity]]
 name = "net.minecraft.world.entity.animal.axolotl.Axolotl"
 attack_power = 2