Version 1.22.0: to Forge 1.19.3-44.1.1

This commit is contained in:
Stephen Seo 2023-03-31 14:22:58 +09:00
parent c8add16c86
commit 275a613f0f
14 changed files with 99 additions and 71 deletions

View file

@ -1,5 +1,9 @@
# Upcoming changes # Upcoming changes
# Version 1.22.0
Update to Forge 1.19.3-44.1.1.
# Version 1.21.4 # Version 1.21.4
More refactoring of check-if-in-battle lookup code. More refactoring of check-if-in-battle lookup code.

View file

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

View file

@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle'
//apply plugin: 'eclipse' //apply plugin: 'eclipse'
//apply plugin: 'maven-publish' //apply plugin: 'maven-publish'
version = "1.21.4" version = "1.22.0"
group = "com.burnedkirby.TurnBasedMinecraft" group = "com.burnedkirby.TurnBasedMinecraft"
archivesBaseName = "TurnBasedMinecraft" archivesBaseName = "TurnBasedMinecraft"
@ -27,7 +27,7 @@ minecraft {
// stable_# Stables are built at the discretion of the MCP team. // stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work. // 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. // Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.19.2' mappings channel: 'official', version: '1.19.3'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
@ -151,7 +151,7 @@ dependencies {
// Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // 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. // 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. // The userdev artifact is a special name and will get all sorts of transformations applied to it.
minecraft 'net.minecraftforge:forge:1.19.2-43.1.1' minecraft 'net.minecraftforge:forge:1.19.3-44.1.1'
// Real mod deobf dependency examples - these get remapped to your current mappings // 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 // compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency

View file

@ -7,6 +7,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision; import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleDecision;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractButton;
import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -127,18 +128,18 @@ public class BattleGui extends Screen {
switch (state) { switch (state) {
case MAIN_MENU: case MAIN_MENU:
info = "What will you do?"; info = "What will you do?";
addRenderableWidget(new Button(width * 3 / 7 - 25, 40, 50, 20, Component.literal("Attack"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Attack"), (button) -> {
buttonActionEvent(button, ButtonAction.ATTACK); buttonActionEvent(button, ButtonAction.ATTACK);
})); }).bounds(width * 3 / 7 - 25, 40, 50, 20).build());
addRenderableWidget(new Button(width * 4 / 7 - 25, 40, 50, 20, Component.literal("Defend"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Defend"), (button) -> {
buttonActionEvent(button, ButtonAction.DEFEND); buttonActionEvent(button, ButtonAction.DEFEND);
})); }).bounds(width * 4 / 7 - 25, 40, 50, 20).build());
addRenderableWidget(new Button(width * 3 / 7 - 25, 60, 50, 20, Component.literal("Item"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Item"), (button) -> {
buttonActionEvent(button, ButtonAction.ITEM); buttonActionEvent(button, ButtonAction.ITEM);
})); }).bounds(width * 3 / 7 - 25, 60, 50, 20).build());
addRenderableWidget(new Button(width * 4 / 7 - 25, 60, 50, 20, Component.literal("Flee"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Flee"), (button) -> {
buttonActionEvent(button, ButtonAction.FLEE); buttonActionEvent(button, ButtonAction.FLEE);
})); }).bounds(width * 4 / 7 - 25, 60, 50, 20).build());
break; break;
case ATTACK_TARGET: case ATTACK_TARGET:
info = "Who will you attack?"; info = "Who will you attack?";
@ -178,21 +179,21 @@ public class BattleGui extends Screen {
} catch (ConcurrentModificationException e) { } catch (ConcurrentModificationException e) {
// ignored // ignored
} }
addRenderableWidget(new Button(width / 2 - 30, height - 120, 60, 20, Component.literal("Cancel"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }).bounds(width / 2 - 30, height - 120, 60, 20).build());
break; break;
case ITEM_ACTION: case ITEM_ACTION:
info = "What will you do with an item?"; info = "What will you do with an item?";
addRenderableWidget(new Button(width * 1 / 4 - 40, height - 120, 80, 20, Component.literal("Switch Held"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Switch Held"), (button) -> {
buttonActionEvent(button, ButtonAction.SWITCH_HELD_ITEM); buttonActionEvent(button, ButtonAction.SWITCH_HELD_ITEM);
})); }).bounds(width / 4 - 40, height - 120, 80, 20).build());
addRenderableWidget(new Button(width * 2 / 4 - 40, height - 120, 80, 20, Component.literal("Use"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Use"), (button) -> {
buttonActionEvent(button, ButtonAction.DECIDE_USE_ITEM); buttonActionEvent(button, ButtonAction.DECIDE_USE_ITEM);
})); }).bounds(width * 2 / 4 - 40, height - 120, 80, 20).build());
addRenderableWidget(new Button(width * 3 / 4 - 40, height - 120, 80, 20, Component.literal("Cancel"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }).bounds(width * 3 / 4 - 40, height - 120, 80, 20).build());
break; break;
case WAITING: case WAITING:
info = "Waiting..."; info = "Waiting...";
@ -204,9 +205,9 @@ public class BattleGui extends Screen {
buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH); buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
})); }));
} }
addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, Component.literal("Cancel"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }).bounds(width / 2 - 40, height - 120, 80, 20).build());
break; break;
case USE_ITEM: case USE_ITEM:
info = "Which item will you use?"; info = "Which item will you use?";
@ -215,9 +216,9 @@ public class BattleGui extends Screen {
buttonActionEvent(button, ButtonAction.DO_USE_ITEM); buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
})); }));
} }
addRenderableWidget(new Button(width / 2 - 40, height - 120, 80, 20, Component.literal("Cancel"), (button) -> { addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
buttonActionEvent(button, ButtonAction.CANCEL); buttonActionEvent(button, ButtonAction.CANCEL);
})); }).bounds(width / 2 - 40, height - 120, 80, 20).build());
break; break;
} }
} }
@ -267,7 +268,7 @@ public class BattleGui extends Screen {
drawString(poseStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF); drawString(poseStack, info, width / 2 - stringWidth / 2, 20, 0xFFFFFFFF);
} }
protected void buttonActionEvent(Button button, ButtonAction action) { protected void buttonActionEvent(AbstractButton button, ButtonAction action) {
switch (action) { switch (action) {
case ATTACK: case ATTACK:
setState(MenuState.ATTACK_TARGET); setState(MenuState.ATTACK_TARGET);

View file

@ -1,24 +1,31 @@
package com.burnedkirby.TurnBasedMinecraft.client; package com.burnedkirby.TurnBasedMinecraft.client;
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button; 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.network.chat.Component;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
public class EntitySelectionButton extends Button { public class EntitySelectionButton extends AbstractButton {
TBMButtonPress onPress;
private int entityID; private int entityID;
private boolean isSideA; private boolean isSideA;
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, Button.OnPress onPress) { 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), onPress); super(x, y, widthIn, heightIn, Component.literal(buttonText));
this.onPress = onPress;
this.entityID = entityID; this.entityID = entityID;
this.isSideA = isSideA; this.isSideA = isSideA;
} }
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, Button.OnPress onPress) { public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMButtonPress onPress) {
super(x, y, widthIn, heightIn, buttonTextComponent, onPress); super(x, y, widthIn, heightIn, buttonTextComponent);
this.onPress = onPress;
this.entityID = entityID; this.entityID = entityID;
this.isSideA = isSideA; this.isSideA = isSideA;
} }
@ -83,11 +90,13 @@ public class EntitySelectionButton extends Button {
} }
} }
private int getX() { @Override
return x; protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
p_259858_.add(NarratedElementType.HINT, TurnBasedMinecraftMod.proxy.getEntity(entityID, Minecraft.getInstance().level.dimension()).getName());
} }
private int getY() { @Override
return y; public void onPress() {
onPress.onPress(this);
} }
} }

