Compare commits

..

No commits in common. "b20f8314d0d90c2ee4e2e4075da5399055e17747" and "be99607226752245f8f28129e1592ee164769f31" have entirely different histories.

15 changed files with 260 additions and 299 deletions

1
.gitignore vendored
View file

@ -22,4 +22,3 @@ eclipse
run
logs/
runs/

View file

@ -1,19 +1,5 @@
# Upcoming changes
# Version Forge-1.25.1
Add icon for mod in Mod list description.
Update for Forge 49.0.19.
Works on Forge Minecraft 1.20.4.
# Version NeoForge-1.25.1
Add icon for mod in Mod list description.
Update for NeoForge 20.4.108-beta.
Works on NeoForge Minecraft 1.20.4.
# Version NeoForge-1.25.0
Add new dependency `j-ogg-vorbis`.

View file

@ -71,7 +71,7 @@ configured for them.)
Simply invoke `./gradlew build` in the mod directory and after some time the
finished jar will be saved at
`build/libs/TurnBasedMinecraft-Forge-1.25.1-all.jar`
`build/libs/TurnBasedMinecraft-Forge-1.25.0-all.jar`
# Reproducibility

View file

@ -4,32 +4,6 @@ Starting with version 1.24.0 of this mod, this file will list what version of
Java was used to compile the jars. In theory, using the same version of Java
should result in an identical jar due to reproducible builds.
## Forge 1.25.1
$ java --version
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+8)
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
$ javac --version
javac 17.0.9
$ sha256sum build/libs/TurnBasedMinecraft-Forge-1.25.1-all.jar
33711947eed8b24fa7fd65d36ecdb6ed78e144af8d7fff6e1bfa304cfe4a1d3d build/libs/TurnBasedMinecraft-Forge-1.25.1-all.jar
## NeoForge 1.25.1
$ java --version
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment (build 17.0.9+8)
OpenJDK 64-Bit Server VM (build 17.0.9+8, mixed mode)
$ javac --version
javac 17.0.9
$ sha256sum build/libs/TurnBasedMinecraft-NeoForge-1.25.1-all.jar
b0ec086c356c4d3662dcea4bdd9aeb2b0786e4ef40e061599e81b529746e01ea build/libs/TurnBasedMinecraft-NeoForge-1.25.1-all.jar
## NeoForge 1.25.0
$ java --version

View file

