v1.23.0, forge 1.20.1-47.1.0

This commit is contained in:
Stephen Seo 2023-09-19 18:49:49 +09:00
parent 8e8771dfc6
commit fab8e2d4a0
19 changed files with 653 additions and 438 deletions

View file

@ -1,5 +1,16 @@
# Upcoming changes
# Version 1.23.0
Support reproducible builds. This means that if this mod is compiled, then it
should be byte-by-byte exactly the same as another compiled jar (assuming it
was compiled with the same version of Java and same mod version.)
Update to Forge 1.20.1-47.1.0.
Experimental support for "use item" for unrecognized items. Note that this uses
the Minecraft API's `Item.finishUsingItem(...)`.
# Version 1.22.0
Update to Forge 1.19.3-44.1.0.

View file

@ -58,7 +58,7 @@ configured for them.)
# Building
Simply invoke `./gradlew build` in the mod directory and after some time the
finished jar will be saved at "build/libs/TurnBasedMinecraft-1.22.0.jar"
finished jar will be saved at "build/libs/TurnBasedMinecraft-1.23.0.jar"
# Other notes

View file

@ -1,20 +1,12 @@
buildscript {
repositories {
maven { url = "https://maven.minecraftforge.net" }
jcenter()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '6.0.6'
classpath 'com.github.johnrengelman:shadow:8.1.1'
}
plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
apply plugin: 'net.minecraftforge.gradle'
//apply plugin: 'eclipse'
//apply plugin: 'maven-publish'
version = "1.22.0"
version = "1.23.0"
group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft"
@ -27,11 +19,16 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.19.3'
mappings channel: mapping_channel, version: mapping_version
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
runs {
@ -151,7 +148,7 @@ dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed
// that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied.
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.3-44.1.1'
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
@ -169,6 +166,25 @@ dependencies {
shade files('libs/javamp3-1.0.3.jar')
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version: forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors: mod_authors, mod_description: mod_description,
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
archiveClassifier = 'slim'

View file

@ -1 +1,55 @@
org.gradle.jvmargs=-Xmx4096m
org.gradle.daemon=false
## Environment Properties
# The Minecraft version must agree with the Forge version to get a valid artifact
minecraft_version=1.20.1
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.1,1.21)
# The Forge version must agree with the Minecraft version to get a valid artifact
forge_version=47.1.0
# The Forge version range can use any version of Forge as bounds or match the loader version range
forge_version_range=[47,)
# The loader version range can only use the major version of Forge/FML as bounds
loader_version_range=[47,)
# The mapping channel to use for mappings.
# The default set of supported mapping channels are ["official", "snapshot", "snapshot_nodoc", "stable", "stable_nodoc"].
# Additional mapping channels can be registered through the "channelProviders" extension in a Gradle plugin.
#
# | Channel | Version | |
# |-----------|----------------------|--------------------------------------------------------------------------------|
# | official | MCVersion | Official field/method names from Mojang mapping files |
# | parchment | YYYY.MM.DD-MCVersion | Open community-sourced parameter names and javadocs layered on top of official |
#
# You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
# See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
#
# Parchment is an unofficial project maintained by ParchmentMC, separate from Minecraft Forge.
# Additional setup is needed to use their mappings, see https://parchmentmc.org/docs/getting-started
mapping_channel=official
# The mapping version to query from the mapping channel.
# This must match the format required by the mapping channel.
mapping_version=1.20.1
## Mod Properties
# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=com_burnedkirby_turnbasedminecraft
# The human-readable display name for the mod.
mod_name=TurnBasedMinecraftMod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=1.23.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.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.
mod_description=Implements turn-based-battle in Minecraft.

15
settings.gradle Normal file
View file

@ -0,0 +1,15 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = 'MinecraftForge'
url = 'https://maven.minecraftforge.net/'
}
jcenter()
mavenCentral()
}
}
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
}

View file