View file

@ -1,14 +1,19 @@
package com.burnedkirby.TurnBasedMinecraft.client; package com.burnedkirby.TurnBasedMinecraft.client;
import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.components.Button; 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.network.chat.Component;
public class ItemSelectionButton extends Button { public class ItemSelectionButton extends AbstractButton {
TBMButtonPress onPress;
private int itemStackID; private int itemStackID;
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, Button.OnPress onPress) { public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, TBMButtonPress onPress) {
super(x, y, widthIn, heightIn, Component.literal(buttonText), onPress); super(x, y, widthIn, heightIn, Component.literal(buttonText));
this.onPress = onPress;
this.itemStackID = itemStackID; this.itemStackID = itemStackID;
} }
@ -28,11 +33,13 @@ public class ItemSelectionButton extends Button {
} }
} }
private int getX() { @Override
return x; protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
p_259858_.add(NarratedElementType.HINT, "Item " + this.itemStackID);
} }
private int getY() { @Override
return y; public void onPress() {
onPress.onPress(this);
} }
} }

View file

@ -0,0 +1,7 @@
package com.burnedkirby.TurnBasedMinecraft.client;
import net.minecraft.client.gui.components.AbstractButton;
public interface TBMButtonPress {
void onPress(AbstractButton button);
}