@ -5,8 +5,8 @@ plugins {
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
}
version = mod_version
group = mod_group_id
version = "1.25.0"
group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft-Forge"
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@ -33,8 +33,48 @@ minecraft {
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
// applies to all the run configs below
configureEach {
client {
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
}
}
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'REGISTRIES'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
mods {
TurnBasedMinecraftMod {
source sourceSets.main
}
}
}
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
@ -48,31 +88,33 @@ minecraft {
// 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'
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', mod_id
}
property 'forge.enabledGameTestNamespaces', 'TurnBasedMinecraftMod'
server {
property 'forge.enabledGameTestNamespaces', mod_id
args '--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 {
property 'forge.enabledGameTestNamespaces', mod_id
mods {
TurnBasedMinecraftMod {
source sourceSets.main
}
}
}
data {
// example of overriding the workingDirectory set in configureEach above
workingDirectory project.file('run-data')
workingDirectory project.file('run')
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
// 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
}
}
}
}
}
@ -80,6 +122,22 @@ minecraft {
// 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'
// }
//}
repositories {
flatDir {
dir 'libs'
@ -87,13 +145,23 @@ repositories {
}
dependencies {
// Specify the version of Minecraft to use.
// Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact.
// The "userdev" classifier will be requested and setup by ForgeGradle.
// If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"],
// then special handling is done to allow a setup of a vanilla dependency without the use of an external repository.
// 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}"
// 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
// 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')
implementation 'fr.delthas:javamp3:1.0.3'
implementation 'com.github.stephengold:j-ogg-vorbis:1.0.4'
@ -126,21 +194,22 @@ tasks.named('processResources', ProcessResources).configure {
}
}
// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {
// Example for how to get properties into the manifest for reading by the runtime..
jar {
archiveClassifier = 'slim'
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Vendor' : mod_authors,
'Specification-Version' : '1', // We are version 1 of ourselves
'Implementation-Title' : "TurnBasedMinecraftMod",
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors
"Specification-Title": "TurnBasedMinecraftMod",
"Specification-Vendor": "TurnBasedMinecraftMod_BK",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": "TurnBasedMinecraftMod",
"Implementation-Version": "${version}",
"Implementation-Vendor" :"TurnBasedMinecraftMod_BK",
// Do not place timestamp for the sake of reproducible builds
// "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
// "ContainedDeps": "javamp3-1.0.3.jar"
])
}
// This is the preferred method to reobfuscate your jar file
finalizedBy 'reobfJar'
}
// Reproducible Builds
@ -149,16 +218,24 @@ tasks.withType(AbstractArchiveTask).configureEach {
reproducibleFileOrder = true
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
// Merge the resources and classes into the same directory.
// This is done because java expects modules to be in a single directory.
// And if we have it in multiple we have to do performance intensive hacks like having the UnionFileSystem
// This will eventually be migrated to ForgeGradle so modders don't need to manually do it. But that is later.
sourceSets.each {
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
}
// 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
// Note you'll need to add a repository here
//def reobfFile = file("$buildDir/reobfJar/output.jar")
//def reobfArtifact = artifacts.add('default', reobfFile) {
// type 'jar'
// builtBy 'reobfJar'
//}
//publishing {
// publications {
// mavenJava(MavenPublication) {
// artifact reobfArtifact
// }
// }
// repositories {
// maven {
// url "file:///${project.projectDir}/mcmodsrepo"
// }
// }
//}

View file

@ -4,17 +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.4
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.4,1.21)
minecraft_version_range=[1.20.2,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=49.0.19
forge_version=48.1.0
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[0,)
forge_version_range=[48,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[0,)
loader_version_range=[48,)
# 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.
@ -32,7 +32,7 @@ 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.20.2
## Mod Properties
@ -44,11 +44,11 @@ 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.1
mod_version=1.25.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
mod_group_id=com.burnedkirby.TurnBasedMinecraft
#mod_group_id=com.example.examplemod
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
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.

View file

@ -150,11 +150,11 @@ public class BattleGui extends Screen {
.getSideAEntrySet()) {
if (e.getValue().entity != null) {
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), true, (button) -> {
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
}));
} else {
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
}));
}
y += 20;
@ -168,11 +168,11 @@ public class BattleGui extends Screen {
.getSideBEntrySet()) {
if (e.getValue().entity != null) {
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), false, (button) -> {
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
}));
} else {
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
}));
}
y += 20;
@ -202,8 +202,8 @@ public class BattleGui extends Screen {
case SWITCH_ITEM:
info = "To which item will you switch to?";
for (int i = 0; i < 9; ++i) {
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
itemButtonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
}));
}
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
@ -213,8 +213,8 @@ public class BattleGui extends Screen {
case USE_ITEM:
info = "Which item will you use?";
for (int i = 0; i < 9; ++i) {
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
itemButtonActionEvent(button, ButtonAction.DO_USE_ITEM);
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
}));
}
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
@ -269,6 +269,10 @@ public class BattleGui extends Screen {
drawString(guiGraphics, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
}
@Override
public void renderBackground(GuiGraphics p_283688_, int p_299421_, int p_298679_, float p_297268_) {
}
protected void buttonActionEvent(AbstractButton button, ButtonAction action) {
switch (action) {
case ATTACK:
@ -290,8 +294,14 @@ public class BattleGui extends Screen {
setState(MenuState.WAITING);
break;
case ATTACK_TARGET:
// Invalid but set to main menu anyways.
setState(MenuState.MAIN_MENU);
if (button instanceof EntitySelectionButton) {
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.ATTACK, ((EntitySelectionButton) button).getID()),
PacketDistributor.SERVER.noArg());
setState(MenuState.WAITING);
} else {
setState(MenuState.MAIN_MENU);
}
break;
case SWITCH_HELD_ITEM:
setState(MenuState.SWITCH_ITEM);
@ -303,47 +313,28 @@ public class BattleGui extends Screen {
setState(MenuState.MAIN_MENU);
break;
case DO_ITEM_SWITCH:
// Invalid but set to main menu anyways.
setState(MenuState.MAIN_MENU);
break;
case DO_USE_ITEM:
// Invalid, but set menu to main menu anyways.
setState(MenuState.MAIN_MENU);
break;
}
}
protected void entityButtonActionEvent(EntitySelectionButton button, ButtonAction action) {
if (action.equals(ButtonAction.ATTACK_TARGET)) {
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.ATTACK, button.getID()),
PacketDistributor.SERVER.noArg());
setState(MenuState.WAITING);
} else {
setState(MenuState.MAIN_MENU);
}
}
protected void itemButtonActionEvent(ItemSelectionButton button, ButtonAction action) {
switch (action) {
case DO_ITEM_SWITCH:
TurnBasedMinecraftMod.getHandler().send(
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.SWITCH_ITEM, button.getID()),
if (button instanceof ItemSelectionButton) {
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID()),
PacketDistributor.SERVER.noArg());
if (button.getID() >= 0 && button.getID() < 9) {
Minecraft.getInstance().player.getInventory().selected = button.getID();
if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) {
Minecraft.getInstance().player.getInventory().selected = ((ItemSelectionButton) button).getID();
}
setState(MenuState.WAITING);
break;
case DO_USE_ITEM:
TurnBasedMinecraftMod.getHandler().send(
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.USE_ITEM, button.getID()),
} else {
setState(MenuState.MAIN_MENU);
}
break;
case DO_USE_ITEM:
if (button instanceof ItemSelectionButton) {
TurnBasedMinecraftMod.getHandler().send(new PacketBattleDecision(
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.USE_ITEM, ((ItemSelectionButton) button).getID()),
PacketDistributor.SERVER.noArg());
setState(MenuState.WAITING);
break;
default:
} else {
setState(MenuState.MAIN_MENU);
break;
}
break;
}
}
@ -360,11 +351,6 @@ public class BattleGui extends Screen {
return false; // TODO verify return value
}
@Override
public void renderBackground(GuiGraphics p_283688_, int p_299421_, int p_298679_, float p_297268_) {
// Left blank to not render background.
}
@Override
public boolean keyReleased(int a, int b, int c) {
if (getMinecraft().player.isCreative()) {

View file

@ -1,49 +1,34 @@
package com.burnedkirby.TurnBasedMinecraft.client;
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
public class EntitySelectionButton implements Renderable, GuiEventListener, NarratableEntry {
private int x;
private int y;
private int width;
private int height;
private boolean focused;
private Button nestedButton;
TBMEntityButtonPress onPress;
public class EntitySelectionButton extends AbstractButton {
TBMButtonPress onPress;
private int entityID;
private boolean isSideA;
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
this.x = x;
this.y = y;
this.width = widthIn;
this.height = heightIn;
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMButtonPress onPress) {
super(x, y, widthIn, heightIn, Component.literal(buttonText));
this.onPress = onPress;
this.entityID = entityID;
this.isSideA = isSideA;
this.nestedButton = Button.builder(Component.literal(buttonText), (unused) -> {}).pos(x, y).size(widthIn, heightIn).build();
}
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
this.x = x;
this.y = y;
this.width = widthIn;
this.height = heightIn;
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMButtonPress onPress) {
super(x, y, widthIn, heightIn, buttonTextComponent);
this.onPress = onPress;
this.entityID = entityID;
this.isSideA = isSideA;
this.nestedButton = Button.builder(buttonTextComponent, (unused) -> {}).pos(x, y).size(widthIn, heightIn).build();
}
public int getID() {
@ -56,86 +41,63 @@ public class EntitySelectionButton implements Renderable, GuiEventListener, Narr
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
this.nestedButton.render(guiGraphics, mouseX, mouseY, partialTicks);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
Entity e = Minecraft.getInstance().level.getEntity(entityID);
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
int xpos = this.x;
int xpos = getX();
int xoffset;
if (isSideA) {
xpos += this.width + 4;
xpos += getWidth() + 4;
xoffset = 4;
} else {
xpos -= 6;
xoffset = -4;
}
if (health > 200) {
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
guiGraphics.fill(xpos, this.y, xpos + 2, this.y + this.height / 5, 0xFF0000FF);
int healthHeight = ((health - 200) * this.height / 100);
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFFFF);
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
guiGraphics.fill(xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
int healthHeight = ((health - 200) * getHeight() / 100);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
} else if (health > 100) {
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
int healthHeight = ((health - 100) * this.height / 100);
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF0000FF);
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
int healthHeight = ((health - 100) * getHeight() / 100);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
} else if (health > 50) {
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
int healthHeight = ((health - 50) * this.height / 50);
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FFFF);
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
int healthHeight = ((health - 50) * getHeight() / 50);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
} else if (health > 20) {
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
int healthHeight = ((health - 20) * this.height / 30);
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FF00);
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
int healthHeight = ((health - 20) * getHeight() / 30);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
} else if (health > 10) {
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
int healthHeight = ((health - 10) * this.height / 10);
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFF00);
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
int healthHeight = ((health - 10) * getHeight() / 10);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
} else {
int healthHeight = (health * this.height / 10);
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFF0000);
int healthHeight = (health * getHeight() / 10);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
}
}
}
@Override
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
p_259858_.add(NarratedElementType.HINT, TurnBasedMinecraftMod.proxy.getEntity(entityID, Minecraft.getInstance().level.dimension()).getName());
}
@Override
public void onPress() {
onPress.onPress(this);
}
@Override
public void setFocused(boolean b) {
this.focused = b;
}
@Override
public boolean isFocused() {
return focused;
}
@Override
public NarrationPriority narrationPriority() {
return NarrationPriority.FOCUSED;
}
@Override
public void updateNarration(NarrationElementOutput narrationElementOutput) {
narrationElementOutput.add(NarratedElementType.HINT, TurnBasedMinecraftMod.proxy.getEntity(entityID, Minecraft.getInstance().level.dimension()).getName());
}
@Override
public boolean mouseClicked(double x, double y, int unknown) {
if (unknown == 0 && x >= this.x && y >= this.y && x <= (double)(this.x + this.width) && y <= (double)(this.y + this.height)) {
onPress();
return true;
}
return false;
}
}