@ -7,6 +7,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
@ -224,10 +225,10 @@ public class BattleGui extends Screen {
}
@Override
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
if (TurnBasedMinecraftMod.proxy.getLocalBattle() == null) {
// drawHoveringText("Waiting...", width / 2 - 50, height / 2);
drawString(poseStack, "Waiting...", width / 2 - 50, height / 2, 0xFFFFFFFF);
drawString(guiGraphics, "Waiting...", width / 2 - 50, height / 2, 0xFFFFFFFF);
return;
}
if (TurnBasedMinecraftMod.proxy.getLocalBattle().getState() == Battle.State.DECISION
@ -243,7 +244,7 @@ public class BattleGui extends Screen {
updateState();
super.render(poseStack, mouseX, mouseY, partialTicks);
super.render(guiGraphics, mouseX, mouseY, partialTicks);
String timeRemainingString = "Time remaining: ";
int timeRemainingInt = timeRemaining.get();
@ -261,11 +262,11 @@ public class BattleGui extends Screen {
timeRemainingString += Integer.toString(timeRemainingInt);
}
int stringWidth = font.width(timeRemainingString);
fill(poseStack, width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000);
drawString(poseStack, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF);
guiGraphics.fill(width / 2 - stringWidth / 2, 5, width / 2 + stringWidth / 2, 15, 0x70000000);
drawString(guiGraphics, timeRemainingString, width / 2 - stringWidth / 2, 5, 0xFFFFFFFF);
stringWidth = font.width(info);
fill(poseStack, width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000);
drawString(poseStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
guiGraphics.fill(width / 2 - stringWidth / 2, 20, width / 2 + stringWidth / 2, 30, 0x70000000);
drawString(guiGraphics, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
}
protected void buttonActionEvent(AbstractButton button, ButtonAction action) {
@ -356,8 +357,8 @@ public class BattleGui extends Screen {
timeRemaining.set(remaining);
}
private void drawString(PoseStack poseStack, String string, int x, int y, int color) {
font.draw(poseStack, string, x, y, color);
private void drawString(GuiGraphics guiGraphics, String string, int x, int y, int color) {
guiGraphics.drawString(font, string, x, y, color);
}
public void setTurnTimerEnabled(boolean enabled) {

View file

@ -333,12 +333,12 @@ public class ClientProxy extends CommonProxy {
break;
case USED_INVALID:
if (pkt.getCustom().length() > 0) {
parentComponent.getSiblings().add(Component.literal(" tried to consume "));
parentComponent.getSiblings().add(Component.literal(" tried to use "));
parentComponent.getSiblings().add(Component.literal(pkt.getCustom()));
parentComponent.getSiblings().add(Component.literal(" and failed!"));
parentComponent.getSiblings().add(Component.literal("!"));
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
} else {
parentComponent.getSiblings().add(Component.literal(" tried to consume an invalid item and failed!"));
parentComponent.getSiblings().add(Component.literal(" tried to use an item!"));
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
}
break;

View file

@ -4,6 +4,7 @@ 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.AbstractButton;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
@ -39,8 +40,8 @@ public class EntitySelectionButton extends AbstractButton {
}
@Override
public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
super.renderButton(poseStack, mouseX, mouseY, partialTicks);
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float 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);
@ -54,38 +55,38 @@ public class EntitySelectionButton extends AbstractButton {
xoffset = -4;
}
if (health > 200) {
fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
fill(poseStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
fill(poseStack, xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
fill(poseStack, xpos, getY(), xpos + 2, getY() + getHeight() / 5, 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);
guiGraphics.fill(xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
int healthHeight = ((health - 200) * getHeight() / 100);
fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
} else if (health > 100) {
fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
fill(poseStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
fill(poseStack, xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 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);
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
int healthHeight = ((health - 100) * getHeight() / 100);
fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
} else if (health > 50) {
fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
fill(poseStack, xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 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);
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
int healthHeight = ((health - 50) * getHeight() / 50);
fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
} else if (health > 20) {
fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
fill(poseStack, xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
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);
fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
} else if (health > 10) {
fill(poseStack, xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
int healthHeight = ((health - 10) * getHeight() / 10);
fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
} else {
int healthHeight = (health * getHeight() / 10);
fill(poseStack, xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
}
}
}

View file

@ -1,6 +1,7 @@
package com.burnedkirby.TurnBasedMinecraft.client;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.narration.NarratedElementType;
import net.minecraft.client.gui.narration.NarrationElementOutput;
@ -22,13 +23,13 @@ public class ItemSelectionButton extends AbstractButton {
}
@Override
public void renderButton(PoseStack poseStack, int mouseX, int mouseY, float partialTicks) {
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
if (visible) {
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
if (hovered) {
fill(poseStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
} else {
fill(poseStack, getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
}
}
}

View file

@ -6,6 +6,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
@ -38,7 +39,7 @@ public class AttackEventHandler
{
iter.remove();
}
else if(event.getSource().getEntity().equals(attacker.entity) && event.getSource().isProjectile())
else if(event.getSource().getEntity().equals(attacker.entity) && event.getSource().is(DamageTypes.ARROW))
{
iter.remove();
if(!isValid)
@ -60,7 +61,7 @@ public class AttackEventHandler
@SubscribeEvent
public void entityAttacked(LivingAttackEvent event)
{
if(event.getEntity().level.isClientSide)
if(event.getEntity().level().isClientSide)
{
return;
}
@ -130,7 +131,7 @@ public class AttackEventHandler
&& event.getEntity() != event.getSource().getEntity()
&& !config.getBattleIgnoringPlayers().contains(event.getSource().getEntity().getId())
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
&& event.getEntity().level.dimension().equals(event.getSource().getEntity().level.dimension())
&& event.getEntity().level().dimension().equals(event.getSource().getEntity().level().dimension())
&& battleManager.checkAttack(event))
{
// TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.proxy.getAttackingEntity() + " and " + event.getEntity());
@ -150,7 +151,7 @@ public class AttackEventHandler
{
Config config = TurnBasedMinecraftMod.proxy.getConfig();
BattleManager battleManager = TurnBasedMinecraftMod.proxy.getBattleManager();
if(event.getEntity().level.isClientSide
if(event.getEntity().level().isClientSide
|| config.isOldBattleBehaviorEnabled()
|| (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getId()))
|| (event.getNewTarget() != null && battleManager.isRecentlyLeftBattle(event.getNewTarget().getId()))
@ -162,7 +163,7 @@ public class AttackEventHandler
&& event.getNewTarget() != null
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
&& !config.getBattleIgnoringPlayers().contains(event.getNewTarget().getId())
&& event.getEntity().level.dimension().equals(event.getNewTarget().level.dimension()))
&& event.getEntity().level().dimension().equals(event.getNewTarget().level().dimension()))
{
TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event);
}

View file

@ -13,6 +13,7 @@ import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
import net.minecraft.world.level.Level;
import net.minecraftforge.common.CreativeModeTabRegistry;
import net.minecraftforge.network.PacketDistributor;
import java.util.*;
@ -786,7 +787,7 @@ public class Battle {
((ServerPlayer) nextEntity).connection.teleport(nextEntity.getX(), nextEntity.getY(), nextEntity.getZ(), yawDirection, pitchDirection);
BowItem itemBow = (BowItem) heldItemStack.getItem();
TurnBasedMinecraftMod.proxy.getAttackerViaBowSet().add(new AttackerViaBow(nextEntity, getId()));
itemBow.releaseUsing(((Player) nextEntity).getMainHandItem(), nextEntity.level, (LivingEntity) nextEntity, randomTimeLeft);
itemBow.releaseUsing(((Player) nextEntity).getMainHandItem(), nextEntity.level(), (LivingEntity) nextEntity, randomTimeLeft);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.FIRED_ARROW, nextEntity.getId(), targetEntity.getId(), 0);
} else {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.BOW_NO_AMMO, next.entity.getId(), 0, 0);
@ -835,7 +836,7 @@ public class Battle {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), TurnBasedMinecraftMod.proxy.getAttackingDamage());
if (defenseDamageTriggered) {
// defense damage
DamageSource defenseDamageSource = DamageSource.mobAttack((LivingEntity) targetEntity);
DamageSource defenseDamageSource = targetEntity.damageSources().mobAttack((LivingEntity) targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity);
nextEntity.invulnerableTime = 0;
nextEntity.hurt(defenseDamageSource, targetEntityInfo.defenseDamage);
@ -898,7 +899,7 @@ public class Battle {
if (random.nextInt(100) < hitChance) {
if (target.remainingDefenses <= 0) {
debugLog += " hit success";
DamageSource damageSource = DamageSource.mobAttack((LivingEntity) next.entity);
DamageSource damageSource = next.entity.damageSources().mobAttack((LivingEntity) next.entity);
int damageAmount = next.entityInfo.attackPower;
if (next.entityInfo.attackVariance > 0) {
damageAmount += random.nextInt(next.entityInfo.attackVariance * 2 + 1) - next.entityInfo.attackVariance;
@ -942,7 +943,7 @@ public class Battle {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), finalDamageAmount);
if (defenseDamageTriggered) {
// defense damage
DamageSource defenseDamageSource = DamageSource.mobAttack((LivingEntity) targetEntity);
DamageSource defenseDamageSource = targetEntity.damageSources().mobAttack((LivingEntity) targetEntity);
TurnBasedMinecraftMod.proxy.setAttackingEntity(targetEntity);
nextEntity.invulnerableTime = 0;
nextEntity.hurt(defenseDamageSource, targetEntityInfo.defenseDamage);
@ -1068,24 +1069,28 @@ public class Battle {
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse;
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
} else {
// then check vanilla foods
if (CreativeModeTabs.FOOD_AND_DRINKS.contains(targetItemStack) && targetItem.isEdible()) {
final CreativeModeTab foodAndDrinksTab = CreativeModeTabRegistry.getTab(CreativeModeTabs.FOOD_AND_DRINKS.location());
if (foodAndDrinksTab.contains(targetItemStack) && targetItem.isEdible()) {
debugLog += " food";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse;
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
} else if (targetItem instanceof PotionItem) {
debugLog += " potion";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse;
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level, (LivingEntity) nextEntity));
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
} else {
debugLog += " non-consumable";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity;
final int nextItemToUse = next.itemToUse;
((Player)nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
}
}
break;
@ -1149,7 +1154,7 @@ public class Battle {
TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
targetEntity.invulnerableTime = 0;
targetEntity.hurt(DamageSource.mobAttack((LivingEntity) nextEntity), finalDamageAmount);
targetEntity.hurt(nextEntity.damageSources().mobAttack((LivingEntity) nextEntity), finalDamageAmount);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), finalDamageAmount);
if (attackEffectTriggered) {
@ -1194,7 +1199,7 @@ public class Battle {
TurnBasedMinecraftMod.proxy.setAttackingEntity(nextEntity);
targetEntity.invulnerableTime = 0;
targetEntity.hurt(DamageSource.mobAttack((LivingEntity) nextEntity), finalDamageAmount);
targetEntity.hurt(nextEntity.damageSources().mobAttack((LivingEntity) nextEntity), finalDamageAmount);
TurnBasedMinecraftMod.proxy.setAttackingEntity(null);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.ATTACK, nextEntity.getId(), targetEntity.getId(), finalDamageAmount);
if (attackEffectTriggered) {

View file

@ -142,7 +142,7 @@ public class BattleManager
Collection<Entity> sideB = new ArrayList<Entity>(1);
sideA.add(event.getEntity());
sideB.add(event.getSource().getEntity());
createBattle(sideA, sideB, event.getEntity().level.dimension());
createBattle(sideA, sideB, event.getEntity().level().dimension());
logger.debug("Attack Not Canceled: new battle created");
}
else
@ -251,7 +251,7 @@ public class BattleManager
Collection<Entity> sideB = new ArrayList<Entity>(1);
sideA.add(event.getEntity());
sideB.add(event.getNewTarget());
createBattle(sideA, sideB, event.getEntity().level.dimension());
createBattle(sideA, sideB, event.getEntity().level().dimension());
logger.debug("neither in battle, at least one is player, creating new battle");
}
} else {
@ -365,7 +365,7 @@ public class BattleManager
public boolean isInBattle(Entity entity) {
synchronized(tempIDPair) {
tempIDPair.id = entity.getId();
tempIDPair.dim = entity.level.dimension();
tempIDPair.dim = entity.level().dimension();
return entityToBattleMap.keySet().contains(tempIDPair);
}
}

View file

@ -9,7 +9,7 @@ import net.minecraftforge.network.PacketDistributor;
public class DimensionChangedHandler {
@SubscribeEvent
public void dimensionChanged(EntityTravelToDimensionEvent event) {
if(event.getEntity().level.isClientSide) {
if(event.getEntity().level().isClientSide) {
return;
}
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))

View file

@ -21,7 +21,7 @@ public class EntityIDDimPair {
EntityIDDimPair(Entity entity) {
id = entity.getId();
dim = entity.level.dimension();
dim = entity.level().dimension();
}
public Entity getEntity() {

View file

@ -7,9 +7,9 @@ public class HurtEventHandler {
@SubscribeEvent
public void handleHurtEvent(LivingHurtEvent event) {
CommonProxy proxy = TurnBasedMinecraftMod.proxy;
if (event.getEntity().level.isClientSide || proxy.getBattleManager() == null) {
if (event.getEntity().level().isClientSide || proxy.getBattleManager() == null) {
return;
} else if (proxy.getConfig().getIgnoreHurtDamageSources().contains(event.getSource().msgId) && proxy.getBattleManager().isInBattle(event.getEntity())) {
} else if (proxy.getConfig().getIgnoreHurtDamageSources().contains(event.getSource().getMsgId()) && proxy.getBattleManager().isInBattle(event.getEntity())) {
event.setCanceled(true);
}
}

View file

@ -6,18 +6,18 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[40,)" #mandatory (34 is current forge version)
loaderVersion="${loader_version_range}" #mandatory (34 is current forge version)
# A URL to refer people to when problems occur with this mod
issueTrackerURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod/issues" #optional
license="MIT"
# A list of mods - how many allowed here is determined by the individual mod loader
[[mods]] #mandatory
# The modid of the mod
modId="com_burnedkirby_turnbasedminecraft" #mandatory
modId="${mod_id}" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="1.22.0" #mandatory
version="${mod_version}" #mandatory
# A display name for the mod
displayName="TurnBasedMinecraftMod" #mandatory
displayName="${mod_name}" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here>
#updateJSONURL="" #optional
# A URL for the "homepage" for this mod, displayed in the mod UI
@ -27,7 +27,7 @@ displayURL="https://github.com/Stephen-Seo/TurnBasedMinecraftMod" #optional
# A text field displayed in the mod UI
credits="Thanks for this mod goes to Java" #optional
# A text field displayed in the mod UI
authors="BurnedKirby" #optional
authors="${mod_authors}" #optional
# The description text for the mod (multi line!) (#mandatory)
description='''
Implements turn-based-battle in Minecraft.
@ -39,7 +39,7 @@ Implements turn-based-battle in Minecraft.
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[40,)" #mandatory
versionRange="${forge_version_range}" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
@ -48,6 +48,6 @@ Implements turn-based-battle in Minecraft.
[[dependencies.com_burnedkirby_turnbasedminecraft]]
modId="minecraft"
mandatory=true
versionRange="[1.19.2,1.20)"
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"

View file

@ -1,6 +1,9 @@
# Please do not change this option, the mod uses this to keep track of what new
# changes to add to the config.
version = 9
version = 10
# 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]
@ -1271,3 +1274,33 @@ decision_attack_probability = 100
decision_defend_probability = 0
decision_flee_probability = 0
ignore_battle = false
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.camel.Camel"
attack_power = 0
attack_probability = 70
attack_variance = 0
attack_effect = "unknown"
defense_damage = 0
evasion = 10
category = "passive"
speed = 55
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
ignore_battle = false
[[server_config.entity]]
name = "net.minecraft.world.entity.animal.sniffer.Sniffer"
attack_power = 0
attack_probability = 70
attack_variance = 0
attack_effect = "unknown"
defense_damage = 0
evasion = 10
category = "passive"
speed = 15
decision_attack_probability = 0
decision_defend_probability = 0
decision_flee_probability = 90
ignore_battle = false

View file

@ -3,8 +3,8 @@
"modid": "com_burnedkirby_turnbasedminecraft",
"name": "Turn Based Minecraft",
"description": "Changes battles to be turn-based.",
"version": "1.22.0",
"mcversion": "1.18.2",
"version": "1.23.0",
"mcversion": "1.20.1",
"url": "",
"updateUrl": "",
"authorList": ["Stephen Seo"],