View file

@ -9,7 +9,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage
import net.minecraft.world.entity.monster.Creeper; import net.minecraft.world.entity.monster.Creeper;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
@ -146,23 +146,23 @@ public class AttackEventHandler
} }
@SubscribeEvent @SubscribeEvent
public void entityTargeted(LivingSetAttackTargetEvent event) public void entityTargeted(LivingChangeTargetEvent event)
{ {
Config config = TurnBasedMinecraftMod.proxy.getConfig(); Config config = TurnBasedMinecraftMod.proxy.getConfig();
BattleManager battleManager = TurnBasedMinecraftMod.proxy.getBattleManager(); BattleManager battleManager = TurnBasedMinecraftMod.proxy.getBattleManager();
if(event.getEntity().level.isClientSide if(event.getEntity().level.isClientSide
|| config.isOldBattleBehaviorEnabled() || config.isOldBattleBehaviorEnabled()
|| (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getId())) || (event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getId()))
|| (event.getTarget() != null && battleManager.isRecentlyLeftBattle(event.getTarget().getId())) || (event.getNewTarget() != null && battleManager.isRecentlyLeftBattle(event.getNewTarget().getId()))
|| (event.getEntity() != null && event.getTarget() != null && Utility.distanceBetweenEntities(event.getEntity(), event.getTarget()) > (double)config.getAggroStartBattleDistance())) || (event.getEntity() != null && event.getNewTarget() != null && Utility.distanceBetweenEntities(event.getEntity(), event.getNewTarget()) > (double)config.getAggroStartBattleDistance()))
{ {
return; return;
} }
else if(event.getEntity() != null else if(event.getEntity() != null
&& event.getTarget() != null && event.getNewTarget() != null
&& !config.getBattleIgnoringPlayers().contains(event.getEntity().getId()) && !config.getBattleIgnoringPlayers().contains(event.getEntity().getId())
&& !config.getBattleIgnoringPlayers().contains(event.getTarget().getId()) && !config.getBattleIgnoringPlayers().contains(event.getNewTarget().getId())
&& event.getEntity().level.dimension().equals(event.getTarget().level.dimension())) && event.getEntity().level.dimension().equals(event.getNewTarget().level.dimension()))
{ {
TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event); TurnBasedMinecraftMod.proxy.getBattleManager().checkTargeted(event);
} }

View file