View file

@ -1,26 +1,19 @@
package com.burnedkirby.TurnBasedMinecraft.client;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component;
public class ItemSelectionButton implements Renderable, GuiEventListener, NarratableEntry {
private int x;
private int y;
private int width;
private int height;
TBMItemButtonPress onPress;
public class ItemSelectionButton extends AbstractButton {
TBMButtonPress onPress;
private int itemStackID;
private boolean focused;
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, int itemStackID, TBMItemButtonPress onPress) {
this.x = x;
this.y = y;
this.width = widthIn;
this.height = heightIn;
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, TBMButtonPress onPress) {
super(x, y, widthIn, heightIn, Component.literal(buttonText));
this.onPress = onPress;
this.itemStackID = itemStackID;
}
@ -31,44 +24,23 @@ public class ItemSelectionButton implements Renderable, GuiEventListener, Narrat
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
if (hovered) {
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x80FFFFFF);
} else {
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x20707070);
if (visible) {
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
if (hovered) {
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
} else {
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
}
}
}
@Override
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
p_259858_.add(NarratedElementType.HINT, "Item " + this.itemStackID);
}
@Override
public void onPress() {
onPress.onPress(this);
}
@Override
public void setFocused(boolean b) {
focused = b;
}
@Override
public boolean isFocused() {
return focused;
}
@Override
public NarrationPriority narrationPriority() {
return NarrationPriority.FOCUSED;
}
@Override
public void updateNarration(NarrationElementOutput narrationElementOutput) {
narrationElementOutput.add(NarratedElementType.HINT, "Item " + this.itemStackID);
}
@Override
public boolean mouseClicked(double x, double y, int unknown) {
if (unknown == 0 && x >= this.x && y >= this.y && x <= (double)(this.x + this.width) && y <= (double)(this.y + this.height)) {
onPress();
return true;
}
return false;
}
}

