Update code for NeoForge 20.4.108-beta
This commit is contained in:
parent
830f4255bb
commit
fb2c4cd13c
21 changed files with 578 additions and 487 deletions
|
@ -2,7 +2,7 @@ plugins {
|
||||||
id 'eclipse'
|
id 'eclipse'
|
||||||
id 'idea'
|
id 'idea'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'net.neoforged.gradle.userdev' version '7.0.57'
|
id 'net.neoforged.gradle.userdev' version '7.0.80'
|
||||||
}
|
}
|
||||||
|
|
||||||
version = "1.25.0"
|
version = "1.25.0"
|
||||||
|
|
|
@ -4,17 +4,17 @@ org.gradle.daemon=false
|
||||||
## Environment Properties
|
## Environment Properties
|
||||||
|
|
||||||
# The Minecraft version must agree with the Forge version to get a valid artifact
|
# The Minecraft version must agree with the Forge version to get a valid artifact
|
||||||
minecraft_version=1.20.2
|
minecraft_version=1.20.4
|
||||||
# The Minecraft version range can use any release version of Minecraft as bounds.
|
# 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
|
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
|
||||||
# as they do not follow standard versioning conventions.
|
# as they do not follow standard versioning conventions.
|
||||||
minecraft_version_range=[1.20.2,1.21)
|
minecraft_version_range=[1.20.4,1.21)
|
||||||
# The Neo version must agree with the Minecraft version to get a valid artifact
|
# The Neo version must agree with the Minecraft version to get a valid artifact
|
||||||
neo_version=20.2.88
|
neo_version=20.4.108-beta
|
||||||
# The Neo version range can use any version of Neo as bounds or match the loader version range
|
# The Neo version range can use any version of Neo as bounds or match the loader version range
|
||||||
neo_version_range=[20.2,)
|
neo_version_range=[20.4,)
|
||||||
# The loader version range can only use the major version of Neo/FML as bounds
|
# The loader version range can only use the major version of Neo/FML as bounds
|
||||||
loader_version_range=[1,)
|
loader_version_range=[2,)
|
||||||
|
|
||||||
## Mod Properties
|
## Mod Properties
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ mod_name=TurnBasedMinecraftMod
|
||||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||||
mod_license=MIT
|
mod_license=MIT
|
||||||
# The mod version. See https://semver.org/
|
# The mod version. See https://semver.org/
|
||||||
mod_version=1.25.0
|
mod_version=1.25.1
|
||||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
# 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.
|
# This should match the base package used for the mod sources.
|
||||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||||
|
|
|
@ -5,13 +5,13 @@ import com.burnedkirby.TurnBasedMinecraft.common.Combatant;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Config;
|
import com.burnedkirby.TurnBasedMinecraft.common.Config;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
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 net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractButton;
|
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;
|
||||||
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
|
|
||||||
import java.util.ConcurrentModificationException;
|
import java.util.ConcurrentModificationException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -150,11 +150,11 @@ public class BattleGui extends Screen {
|
||||||
.getSideAEntrySet()) {
|
.getSideAEntrySet()) {
|
||||||
if (e.getValue().entity != null) {
|
if (e.getValue().entity != null) {
|
||||||
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), true, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), true, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width / 4 - 60, y, 120, 20, "Unknown", e.getKey(), true, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
y += 20;
|
y += 20;
|
||||||
|
@ -168,11 +168,11 @@ public class BattleGui extends Screen {
|
||||||
.getSideBEntrySet()) {
|
.getSideBEntrySet()) {
|
||||||
if (e.getValue().entity != null) {
|
if (e.getValue().entity != null) {
|
||||||
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), false, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, e.getValue().entity.getDisplayName(), e.getKey(), false, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
|
addRenderableWidget(new EntitySelectionButton(width * 3 / 4 - 60, y, 120, 20, "Unknown", e.getKey(), false, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
entityButtonActionEvent(button, ButtonAction.ATTACK_TARGET);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
y += 20;
|
y += 20;
|
||||||
|
@ -202,8 +202,8 @@ public class BattleGui extends Screen {
|
||||||
case SWITCH_ITEM:
|
case SWITCH_ITEM:
|
||||||
info = "To which item will you switch to?";
|
info = "To which item will you switch to?";
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
|
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
|
itemButtonActionEvent(button, ButtonAction.DO_ITEM_SWITCH);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
||||||
|
@ -213,8 +213,8 @@ public class BattleGui extends Screen {
|
||||||
case USE_ITEM:
|
case USE_ITEM:
|
||||||
info = "Which item will you use?";
|
info = "Which item will you use?";
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, "", i, (button) -> {
|
addRenderableWidget(new ItemSelectionButton(width / 2 - 88 + i * 20, height - 19, 16, 16, i, (button) -> {
|
||||||
buttonActionEvent(button, ButtonAction.DO_USE_ITEM);
|
itemButtonActionEvent(button, ButtonAction.DO_USE_ITEM);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
addRenderableWidget(Button.builder(Component.literal("Cancel"), (button) -> {
|
||||||
|
@ -275,7 +275,7 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.ATTACK_TARGET);
|
setState(MenuState.ATTACK_TARGET);
|
||||||
break;
|
break;
|
||||||
case DEFEND:
|
case DEFEND:
|
||||||
TurnBasedMinecraftMod.getHandler().sendToServer(new PacketBattleDecision(
|
PacketDistributor.SERVER.noArg().send(new PacketBattleDecision(
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.DEFEND, 0));
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
|
@ -283,19 +283,13 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.ITEM_ACTION);
|
setState(MenuState.ITEM_ACTION);
|
||||||
break;
|
break;
|
||||||
case FLEE:
|
case FLEE:
|
||||||
TurnBasedMinecraftMod.getHandler().sendToServer(new PacketBattleDecision(
|
PacketDistributor.SERVER.noArg().send(new PacketBattleDecision(
|
||||||
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
|
TurnBasedMinecraftMod.proxy.getLocalBattle().getId(), Battle.Decision.FLEE, 0));
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
break;
|
break;
|
||||||
case ATTACK_TARGET:
|
case ATTACK_TARGET:
|
||||||
if (button instanceof EntitySelectionButton) {
|
// Invalid, but set menu to main menu anyways.
|
||||||
TurnBasedMinecraftMod.getHandler()
|
|
||||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
|
||||||
Battle.Decision.ATTACK, ((EntitySelectionButton) button).getID()));
|
|
||||||
setState(MenuState.WAITING);
|
|
||||||
} else {
|
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case SWITCH_HELD_ITEM:
|
case SWITCH_HELD_ITEM:
|
||||||
setState(MenuState.SWITCH_ITEM);
|
setState(MenuState.SWITCH_ITEM);
|
||||||
|
@ -307,27 +301,46 @@ public class BattleGui extends Screen {
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
break;
|
break;
|
||||||
case DO_ITEM_SWITCH:
|
case DO_ITEM_SWITCH:
|
||||||
if (button instanceof ItemSelectionButton) {
|
// Invalid, but set menu to main menu anyways.
|
||||||
TurnBasedMinecraftMod.getHandler()
|
|
||||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
|
||||||
Battle.Decision.SWITCH_ITEM, ((ItemSelectionButton) button).getID()));
|
|
||||||
if (((ItemSelectionButton) button).getID() >= 0 && ((ItemSelectionButton) button).getID() < 9) {
|
|
||||||
Minecraft.getInstance().player.getInventory().selected = ((ItemSelectionButton) button).getID();
|
|
||||||
}
|
|
||||||
setState(MenuState.WAITING);
|
|
||||||
} else {
|
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case DO_USE_ITEM:
|
case DO_USE_ITEM:
|
||||||
if (button instanceof ItemSelectionButton) {
|
// Invalid, but set menu to main menu anyways.
|
||||||
TurnBasedMinecraftMod.getHandler()
|
setState(MenuState.MAIN_MENU);
|
||||||
.sendToServer(new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
break;
|
||||||
Battle.Decision.USE_ITEM, ((ItemSelectionButton) button).getID()));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void entityButtonActionEvent(EntitySelectionButton button, ButtonAction action) {
|
||||||
|
if (action.equals(ButtonAction.ATTACK_TARGET)) {
|
||||||
|
PacketDistributor.SERVER.noArg().send(
|
||||||
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||||
|
Battle.Decision.ATTACK, ((EntitySelectionButton) button).getID()));
|
||||||
setState(MenuState.WAITING);
|
setState(MenuState.WAITING);
|
||||||
} else {
|
} else {
|
||||||
setState(MenuState.MAIN_MENU);
|
setState(MenuState.MAIN_MENU);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void itemButtonActionEvent(ItemSelectionButton button, ButtonAction action) {
|
||||||
|
switch (action) {
|
||||||
|
case DO_ITEM_SWITCH:
|
||||||
|
PacketDistributor.SERVER.noArg().send(
|
||||||
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||||
|
Battle.Decision.SWITCH_ITEM, button.getID()));
|
||||||
|
if (button.getID() >= 0 && button.getID() < 9) {
|
||||||
|
Minecraft.getInstance().player.getInventory().selected = button.getID();
|
||||||
|
}
|
||||||
|
setState(MenuState.WAITING);
|
||||||
|
break;
|
||||||
|
case DO_USE_ITEM:
|
||||||
|
PacketDistributor.SERVER.noArg().send(
|
||||||
|
new PacketBattleDecision(TurnBasedMinecraftMod.proxy.getLocalBattle().getId(),
|
||||||
|
Battle.Decision.USE_ITEM, button.getID()));
|
||||||
|
setState(MenuState.WAITING);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setState(MenuState.MAIN_MENU);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
private BattleGui battleGui = null;
|
private BattleGui battleGui = null;
|
||||||
|
@ -222,7 +222,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <MSG> void handlePacket(MSG msg, NetworkEvent.Context ctx) {
|
public <MSG> void handlePacket(final MSG msg, final PlayPayloadContext ctx) {
|
||||||
if (msg.getClass() == PacketBattleMessage.class) {
|
if (msg.getClass() == PacketBattleMessage.class) {
|
||||||
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
PacketBattleMessage pkt = (PacketBattleMessage) msg;
|
||||||
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
Entity fromEntity = getEntity(pkt.getEntityIDFrom(), pkt.getDimension());
|
||||||
|
|
|
@ -1,34 +1,49 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.client;
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.CommonProxy;
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
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.components.Renderable;
|
||||||
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||||
|
import net.minecraft.client.gui.narration.NarratableEntry;
|
||||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
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 AbstractButton {
|
public class EntitySelectionButton implements Renderable, GuiEventListener, NarratableEntry {
|
||||||
TBMButtonPress onPress;
|
private int x;
|
||||||
|
private int y;
|
||||||
|
private int width;
|
||||||
|
private int height;
|
||||||
|
private boolean focused;
|
||||||
|
private Button nestedButton;
|
||||||
|
TBMEntityButtonPress 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, TBMButtonPress onPress) {
|
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
|
||||||
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = widthIn;
|
||||||
|
this.height = heightIn;
|
||||||
this.onPress = onPress;
|
this.onPress = onPress;
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.isSideA = isSideA;
|
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, TBMButtonPress onPress) {
|
public EntitySelectionButton(int x, int y, int widthIn, int heightIn, Component buttonTextComponent, int entityID, boolean isSideA, TBMEntityButtonPress onPress) {
|
||||||
super(x, y, widthIn, heightIn, buttonTextComponent);
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = widthIn;
|
||||||
|
this.height = heightIn;
|
||||||
this.onPress = onPress;
|
this.onPress = onPress;
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
this.isSideA = isSideA;
|
this.isSideA = isSideA;
|
||||||
|
this.nestedButton = Button.builder(buttonTextComponent, (unused) -> {}).pos(x, y).size(widthIn, heightIn).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getID() {
|
public int getID() {
|
||||||
|
@ -41,63 +56,86 @@ public class EntitySelectionButton extends AbstractButton {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
this.nestedButton.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||||
Entity e = Minecraft.getInstance().level.getEntity(entityID);
|
Entity e = Minecraft.getInstance().level.getEntity(entityID);
|
||||||
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
|
if (e != null && e instanceof LivingEntity && ((LivingEntity) e).isAlive()) {
|
||||||
int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
|
int health = (int) (((LivingEntity) e).getHealth() + 0.5f);
|
||||||
int xpos = getX();
|
int xpos = this.x;
|
||||||
int xoffset;
|
int xoffset;
|
||||||
if (isSideA) {
|
if (isSideA) {
|
||||||
xpos += getWidth() + 4;
|
xpos += this.width + 4;
|
||||||
xoffset = 4;
|
xoffset = 4;
|
||||||
} else {
|
} else {
|
||||||
xpos -= 6;
|
xpos -= 6;
|
||||||
xoffset = -4;
|
xoffset = -4;
|
||||||
}
|
}
|
||||||
if (health > 200) {
|
if (health > 200) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
|
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
|
||||||
guiGraphics.fill(xpos, getY(), xpos + 2, getY() + getHeight() / 5, 0xFF0000FF);
|
guiGraphics.fill(xpos, this.y, xpos + 2, this.y + this.height / 5, 0xFF0000FF);
|
||||||
int healthHeight = ((health - 200) * getHeight() / 100);
|
int healthHeight = ((health - 200) * this.height / 100);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFFFF);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFFFF);
|
||||||
} else if (health > 100) {
|
} else if (health > 100) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() / 5, xpos + 2, getY() + getHeight() * 2 / 5, 0xFF00FFFF);
|
guiGraphics.fill(xpos, this.y + this.height / 5, xpos + 2, this.y + this.height * 2 / 5, 0xFF00FFFF);
|
||||||
int healthHeight = ((health - 100) * getHeight() / 100);
|
int healthHeight = ((health - 100) * this.height / 100);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF0000FF);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF0000FF);
|
||||||
} else if (health > 50) {
|
} else if (health > 50) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 2 / 5, xpos + 2, getY() + getHeight() * 3 / 5, 0xFF00FF00);
|
guiGraphics.fill(xpos, this.y + this.height * 2 / 5, xpos + 2, this.y + this.height * 3 / 5, 0xFF00FF00);
|
||||||
int healthHeight = ((health - 50) * getHeight() / 50);
|
int healthHeight = ((health - 50) * this.height / 50);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FFFF);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FFFF);
|
||||||
} else if (health > 20) {
|
} else if (health > 20) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 3 / 5, xpos + 2, getY() + getHeight() * 4 / 5, 0xFFFFFF00);
|
guiGraphics.fill(xpos, this.y + this.height * 3 / 5, xpos + 2, this.y + this.height * 4 / 5, 0xFFFFFF00);
|
||||||
int healthHeight = ((health - 20) * getHeight() / 30);
|
int healthHeight = ((health - 20) * this.height / 30);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFF00FF00);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFF00FF00);
|
||||||
} else if (health > 10) {
|
} else if (health > 10) {
|
||||||
guiGraphics.fill(xpos, getY() + getHeight() * 4 / 5, xpos + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos, this.y + this.height * 4 / 5, xpos + 2, this.y + this.height, 0xFFFF0000);
|
||||||
int healthHeight = ((health - 10) * getHeight() / 10);
|
int healthHeight = ((health - 10) * this.height / 10);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFFFF00);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 0xFFFFFF00);
|
||||||
} else {
|
} else {
|
||||||
int healthHeight = (health * getHeight() / 10);
|
int healthHeight = (health * this.height / 10);
|
||||||
guiGraphics.fill(xpos + xoffset, getY() + getHeight() - healthHeight, xpos + xoffset + 2, getY() + getHeight(), 0xFFFF0000);
|
guiGraphics.fill(xpos + xoffset, this.y + this.height - healthHeight, xpos + xoffset + 2, this.y + this.height, 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() {
|
public void onPress() {
|
||||||
onPress.onPress(this);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
package com.burnedkirby.TurnBasedMinecraft.client;
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.AbstractButton;
|
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.narration.NarratedElementType;
|
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
|
|
||||||
public class ItemSelectionButton extends AbstractButton {
|
public class ItemSelectionButton implements Renderable, GuiEventListener, NarratableEntry {
|
||||||
|
private int x;
|
||||||
TBMButtonPress onPress;
|
private int y;
|
||||||
|
private int width;
|
||||||
|
private int height;
|
||||||
|
TBMItemButtonPress onPress;
|
||||||
private int itemStackID;
|
private int itemStackID;
|
||||||
|
|
||||||
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, String buttonText, int itemStackID, TBMButtonPress onPress) {
|
public ItemSelectionButton(int x, int y, int widthIn, int heightIn, int itemStackID, TBMItemButtonPress onPress) {
|
||||||
super(x, y, widthIn, heightIn, Component.literal(buttonText));
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.width = widthIn;
|
||||||
|
this.height = heightIn;
|
||||||
this.onPress = onPress;
|
this.onPress = onPress;
|
||||||
this.itemStackID = itemStackID;
|
this.itemStackID = itemStackID;
|
||||||
}
|
}
|
||||||
|
@ -24,23 +30,44 @@ public class ItemSelectionButton extends AbstractButton {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
|
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float unk) {
|
||||||
if (visible) {
|
boolean hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||||
boolean hovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + getHeight();
|
|
||||||
if (hovered) {
|
if (hovered) {
|
||||||
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x80FFFFFF);
|
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x80FFFFFF);
|
||||||
} else {
|
} else {
|
||||||
guiGraphics.fill(getX(), getY(), getX() + getWidth(), getY() + getHeight(), 0x20707070);
|
guiGraphics.fill(this.x, this.y, this.x + this.width, this.y + this.height, 0x20707070);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateWidgetNarration(NarrationElementOutput p_259858_) {
|
|
||||||
p_259858_.add(NarratedElementType.HINT, "Item " + this.itemStackID);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPress() {
|
public void onPress() {
|
||||||
onPress.onPress(this);
|
onPress.onPress(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocused(boolean b) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFocused() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NarrationPriority narrationPriority() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
|
public interface TBMEntityButtonPress {
|
||||||
|
void onPress(EntitySelectionButton button);
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package com.burnedkirby.TurnBasedMinecraft.client;
|
||||||
|
|
||||||
|
public interface TBMItemButtonPress {
|
||||||
|
void onPress(ItemSelectionButton button);
|
||||||
|
}
|
|
@ -82,7 +82,7 @@ public class AttackEventHandler
|
||||||
if(!event.getEntity().hasCustomName())
|
if(!event.getEntity().hasCustomName())
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.logger.error("Cannot edit custom name from entity without custom name");
|
TurnBasedMinecraftMod.logger.error("Cannot edit custom name from entity without custom name");
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketGeneralMessage("Cannot edit custom name from entity without custom name"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
editingInfo.entityInfo = config.getCustomEntityInfo(event.getEntity().getCustomName().getString());
|
||||||
|
@ -91,9 +91,9 @@ public class AttackEventHandler
|
||||||
editingInfo.entityInfo = new EntityInfo();
|
editingInfo.entityInfo = new EntityInfo();
|
||||||
editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString();
|
editingInfo.entityInfo.customName = event.getEntity().getCustomName().getString();
|
||||||
}
|
}
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketGeneralMessage("Editing custom name \"" + event.getEntity().getCustomName().getString() + "\""));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing custom \"" + event.getEntity().getCustomName().getString() + "\"");
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -107,9 +107,9 @@ public class AttackEventHandler
|
||||||
{
|
{
|
||||||
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
editingInfo.entityInfo = editingInfo.entityInfo.clone();
|
||||||
}
|
}
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketGeneralMessage("Editing entity \"" + editingInfo.entityInfo.classType.getName() + "\""));
|
||||||
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
TurnBasedMinecraftMod.logger.info("Begin editing \"" + editingInfo.entityInfo.classType.getName() + "\"");
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer)editingInfo.editor), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with((ServerPlayer)editingInfo.editor).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,7 +449,7 @@ public class Battle {
|
||||||
}
|
}
|
||||||
PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
PacketBattleInfo infoPacket = new PacketBattleInfo(getSideAIDs(), getSideBIDs(), timer, TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever());
|
||||||
for (Combatant p : players.values()) {
|
for (Combatant p : players.values()) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), infoPacket);
|
PacketDistributor.PLAYER.with((ServerPlayer)p.entity).send(infoPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ public class Battle {
|
||||||
PacketBattleMessage packet = new PacketBattleMessage(type, from, to, dimension, amount, custom);
|
PacketBattleMessage packet = new PacketBattleMessage(type, from, to, dimension, amount, custom);
|
||||||
for (Combatant p : players.values()) {
|
for (Combatant p : players.values()) {
|
||||||
if (p.entity.isAlive()) {
|
if (p.entity.isAlive()) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) p.entity), packet);
|
PacketDistributor.PLAYER.with((ServerPlayer)p.entity).send(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ public class Battle {
|
||||||
|
|
||||||
private void removeCombatantPostRemove(Combatant c) {
|
private void removeCombatantPostRemove(Combatant c) {
|
||||||
if (c.entity instanceof Player) {
|
if (c.entity instanceof Player) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) c.entity), new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
|
PacketDistributor.PLAYER.with((ServerPlayer)c.entity).send(new PacketBattleMessage(PacketBattleMessage.MessageType.ENDED, 0, 0, dimension, 0));
|
||||||
}
|
}
|
||||||
battleManager.addRecentlyLeftBattle(c);
|
battleManager.addRecentlyLeftBattle(c);
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,7 +317,7 @@ public class BattleManager
|
||||||
c.time = System.nanoTime();
|
c.time = System.nanoTime();
|
||||||
Config config = TurnBasedMinecraftMod.proxy.getConfig();
|
Config config = TurnBasedMinecraftMod.proxy.getConfig();
|
||||||
if(c.entity instanceof ServerPlayer) {
|
if(c.entity instanceof ServerPlayer) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayer) c.entity), new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
|
PacketDistributor.PLAYER.with((ServerPlayer)c.entity).send(new PacketGeneralMessage("You just left battle! " + config.getLeaveBattleCooldownSeconds() + " seconds until you can attack/be-attacked again!"));
|
||||||
}
|
}
|
||||||
recentlyLeftBattle.put(c.entity.getId(), c);
|
recentlyLeftBattle.put(c.entity.getId(), c);
|
||||||
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
entityToBattleMap.remove(new EntityIDDimPair(c.entity));
|
||||||
|
@ -337,7 +337,7 @@ public class BattleManager
|
||||||
iter.remove();
|
iter.remove();
|
||||||
if(entry.getValue().entity instanceof ServerPlayer)
|
if(entry.getValue().entity instanceof ServerPlayer)
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.getHandler().send(PacketDistributor.PLAYER.with(()->(ServerPlayer)entry.getValue().entity), new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
|
PacketDistributor.PLAYER.with((ServerPlayer)entry.getValue().entity).send(new PacketGeneralMessage("Timer ended, you can now attack/be-attacked again."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.resources.ResourceKey;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
import net.neoforged.neoforge.server.ServerLifecycleHooks;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -172,5 +172,5 @@ public class CommonProxy
|
||||||
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
return ServerLifecycleHooks.getCurrentServer().getLevel(dim).getEntity(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <MSG> void handlePacket(MSG msg, NetworkEvent.Context ctx) {}
|
public <MSG> void handlePacket(final MSG msg, final PlayPayloadContext ctx) {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,7 @@ public class DimensionChangedHandler {
|
||||||
}
|
}
|
||||||
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
|
if(TurnBasedMinecraftMod.proxy.getBattleManager().forceLeaveBattle(new EntityIDDimPair(event.getEntity()))
|
||||||
&& event.getEntity() instanceof ServerPlayer) {
|
&& event.getEntity() instanceof ServerPlayer) {
|
||||||
TurnBasedMinecraftMod.getHandler().send(
|
PacketDistributor.PLAYER.with((ServerPlayer)event.getEntity()).send(new PacketGeneralMessage("Left battle due to moving to a different dimension"));
|
||||||
PacketDistributor.PLAYER.with(() -> (ServerPlayer)event.getEntity()),
|
|
||||||
new PacketGeneralMessage("Left battle due to moving to a different dimension"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.minecraft.network.chat.HoverEvent;
|
||||||
import net.minecraft.network.chat.MutableComponent;
|
import net.minecraft.network.chat.MutableComponent;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.bus.api.SubscribeEvent;
|
import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
|
@ -29,10 +30,9 @@ import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
|
||||||
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||||
import net.neoforged.neoforge.network.NetworkRegistry;
|
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
|
||||||
import net.neoforged.neoforge.network.PacketDistributor;
|
import net.neoforged.neoforge.network.PacketDistributor;
|
||||||
import net.neoforged.neoforge.network.simple.SimpleChannel;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
@ -53,32 +53,46 @@ public class TurnBasedMinecraftMod {
|
||||||
|
|
||||||
private static final String PROTOCOL_VERSION = Integer.toString(3);
|
private static final String PROTOCOL_VERSION = Integer.toString(3);
|
||||||
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
private static final ResourceLocation HANDLER_ID = new ResourceLocation(MODID, "main_channel");
|
||||||
private static final SimpleChannel HANDLER = NetworkRegistry.ChannelBuilder
|
|
||||||
.named(HANDLER_ID)
|
|
||||||
.clientAcceptedVersions(PROTOCOL_VERSION::equals)
|
|
||||||
.serverAcceptedVersions(PROTOCOL_VERSION::equals)
|
|
||||||
.networkProtocolVersion(() -> PROTOCOL_VERSION)
|
|
||||||
.simpleChannel();
|
|
||||||
protected static Logger logger = LogManager.getLogger();
|
protected static Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
public static ResourceLocation getNetResourceLocation() {
|
public static ResourceLocation getNetResourceLocation() {
|
||||||
return HANDLER_ID;
|
return HANDLER_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleChannel getHandler() {
|
|
||||||
return HANDLER;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommonProxy proxy;
|
public static CommonProxy proxy;
|
||||||
|
|
||||||
public TurnBasedMinecraftMod() {
|
public TurnBasedMinecraftMod(IEventBus eventBus) {
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::firstInit);
|
eventBus.addListener(this::firstInit);
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
|
eventBus.addListener(this::secondInitClient);
|
||||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
|
eventBus.addListener(this::secondInitServer);
|
||||||
|
eventBus.addListener(this::registerNetwork);
|
||||||
NeoForge.EVENT_BUS.register(this);
|
NeoForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerNetwork(final RegisterPayloadHandlerEvent event) {
|
||||||
|
final IPayloadRegistrar registrar = event.registrar(MODID);
|
||||||
|
|
||||||
|
registrar.play(PacketBattleDecision.ID, PacketBattleDecision::new, handler -> handler
|
||||||
|
.server(PacketBattleDecision.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketBattleInfo.ID, PacketBattleInfo::new, handler -> handler
|
||||||
|
.client(PacketBattleInfo.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketBattleMessage.ID, PacketBattleMessage::new, handler -> handler
|
||||||
|
.client(PacketBattleMessage.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketBattleRequestInfo.ID, PacketBattleRequestInfo::new, handler -> handler
|
||||||
|
.server(PacketBattleRequestInfo.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketEditingMessage.ID, PacketEditingMessage::new, handler -> handler
|
||||||
|
.client(PacketEditingMessage.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
registrar.play(PacketGeneralMessage.ID, PacketGeneralMessage::new, handler -> handler
|
||||||
|
.client(PacketGeneralMessage.PayloadHandler.getInstance()::handleData));
|
||||||
|
|
||||||
|
logger.debug("Register packets com_burnedkirby_turnbasedminecraft");
|
||||||
|
}
|
||||||
|
|
||||||
private void firstInit(final FMLCommonSetupEvent event) {
|
private void firstInit(final FMLCommonSetupEvent event) {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
proxy = new ClientProxy();
|
proxy = new ClientProxy();
|
||||||
|
@ -88,45 +102,6 @@ public class TurnBasedMinecraftMod {
|
||||||
proxy.setLogger(logger);
|
proxy.setLogger(logger);
|
||||||
proxy.initialize();
|
proxy.initialize();
|
||||||
|
|
||||||
// register packets
|
|
||||||
int packetHandlerID = 0;
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleInfo.class,
|
|
||||||
new PacketBattleInfo.Encoder(),
|
|
||||||
new PacketBattleInfo.Decoder(),
|
|
||||||
new PacketBattleInfo.Consumer());
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleRequestInfo.class,
|
|
||||||
new PacketBattleRequestInfo.Encoder(),
|
|
||||||
new PacketBattleRequestInfo.Decoder(),
|
|
||||||
new PacketBattleRequestInfo.Consumer());
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleDecision.class,
|
|
||||||
new PacketBattleDecision.Encoder(),
|
|
||||||
new PacketBattleDecision.Decoder(),
|
|
||||||
new PacketBattleDecision.Consumer());
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketBattleMessage.class,
|
|
||||||
new PacketBattleMessage.Encoder(),
|
|
||||||
new PacketBattleMessage.Decoder(),
|
|
||||||
new PacketBattleMessage.Consumer());
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketGeneralMessage.class,
|
|
||||||
new PacketGeneralMessage.Encoder(),
|
|
||||||
new PacketGeneralMessage.Decoder(),
|
|
||||||
new PacketGeneralMessage.Consumer());
|
|
||||||
HANDLER.registerMessage(
|
|
||||||
packetHandlerID++,
|
|
||||||
PacketEditingMessage.class,
|
|
||||||
new PacketEditingMessage.Encoder(),
|
|
||||||
new PacketEditingMessage.Decoder(),
|
|
||||||
new PacketEditingMessage.Consumer());
|
|
||||||
|
|
||||||
// register event handler(s)
|
// register event handler(s)
|
||||||
NeoForge.EVENT_BUS.register(new AttackEventHandler());
|
NeoForge.EVENT_BUS.register(new AttackEventHandler());
|
||||||
NeoForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
NeoForge.EVENT_BUS.register(new PlayerJoinEventHandler());
|
||||||
|
@ -177,7 +152,7 @@ public class TurnBasedMinecraftMod {
|
||||||
proxy.getConfig().setBattleDisabledForAll(true);
|
proxy.getConfig().setBattleDisabledForAll(true);
|
||||||
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
||||||
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP disabled turn-based-combat for everyone"));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -198,7 +173,7 @@ public class TurnBasedMinecraftMod {
|
||||||
proxy.getConfig().setBattleDisabledForAll(false);
|
proxy.getConfig().setBattleDisabledForAll(false);
|
||||||
proxy.getConfig().clearBattleIgnoringPlayers();
|
proxy.getConfig().clearBattleIgnoringPlayers();
|
||||||
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
for (ServerPlayer player : c.getSource().getServer().getPlayerList().getPlayers()) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP enabled turn-based-combat for everyone"));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}));
|
}));
|
||||||
|
@ -209,7 +184,7 @@ public class TurnBasedMinecraftMod {
|
||||||
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
||||||
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
||||||
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
proxy.getConfig().addBattleIgnoringPlayer(player.getId());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP enabled turn-based-combat for you"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP enabled turn-based-combat for you"));
|
||||||
c.getSource().sendSuccess(() -> Component.literal("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
c.getSource().sendSuccess(() -> Component.literal("Enabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -221,7 +196,7 @@ public class TurnBasedMinecraftMod {
|
||||||
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
.then(Commands.argument("targets", EntityArgument.players()).executes(c -> {
|
||||||
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
for (ServerPlayer player : EntityArgument.getPlayers(c, "targets")) {
|
||||||
proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
|
proxy.getConfig().removeBattleIgnoringPlayer(player.getId());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("OP disabled turn-based-combat for you"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("OP disabled turn-based-combat for you"));
|
||||||
c.getSource().sendSuccess(() -> Component.literal("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
c.getSource().sendSuccess(() -> Component.literal("Disabled turn-based-combat for " + player.getDisplayName().getString()), true);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -234,12 +209,12 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -250,14 +225,14 @@ public class TurnBasedMinecraftMod {
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
if (!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) {
|
if (!proxy.getConfig().editEntityEntry(editingInfo.entityInfo)) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("An error occurred while attempting to save an entry to the config"));
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
} else {
|
} else {
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("Entity info saved in config and loaded."));
|
||||||
}
|
}
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -270,7 +245,7 @@ public class TurnBasedMinecraftMod {
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null) {
|
if (editingInfo != null) {
|
||||||
proxy.removeEditingInfo(player.getId());
|
proxy.removeEditingInfo(player.getId());
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
|
PacketDistributor.PLAYER.with(player).send(new PacketGeneralMessage("Cancelled editing entry."));
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
|
@ -282,11 +257,11 @@ public class TurnBasedMinecraftMod {
|
||||||
Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
|
Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
proxy.setEditingPlayer(player);
|
proxy.setEditingPlayer(player);
|
||||||
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
proxy.getEditingInfo(player.getId()).isEditingCustomName = true;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getString() + "\" (\"" + c.getSource().getDisplayName() + "\")");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -296,9 +271,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -310,9 +285,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -326,9 +301,9 @@ public class TurnBasedMinecraftMod {
|
||||||
boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
|
boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.ignoreBattle = ignoreBattle;
|
editingInfo.entityInfo.ignoreBattle = ignoreBattle;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -341,9 +316,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -360,9 +335,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackPower = attackPower;
|
editingInfo.entityInfo.attackPower = attackPower;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -375,9 +350,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -396,9 +371,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackProbability = attackProbability;
|
editingInfo.entityInfo.attackProbability = attackProbability;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -411,9 +386,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -430,9 +405,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackVariance = attackVariance;
|
editingInfo.entityInfo.attackVariance = attackVariance;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -445,9 +420,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -461,9 +436,9 @@ public class TurnBasedMinecraftMod {
|
||||||
EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
|
EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackEffect = effect;
|
editingInfo.entityInfo.attackEffect = effect;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -476,9 +451,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -497,9 +472,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -512,9 +487,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -531,9 +506,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
editingInfo.entityInfo.defenseDamage = defenseDamage;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -546,9 +521,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -567,9 +542,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -582,9 +557,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -603,9 +578,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.evasion = evasion;
|
editingInfo.entityInfo.evasion = evasion;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -618,9 +593,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -637,9 +612,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.speed = speed;
|
editingInfo.entityInfo.speed = speed;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -652,9 +627,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -668,9 +643,9 @@ public class TurnBasedMinecraftMod {
|
||||||
String category = StringArgumentType.getString(c, "category");
|
String category = StringArgumentType.getString(c, "category");
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.category = category;
|
editingInfo.entityInfo.category = category;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -683,9 +658,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -704,9 +679,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
editingInfo.entityInfo.decisionAttack = decisionAttack;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -719,9 +694,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -740,9 +715,9 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
editingInfo.entityInfo.decisionDefend = decisionDefend;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -755,9 +730,9 @@ public class TurnBasedMinecraftMod {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -771,9 +746,9 @@ public class TurnBasedMinecraftMod {
|
||||||
int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
|
int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
|
||||||
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
editingInfo.entityInfo.decisionFlee = decisionFlee;
|
editingInfo.entityInfo.decisionFlee = decisionFlee;
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
} else if (editingInfo != null) {
|
} else if (editingInfo != null) {
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
} else {
|
} else {
|
||||||
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
@ -789,7 +764,7 @@ public class TurnBasedMinecraftMod {
|
||||||
.requires(c -> c.hasPermission(2))
|
.requires(c -> c.hasPermission(2))
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
PacketDistributor.PLAYER.with(player).send(new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
||||||
|
|
|
@ -4,13 +4,17 @@ import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
import com.burnedkirby.TurnBasedMinecraft.common.Battle.Decision;
|
||||||
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class PacketBattleDecision
|
public class PacketBattleDecision implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattledecision");
|
||||||
|
|
||||||
private int battleID;
|
private int battleID;
|
||||||
private Battle.Decision decision;
|
private Battle.Decision decision;
|
||||||
private int targetIDOrItemID;
|
private int targetIDOrItemID;
|
||||||
|
@ -24,40 +28,43 @@ public class PacketBattleDecision
|
||||||
this.targetIDOrItemID = targetIDOrItemID;
|
this.targetIDOrItemID = targetIDOrItemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleDecision> {
|
public PacketBattleDecision(final FriendlyByteBuf buf) {
|
||||||
public Encoder() {}
|
this.battleID = buf.readInt();
|
||||||
|
this.decision = Decision.valueOf(buf.readInt());
|
||||||
|
this.targetIDOrItemID = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(PacketBattleDecision pkt, FriendlyByteBuf buf) {
|
public void write(FriendlyByteBuf buf) {
|
||||||
buf.writeInt(pkt.battleID);
|
buf.writeInt(battleID);
|
||||||
buf.writeInt(pkt.decision.getValue());
|
buf.writeInt(decision.getValue());
|
||||||
buf.writeInt(pkt.targetIDOrItemID);
|
buf.writeInt(targetIDOrItemID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleDecision> {
|
|
||||||
public Decoder() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketBattleDecision decode(FriendlyByteBuf buf) {
|
public ResourceLocation id() {
|
||||||
return new PacketBattleDecision(buf.readInt(), Decision.valueOf(buf.readInt()), buf.readInt());
|
return ID;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleDecision> {
|
public static class PayloadHandler {
|
||||||
public Consumer() {}
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
@Override
|
public static PayloadHandler getInstance() {
|
||||||
public void handle(PacketBattleDecision pkt, NetworkEvent.Context ctx) {
|
return INSTANCE;
|
||||||
ctx.enqueueWork(() -> {
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketBattleDecision pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||||
if(b != null)
|
if(b != null)
|
||||||
{
|
{
|
||||||
ServerPlayer player = ctx.getSender();
|
Player player = ctx.player().get();
|
||||||
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
b.setDecision(player.getId(), pkt.decision, pkt.targetIDOrItemID);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleDecision! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
ctx.setPacketHandled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,16 @@ import java.util.Collection;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
|
||||||
|
|
||||||
public class PacketBattleInfo
|
public class PacketBattleInfo implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattleinfo");
|
||||||
private Collection<Integer> sideA;
|
private Collection<Integer> sideA;
|
||||||
private Collection<Integer> sideB;
|
private Collection<Integer> sideB;
|
||||||
private long decisionNanos;
|
private long decisionNanos;
|
||||||
|
@ -38,53 +41,51 @@ public class PacketBattleInfo
|
||||||
this.turnTimerEnabled = turnTimerEnabled;
|
this.turnTimerEnabled = turnTimerEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleInfo> {
|
public PacketBattleInfo(final FriendlyByteBuf buf) {
|
||||||
public Encoder() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void encode(PacketBattleInfo msg, FriendlyByteBuf buf) {
|
|
||||||
buf.writeInt(msg.sideA.size());
|
|
||||||
buf.writeInt(msg.sideB.size());
|
|
||||||
for(Integer id : msg.sideA) {
|
|
||||||
buf.writeInt(id);
|
|
||||||
}
|
|
||||||
for(Integer id : msg.sideB) {
|
|
||||||
buf.writeInt(id);
|
|
||||||
}
|
|
||||||
buf.writeLong(msg.decisionNanos);
|
|
||||||
buf.writeLong(msg.maxDecisionNanos);
|
|
||||||
buf.writeBoolean(msg.turnTimerEnabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleInfo> {
|
|
||||||
public Decoder() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketBattleInfo decode(FriendlyByteBuf buf) {
|
|
||||||
int sideACount = buf.readInt();
|
int sideACount = buf.readInt();
|
||||||
int sideBCount = buf.readInt();
|
int sideBCount = buf.readInt();
|
||||||
Collection<Integer> sideA = new ArrayList<Integer>(sideACount);
|
this.sideA = new ArrayList<>(sideACount);
|
||||||
Collection<Integer> sideB = new ArrayList<Integer>(sideBCount);
|
this.sideB = new ArrayList<>(sideBCount);
|
||||||
for(int i = 0; i < sideACount; ++i) {
|
for (int i = 0; i < sideACount; ++i) {
|
||||||
sideA.add(buf.readInt());
|
this.sideA.add(buf.readInt());
|
||||||
}
|
}
|
||||||
for(int i = 0; i < sideBCount; ++i) {
|
for (int i = 0; i < sideBCount; ++i) {
|
||||||
sideB.add(buf.readInt());
|
this.sideB.add(buf.readInt());
|
||||||
}
|
}
|
||||||
long decisionNanos = buf.readLong();
|
this.decisionNanos = buf.readLong();
|
||||||
long maxDecisionNanos = buf.readLong();
|
this.maxDecisionNanos = buf.readLong();
|
||||||
boolean turnTimerEnabled = buf.readBoolean();
|
this.turnTimerEnabled = buf.readBoolean();
|
||||||
return new PacketBattleInfo(sideA, sideB, decisionNanos, maxDecisionNanos, turnTimerEnabled);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleInfo> {
|
|
||||||
public Consumer() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketBattleInfo pkt, NetworkEvent.Context ctx) {
|
public void write(FriendlyByteBuf buf) {
|
||||||
ctx.enqueueWork(() -> {
|
buf.writeInt(sideA.size());
|
||||||
|
buf.writeInt(sideB.size());
|
||||||
|
for(Integer id : sideA) {
|
||||||
|
buf.writeInt(id);
|
||||||
|
}
|
||||||
|
for(Integer id : sideB) {
|
||||||
|
buf.writeInt(id);
|
||||||
|
}
|
||||||
|
buf.writeLong(decisionNanos);
|
||||||
|
buf.writeLong(maxDecisionNanos);
|
||||||
|
buf.writeBoolean(turnTimerEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation id() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PayloadHandler {
|
||||||
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
|
public static PayloadHandler getInstance() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketBattleInfo pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
if(TurnBasedMinecraftMod.proxy.getLocalBattle() == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -110,8 +111,10 @@ public class PacketBattleInfo
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
TurnBasedMinecraftMod.proxy.setBattleGuiBattleChanged();
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerEnabled(pkt.turnTimerEnabled);
|
||||||
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
TurnBasedMinecraftMod.proxy.setBattleGuiTurnTimerMax((int)(pkt.maxDecisionNanos / 1000000000L));
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleInfo! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
ctx.setPacketHandled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,33 @@ import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.Utility;
|
import com.burnedkirby.TurnBasedMinecraft.common.Utility;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
|
||||||
|
|
||||||
public class PacketBattleMessage
|
public class PacketBattleMessage implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattlemessage");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(messageType.getValue());
|
||||||
|
buf.writeInt(entityIDFrom);
|
||||||
|
buf.writeInt(entityIDTo);
|
||||||
|
buf.writeUtf(Utility.serializeDimension(dimension));
|
||||||
|
buf.writeInt(amount);
|
||||||
|
buf.writeUtf(custom);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation id() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
{
|
{
|
||||||
ENTERED(0),
|
ENTERED(0),
|
||||||
|
@ -154,47 +173,31 @@ public class PacketBattleMessage
|
||||||
this.custom = custom;
|
this.custom = custom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleMessage> {
|
public PacketBattleMessage(final FriendlyByteBuf buf) {
|
||||||
public Encoder() {}
|
this.messageType = MessageType.valueOf(buf.readInt());
|
||||||
|
this.entityIDFrom = buf.readInt();
|
||||||
@Override
|
this.entityIDTo = buf.readInt();
|
||||||
public void encode(PacketBattleMessage pkt, FriendlyByteBuf buf) {
|
this.dimension = Utility.deserializeDimension(buf.readUtf());
|
||||||
buf.writeInt(pkt.messageType.getValue());
|
this.amount = buf.readInt();
|
||||||
buf.writeInt(pkt.entityIDFrom);
|
this.custom = buf.readUtf();
|
||||||
buf.writeInt(pkt.entityIDTo);
|
|
||||||
buf.writeUtf(Utility.serializeDimension(pkt.dimension));
|
|
||||||
buf.writeInt(pkt.amount);
|
|
||||||
buf.writeUtf(pkt.custom);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleMessage> {
|
public static class PayloadHandler {
|
||||||
public Decoder() {}
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
@Override
|
public static PayloadHandler getInstance() {
|
||||||
public PacketBattleMessage decode(FriendlyByteBuf buf) {
|
return INSTANCE;
|
||||||
return new PacketBattleMessage(
|
|
||||||
MessageType.valueOf(
|
|
||||||
buf.readInt()),
|
|
||||||
buf.readInt(),
|
|
||||||
buf.readInt(),
|
|
||||||
Utility.deserializeDimension(buf.readUtf()),
|
|
||||||
buf.readInt(),
|
|
||||||
buf.readUtf());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleMessage> {
|
public void handleData(final PacketBattleMessage pkt, final PlayPayloadContext ctx) {
|
||||||
public Consumer() {}
|
ctx.workHandler().submitAsync(() -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketBattleMessage pkt, NetworkEvent.Context ctx) {
|
|
||||||
ctx.enqueueWork(() -> {
|
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleMessage! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
ctx.setPacketHandled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,15 @@ import com.burnedkirby.TurnBasedMinecraft.common.Battle;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
|
|
||||||
public class PacketBattleRequestInfo
|
public class PacketBattleRequestInfo implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetbattlerequestinfo");
|
||||||
|
|
||||||
private int battleID;
|
private int battleID;
|
||||||
|
|
||||||
public PacketBattleRequestInfo() {}
|
public PacketBattleRequestInfo() {}
|
||||||
|
@ -18,37 +22,43 @@ public class PacketBattleRequestInfo
|
||||||
this.battleID = battleID;
|
this.battleID = battleID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketBattleRequestInfo> {
|
public PacketBattleRequestInfo(final FriendlyByteBuf buf) {
|
||||||
public Encoder() {}
|
battleID = buf.readInt();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(PacketBattleRequestInfo pkt, FriendlyByteBuf buf) {
|
public void write(FriendlyByteBuf buf) {
|
||||||
buf.writeInt(pkt.battleID);
|
buf.writeInt(battleID);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketBattleRequestInfo> {
|
|
||||||
public Decoder() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketBattleRequestInfo decode(FriendlyByteBuf buf) {
|
public ResourceLocation id() {
|
||||||
return new PacketBattleRequestInfo(buf.readInt());
|
return ID;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketBattleRequestInfo> {
|
public static class PayloadHandler {
|
||||||
public Consumer() {}
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
@Override
|
public static PayloadHandler getInstance() {
|
||||||
public void handle(PacketBattleRequestInfo pkt, NetworkEvent.Context ctx) {
|
return INSTANCE;
|
||||||
ctx.enqueueWork(() -> {
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketBattleRequestInfo pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
Battle b = TurnBasedMinecraftMod.proxy.getBattleManager().getBattleByID(pkt.battleID);
|
||||||
if(b == null) {
|
if(b == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TurnBasedMinecraftMod.getHandler().reply(new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerNanos(), TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(), !TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()), ctx);
|
ctx.replyHandler().send(new PacketBattleInfo(
|
||||||
|
b.getSideAIDs(),
|
||||||
|
b.getSideBIDs(),
|
||||||
|
b.getTimerNanos(),
|
||||||
|
TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationNanos(),
|
||||||
|
!TurnBasedMinecraftMod.proxy.getConfig().isBattleDecisionDurationForever()));
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketBattleRequestInfo! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
ctx.setPacketHandled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,49 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
|
import com.burnedkirby.TurnBasedMinecraft.common.EntityInfo;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PacketEditingMessage
|
public class PacketEditingMessage implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packeteditingmessage");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(FriendlyByteBuf buf) {
|
||||||
|
buf.writeInt(type.getValue());
|
||||||
|
if(entityInfo.classType != null) {
|
||||||
|
buf.writeUtf(entityInfo.classType.getName());
|
||||||
|
} else {
|
||||||
|
buf.writeUtf("unknown");
|
||||||
|
}
|
||||||
|
buf.writeBoolean(entityInfo.ignoreBattle);
|
||||||
|
buf.writeInt(entityInfo.attackPower);
|
||||||
|
buf.writeInt(entityInfo.attackProbability);
|
||||||
|
buf.writeInt(entityInfo.attackVariance);
|
||||||
|
buf.writeUtf(entityInfo.attackEffect.toString());
|
||||||
|
buf.writeInt(entityInfo.attackEffectProbability);
|
||||||
|
buf.writeInt(entityInfo.defenseDamage);
|
||||||
|
buf.writeInt(entityInfo.defenseDamageProbability);
|
||||||
|
buf.writeInt(entityInfo.evasion);
|
||||||
|
buf.writeInt(entityInfo.speed);
|
||||||
|
buf.writeUtf(entityInfo.category);
|
||||||
|
buf.writeInt(entityInfo.decisionAttack);
|
||||||
|
buf.writeInt(entityInfo.decisionDefend);
|
||||||
|
buf.writeInt(entityInfo.decisionFlee);
|
||||||
|
buf.writeUtf(entityInfo.customName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceLocation id() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
|
||||||
public enum Type
|
public enum Type
|
||||||
{
|
{
|
||||||
ATTACK_ENTITY(0),
|
ATTACK_ENTITY(0),
|
||||||
|
@ -87,75 +121,45 @@ public class PacketEditingMessage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketEditingMessage> {
|
public PacketEditingMessage(final FriendlyByteBuf buf) {
|
||||||
public Encoder() {}
|
this.type = Type.valueOf(buf.readInt());
|
||||||
|
this.entityInfo = new EntityInfo();
|
||||||
@Override
|
|
||||||
public void encode(PacketEditingMessage pkt, FriendlyByteBuf buf) {
|
|
||||||
buf.writeInt(pkt.type.getValue());
|
|
||||||
if(pkt.entityInfo.classType != null) {
|
|
||||||
buf.writeUtf(pkt.entityInfo.classType.getName());
|
|
||||||
} else {
|
|
||||||
buf.writeUtf("unknown");
|
|
||||||
}
|
|
||||||
buf.writeBoolean(pkt.entityInfo.ignoreBattle);
|
|
||||||
buf.writeInt(pkt.entityInfo.attackPower);
|
|
||||||
buf.writeInt(pkt.entityInfo.attackProbability);
|
|
||||||
buf.writeInt(pkt.entityInfo.attackVariance);
|
|
||||||
buf.writeUtf(pkt.entityInfo.attackEffect.toString());
|
|
||||||
buf.writeInt(pkt.entityInfo.attackEffectProbability);
|
|
||||||
buf.writeInt(pkt.entityInfo.defenseDamage);
|
|
||||||
buf.writeInt(pkt.entityInfo.defenseDamageProbability);
|
|
||||||
buf.writeInt(pkt.entityInfo.evasion);
|
|
||||||
buf.writeInt(pkt.entityInfo.speed);
|
|
||||||
buf.writeUtf(pkt.entityInfo.category);
|
|
||||||
buf.writeInt(pkt.entityInfo.decisionAttack);
|
|
||||||
buf.writeInt(pkt.entityInfo.decisionDefend);
|
|
||||||
buf.writeInt(pkt.entityInfo.decisionFlee);
|
|
||||||
buf.writeUtf(pkt.entityInfo.customName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketEditingMessage> {
|
|
||||||
public Decoder() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PacketEditingMessage decode(FriendlyByteBuf buf) {
|
|
||||||
Type type = Type.valueOf(buf.readInt());
|
|
||||||
EntityInfo einfo = new EntityInfo();
|
|
||||||
try {
|
try {
|
||||||
einfo.classType = einfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
this.entityInfo.classType = this.entityInfo.getClass().getClassLoader().loadClass(buf.readUtf());
|
||||||
} catch (ClassNotFoundException e) { /* ignored */ }
|
} catch (ClassNotFoundException e) { /* ignored */ }
|
||||||
einfo.ignoreBattle = buf.readBoolean();
|
this.entityInfo.ignoreBattle = buf.readBoolean();
|
||||||
einfo.attackPower = buf.readInt();
|
this.entityInfo.attackPower = buf.readInt();
|
||||||
einfo.attackProbability = buf.readInt();
|
this.entityInfo.attackProbability = buf.readInt();
|
||||||
einfo.attackVariance = buf.readInt();
|
this.entityInfo.attackVariance = buf.readInt();
|
||||||
einfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
this.entityInfo.attackEffect = EntityInfo.Effect.fromString(buf.readUtf());
|
||||||
einfo.attackEffectProbability = buf.readInt();
|
this.entityInfo.attackEffectProbability = buf.readInt();
|
||||||
einfo.defenseDamage = buf.readInt();
|
this.entityInfo.defenseDamage = buf.readInt();
|
||||||
einfo.defenseDamageProbability = buf.readInt();
|
this.entityInfo.defenseDamageProbability = buf.readInt();
|
||||||
einfo.evasion = buf.readInt();
|
this.entityInfo.evasion = buf.readInt();
|
||||||
einfo.speed = buf.readInt();
|
this.entityInfo.speed = buf.readInt();
|
||||||
einfo.category = buf.readUtf();
|
this.entityInfo.category = buf.readUtf();
|
||||||
einfo.decisionAttack = buf.readInt();
|
this.entityInfo.decisionAttack = buf.readInt();
|
||||||
einfo.decisionDefend = buf.readInt();
|
this.entityInfo.decisionDefend = buf.readInt();
|
||||||
einfo.decisionFlee = buf.readInt();
|
this.entityInfo.decisionFlee = buf.readInt();
|
||||||
einfo.customName = buf.readUtf();
|
this.entityInfo.customName = buf.readUtf();
|
||||||
return new PacketEditingMessage(type, einfo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketEditingMessage> {
|
public static class PayloadHandler {
|
||||||
public Consumer() {}
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
@Override
|
public static PayloadHandler getInstance() {
|
||||||
public void handle(PacketEditingMessage pkt, NetworkEvent.Context ctx) {
|
return INSTANCE;
|
||||||
ctx.enqueueWork(() -> {
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketEditingMessage pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketEditingMessage! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
ctx.setPacketHandled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,14 +3,16 @@ package com.burnedkirby.TurnBasedMinecraft.common.networking;
|
||||||
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
||||||
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.neoforged.api.distmarker.Dist;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.neoforged.fml.DistExecutor;
|
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.neoforged.fml.loading.FMLEnvironment;
|
import net.neoforged.fml.loading.FMLEnvironment;
|
||||||
import net.neoforged.neoforge.network.NetworkEvent;
|
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||||
import net.neoforged.neoforge.network.simple.MessageFunctions;
|
|
||||||
|
|
||||||
public class PacketGeneralMessage
|
public class PacketGeneralMessage implements CustomPacketPayload
|
||||||
{
|
{
|
||||||
|
public static final ResourceLocation ID = new ResourceLocation(TurnBasedMinecraftMod.MODID, "network_packetgeneralmessage");
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
@ -27,35 +29,36 @@ public class PacketGeneralMessage
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Encoder implements MessageFunctions.MessageEncoder<PacketGeneralMessage> {
|
public PacketGeneralMessage(final FriendlyByteBuf buf) {
|
||||||
public Encoder() {}
|
this.message = buf.readUtf();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(PacketGeneralMessage pkt, FriendlyByteBuf buf) {
|
public void write(FriendlyByteBuf buf) {
|
||||||
buf.writeUtf(pkt.message);
|
buf.writeUtf(message);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static class Decoder implements MessageFunctions.MessageDecoder<PacketGeneralMessage> {
|
|
||||||
public Decoder() {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PacketGeneralMessage decode(FriendlyByteBuf buf) {
|
public ResourceLocation id() {
|
||||||
return new PacketGeneralMessage(buf.readUtf());
|
return ID;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Consumer implements MessageFunctions.MessageConsumer<PacketGeneralMessage> {
|
public static class PayloadHandler {
|
||||||
public Consumer() {}
|
private static final PayloadHandler INSTANCE = new PayloadHandler();
|
||||||
|
|
||||||
@Override
|
public static PayloadHandler getInstance() {
|
||||||
public void handle(PacketGeneralMessage pkt, NetworkEvent.Context ctx) {
|
return INSTANCE;
|
||||||
ctx.enqueueWork(() -> {
|
}
|
||||||
|
|
||||||
|
public void handleData(final PacketGeneralMessage pkt, final PlayPayloadContext ctx) {
|
||||||
|
ctx.workHandler().submitAsync(() -> {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
TurnBasedMinecraftMod.proxy.handlePacket(pkt, ctx);
|
||||||
}
|
}
|
||||||
|
}).exceptionally(e -> {
|
||||||
|
ctx.packetHandler().disconnect(Component.literal("Exception handling PacketGeneralMessage! " + e.getMessage()));
|
||||||
|
return null;
|
||||||
});
|
});
|
||||||
ctx.setPacketHandled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,14 +33,14 @@ description='''
|
||||||
Implements turn-based-battle in Minecraft.
|
Implements turn-based-battle in Minecraft.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
logoFile="/assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
|
logoFile="assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
|
||||||
|
|
||||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
[[dependencies.com_burnedkirby_turnbasedminecraft]] #optional
|
||||||
# the modid of the dependency
|
# the modid of the dependency
|
||||||
modId="neoforge" #mandatory
|
modId="neoforge" #mandatory
|
||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory=true #mandatory
|
type="required" #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange="${neo_version_range}" #mandatory
|
versionRange="${neo_version_range}" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
|
@ -50,7 +50,7 @@ logoFile="/assets/com_burnedkirby_turnbasedminecraft/tbmm_icon.png"
|
||||||
# Here's another dependency
|
# Here's another dependency
|
||||||
[[dependencies.com_burnedkirby_turnbasedminecraft]]
|
[[dependencies.com_burnedkirby_turnbasedminecraft]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
type="required"
|
||||||
versionRange="${minecraft_version_range}"
|
versionRange="${minecraft_version_range}"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
|
|
Loading…
Reference in a new issue