@ -1071,7 +1071,7 @@ public class Battle {
((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 { } else {
// then check vanilla foods // then check vanilla foods
if (targetItem.getItemCategory() == CreativeModeTab.TAB_FOOD && targetItem.isEdible()) { if (CreativeModeTabs.FOOD_AND_DRINKS.contains(targetItemStack) && targetItem.isEdible()) {
debugLog += " food"; debugLog += " food";
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString()); sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_FOOD.getValue(), targetItemStack.getDisplayName().getString());
final Entity nextEntity = next.entity; final Entity nextEntity = next.entity;

View file

@ -9,7 +9,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.event.entity.living.LivingChangeTargetEvent;
import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PacketDistributor;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -179,17 +179,17 @@ public class BattleManager
return true; return true;
} }
public void checkTargeted(LivingSetAttackTargetEvent event) public void checkTargeted(LivingChangeTargetEvent event)
{ {
// Check if "player_only_battles" is enabled and if both entities are players. // Check if "player_only_battles" is enabled and if both entities are players.
if (TurnBasedMinecraftMod.proxy.getConfig().isPlayerOnlyBattlesEnabled() && if (TurnBasedMinecraftMod.proxy.getConfig().isPlayerOnlyBattlesEnabled() &&
(!(event.getEntity() instanceof Player) || !(event.getTarget() instanceof Player))) { (!(event.getEntity() instanceof Player) || !(event.getNewTarget() instanceof Player))) {
return; return;
} }
String targetedCustomName; String targetedCustomName;
try { try {
targetedCustomName = event.getTarget().getCustomName().getString(); targetedCustomName = event.getNewTarget().getCustomName().getString();
} catch (NullPointerException e) { } catch (NullPointerException e) {
targetedCustomName = null; targetedCustomName = null;
} }
@ -207,7 +207,7 @@ public class BattleManager
} }
EntityInfo targetedInfo; EntityInfo targetedInfo;
if(event.getTarget() instanceof Player) if(event.getNewTarget() instanceof Player)
{ {
targetedInfo = null; targetedInfo = null;
} }
@ -216,10 +216,10 @@ public class BattleManager
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(targetedCustomName); targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getCustomEntityInfoReference(targetedCustomName);
if(targetedInfo == null) if(targetedInfo == null)
{ {
targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getTarget()); targetedInfo = TurnBasedMinecraftMod.proxy.getConfig().getMatchingEntityInfo(event.getNewTarget());
} }
} }
if((event.getTarget() instanceof Player && ((Player)event.getTarget()).isCreative()) if((event.getNewTarget() instanceof Player && ((Player)event.getNewTarget()).isCreative())
|| attackerInfo == null || attackerInfo == null
|| attackerInfo.ignoreBattle || attackerInfo.ignoreBattle
|| TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category) || TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType(attackerInfo.category)
@ -235,8 +235,8 @@ public class BattleManager
if(attackerBattle != null && !attackerBattle.hasCombatant(event.getEntity().getId())) { if(attackerBattle != null && !attackerBattle.hasCombatant(event.getEntity().getId())) {
attackerBattle = null; attackerBattle = null;
} }
Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getTarget()))); Battle defenderBattle = battleMap.get(entityToBattleMap.get(new EntityIDDimPair(event.getNewTarget())));
if(defenderBattle != null && !defenderBattle.hasCombatant(event.getTarget().getId())) { if(defenderBattle != null && !defenderBattle.hasCombatant(event.getNewTarget().getId())) {
defenderBattle = null; defenderBattle = null;
} }
@ -244,13 +244,13 @@ public class BattleManager
return; return;
} else if(attackerBattle == null && defenderBattle == null) { } else if(attackerBattle == null && defenderBattle == null) {
// neither in battle // neither in battle
if(event.getEntity() instanceof Player || event.getTarget() instanceof Player) if(event.getEntity() instanceof Player || event.getNewTarget() instanceof Player)
{ {
// at least one is a player, create battle // at least one is a player, create battle
Collection<Entity> sideA = new ArrayList<Entity>(1); Collection<Entity> sideA = new ArrayList<Entity>(1);
Collection<Entity> sideB = new ArrayList<Entity>(1); Collection<Entity> sideB = new ArrayList<Entity>(1);
sideA.add(event.getEntity()); sideA.add(event.getEntity());
sideB.add(event.getTarget()); 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"); logger.debug("neither in battle, at least one is player, creating new battle");
} }
@ -261,16 +261,16 @@ public class BattleManager
// battle max reached, cannot add to battle // battle max reached, cannot add to battle
return; return;
} else if (attackerBattle.hasCombatantInSideA(event.getEntity().getId())) { } else if (attackerBattle.hasCombatantInSideA(event.getEntity().getId())) {
attackerBattle.addCombatantToSideB(event.getTarget()); attackerBattle.addCombatantToSideB(event.getNewTarget());
} else { } else {
attackerBattle.addCombatantToSideA(event.getTarget()); attackerBattle.addCombatantToSideA(event.getNewTarget());
} }
entityToBattleMap.put(new EntityIDDimPair(event.getTarget()), attackerBattle.getId()); entityToBattleMap.put(new EntityIDDimPair(event.getNewTarget()), attackerBattle.getId());
} else { } else {
if (defenderBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) { if (defenderBattle.getSize() >= TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()) {
// battle max reached, cannot add to battle // battle max reached, cannot add to battle
return; return;
} else if (defenderBattle.hasCombatantInSideA(event.getTarget().getId())) { } else if (defenderBattle.hasCombatantInSideA(event.getNewTarget().getId())) {
defenderBattle.addCombatantToSideB(event.getEntity()); defenderBattle.addCombatantToSideB(event.getEntity());
} else { } else {
defenderBattle.addCombatantToSideA(event.getEntity()); defenderBattle.addCombatantToSideA(event.getEntity());

View file

@ -39,7 +39,7 @@ import org.apache.logging.log4j.Logger;
public class TurnBasedMinecraftMod { public class TurnBasedMinecraftMod {
public static final String MODID = "com_burnedkirby_turnbasedminecraft"; public static final String MODID = "com_burnedkirby_turnbasedminecraft";
public static final String NAME = "Turn Based Minecraft Mod"; public static final String NAME = "Turn Based Minecraft Mod";
public static final String VERSION = "1.21.4"; public static final String VERSION = "1.22.0";
public static final String CONFIG_FILENAME = "TBM_Config.toml"; public static final String CONFIG_FILENAME = "TBM_Config.toml";
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml"; public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/"; public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";

View file

@ -1,6 +1,6 @@
package com.burnedkirby.TurnBasedMinecraft.common; package com.burnedkirby.TurnBasedMinecraft.common;
import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -60,6 +60,6 @@ public class Utility
public static ResourceKey<Level> deserializeDimension(String dimString) { public static ResourceKey<Level> deserializeDimension(String dimString) {
ResourceLocation dimRes = new ResourceLocation(dimString); ResourceLocation dimRes = new ResourceLocation(dimString);
return ResourceKey.create(Registry.DIMENSION_REGISTRY, dimRes); return ResourceKey.create(Registries.DIMENSION, dimRes);
} }
} }

View file

@ -15,7 +15,7 @@ license="MIT"
# The modid of the mod # The modid of the mod
modId="com_burnedkirby_turnbasedminecraft" #mandatory modId="com_burnedkirby_turnbasedminecraft" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="1.21.4" #mandatory version="1.22.0" #mandatory
# A display name for the mod # A display name for the mod
displayName="TurnBasedMinecraftMod" #mandatory displayName="TurnBasedMinecraftMod" #mandatory
# A URL to query for updates for this mod. See the JSON update specification <here> # A URL to query for updates for this mod. See the JSON update specification <here>

View file

@ -3,7 +3,7 @@
"modid": "com_burnedkirby_turnbasedminecraft", "modid": "com_burnedkirby_turnbasedminecraft",
"name": "Turn Based Minecraft", "name": "Turn Based Minecraft",
"description": "Changes battles to be turn-based.", "description": "Changes battles to be turn-based.",
"version": "1.21.4", "version": "1.22.0",
"mcversion": "1.18.2", "mcversion": "1.18.2",
"url": "", "url": "",
"updateUrl": "", "updateUrl": "",