View file

@ -1,5 +0,0 @@
package com.burnedkirby.TurnBasedMinecraft.client;
public interface TBMEntityButtonPress {
void onPress(EntitySelectionButton button);
}

View file

@ -1,5 +0,0 @@
package com.burnedkirby.TurnBasedMinecraft.client;
public interface TBMItemButtonPress {
void onPress(ItemSelectionButton button);
}

View file

@ -37,7 +37,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.25.1";
public static final String VERSION = "1.25.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/";
@ -78,7 +78,7 @@ public class TurnBasedMinecraftMod {
}
private void firstInit(final FMLCommonSetupEvent event) {
proxy = DistExecutor.unsafeRunForDist(() -> () -> new ClientProxy(), () -> () -> new CommonProxy());
proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
proxy.setLogger(logger);
proxy.initialize();

View file

@ -32,9 +32,6 @@ authors="${mod_authors}" #optional
description='''
Implements turn-based-battle in Minecraft.
'''
logoFile="assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
# the modid of the dependency

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

View file

@ -0,0 +1,18 @@
[
{
"modid": "com_burnedkirby_turnbasedminecraft",
"name": "Turn Based Minecraft",
"description": "Changes battles to be turn-based.",
"version": "1.25.0",
"mcversion": "1.20.2",
"url": "",
"updateUrl": "",
"authorList": ["Stephen Seo"],
"credits": "The Forge and FML guys, for making this possible.
Dependencies:
JavaMP3 by delthas, josephx86, GlaDOSik, and kevinstadler (MIT License)",
"logoFile": "",
"screenshots": [],
"dependencies": []
}
]