import com.burnedkirby.TurnBasedMinecraft.common.networking.*;
import com.mojang.brigadier.LiteralMessage;
import com.mojang.brigadier.Message;
+import com.mojang.brigadier.arguments.BoolArgumentType;
+import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.minecraftforge.fml.event.lifecycle.FMLDedicatedServerSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
+import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.PacketDistributor;
import net.minecraftforge.fml.network.simple.SimpleChannel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-@Mod(value = TurnBasedMinecraftMod.MODID)
+@Mod(TurnBasedMinecraftMod.MODID)
public class TurnBasedMinecraftMod
{
- public static final String MODID = "com.burnedkirby.turnbasedminecraft";
+ public static final String MODID = "com_burnedkirby_turnbasedminecraft";
public static final String NAME = "Turn Based Minecraft Mod";
- public static final String VERSION = "1.8";
+ public static final String VERSION = "1.9";
public static final String CONFIG_FILENAME = "TBM_Config.toml";
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
public static final String CONFIG_FILE_PATH = CONFIG_DIRECTORY + CONFIG_FILENAME;
public static final String DEFAULT_CONFIG_FILE_PATH = CONFIG_DIRECTORY + DEFAULT_CONFIG_FILENAME;
- public static final String CONFIG_INTERNAL_PATH = "/assets/TurnBasedMinecraft/" + CONFIG_FILENAME;
+ public static final String CONFIG_INTERNAL_PATH = "/assets/com_burnedkirby_turnbasedminecraft/" + CONFIG_FILENAME;
public static final String MUSIC_ROOT = CONFIG_DIRECTORY + "Music/";
public static final String MUSIC_SILLY = MUSIC_ROOT + "silly/";
public static final String MUSIC_BATTLE = MUSIC_ROOT + "battle/";
public static CommonProxy proxy;
- @SubscribeEvent
- public void firstInit(FMLCommonSetupEvent event)
+ public TurnBasedMinecraftMod() {
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::firstInit);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitClient);
+ FMLJavaModLoadingContext.get().getModEventBus().addListener(this::secondInitServer);
+
+ MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ private void firstInit(final FMLCommonSetupEvent event)
{
proxy = DistExecutor.runForDist(()->()->new ClientProxy(), ()->()->new CommonProxy());
- proxy.initialize();
proxy.setLogger(logger);
-
+ proxy.initialize();
+
// register packets
int packetHandlerID = 0;
HANDLER.registerMessage(
// register event handler(s)
MinecraftForge.EVENT_BUS.register(new AttackEventHandler());
MinecraftForge.EVENT_BUS.register(new PlayerJoinEventHandler());
+
+ logger.debug("Init com_burnedkirby_turnbasedminecraft");
}
- @SubscribeEvent
- public void secondInitClient(FMLClientSetupEvent event)
+ private void secondInitClient(final FMLClientSetupEvent event)
{
proxy.postInit();
}
- @SubscribeEvent
- public void secondInitServer(FMLDedicatedServerSetupEvent event)
+ private void secondInitServer(final FMLDedicatedServerSetupEvent event)
{
proxy.postInit();
}
} else if(editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else {
- proxy.setEditingPlayer(c.getSource().asPlayer());
+ proxy.setEditingPlayer(player);
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
- logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getUnformattedComponentText() + "\"");
+ logger.info("Begin editing TBM Entity for player \"" + player.getDisplayName().getUnformattedComponentText() + "\" (\"" + c.getSource().getName() + "\")");
}
return 1;
})
- .then(Commands.argument("action", StringArgumentType.word())
+ .then(Commands.literal("finish")
.executes(c -> {
- String action = StringArgumentType.getString(c, "action").toLowerCase();
ServerPlayerEntity player = c.getSource().asPlayer();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
- if (action.equals("finish")) {
- 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"));
- proxy.removeEditingInfo(player.getEntityId());
- } else {
- proxy.removeEditingInfo(player.getEntityId());
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
- }
- } else if (action.equals("cancel")) {
+ 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"));
proxy.removeEditingInfo(player.getEntityId());
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
- } else if (action.equals("edit")) {
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else {
- Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ proxy.removeEditingInfo(player.getEntityId());
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Entity info saved in config and loaded."));
}
} else if(editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else {
- if(action.equals("custom")) {
- proxy.setEditingPlayer(player);
- proxy.getEditingInfo(player.getEntityId()).isEditingCustomName = true;
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ .then(Commands.literal("cancel")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null) {
+ proxy.removeEditingInfo(player.getEntityId());
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketGeneralMessage("Cancelled editing entry."));
+ }
+ return 1;
+ }))
+ .then(Commands.literal("custom")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ Message exceptionMessage = new LiteralMessage("Invalid action for tbm-edit");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ proxy.setEditingPlayer(player);
+ proxy.getEditingInfo(player.getEntityId()).isEditingCustomName = true;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getUnformattedComponentText() + "\" (\"" + c.getSource().getName() + "\")");
+ }
+ return 1;
+ }))
+ .then(Commands.literal("edit")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null){
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.literal("ignoreBattle")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
+ } else if(editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
- logger.info("Begin editing custom TBM Entity for player \"" + player.getDisplayName().getUnformattedComponentText() + "\'");
} else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
}
- }
- return 1;
- })
- .then(Commands.argument("category", StringArgumentType.word())
+ return 1;
+ })
+ .then(Commands.argument("ignoreBattle", BoolArgumentType.bool())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ boolean ignoreBattle = BoolArgumentType.getBool(c, "ignoreBattle");
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.ignoreBattle = ignoreBattle;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("attackPower")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("attackPower", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int attackPower = IntegerArgumentType.getInteger(c, "attackPower");
+ if(attackPower < 0) {
+ attackPower = 0;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.attackPower = attackPower;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("attackProbability")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("attackProbability", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int attackProbability = IntegerArgumentType.getInteger(c, "attackProbability");
+ if(attackProbability < 0) {
+ attackProbability = 0;
+ } else if(attackProbability > 100) {
+ attackProbability = 100;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.attackProbability = attackProbability;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("attackVariance")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("attackVariance", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int attackVariance = IntegerArgumentType.getInteger(c, "attackVariance");
+ if(attackVariance < 0) {
+ attackVariance = 0;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.attackVariance = attackVariance;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("attackEffect")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("attackEffect", StringArgumentType.word())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ EntityInfo.Effect effect = EntityInfo.Effect.fromString(StringArgumentType.getString(c, "attackEffect"));
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.attackEffect = effect;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("attackEffectProbability")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("attackEffectProbability", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int attackEffectProbability = IntegerArgumentType.getInteger(c, "attackEffectProbability");
+ if(attackEffectProbability < 0) {
+ attackEffectProbability = 0;
+ } else if(attackEffectProbability > 100) {
+ attackEffectProbability = 100;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.attackEffectProbability = attackEffectProbability;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("defenseDamage")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("defenseDamage", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int defenseDamage = IntegerArgumentType.getInteger(c, "defenseDamage");
+ if(defenseDamage < 0) {
+ defenseDamage = 0;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.defenseDamage = defenseDamage;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("defenseDamageProbability")
.executes(c -> {
- String action = StringArgumentType.getString(c, "action").toLowerCase();
- String category = StringArgumentType.getString(c, "category");
ServerPlayerEntity player = c.getSource().asPlayer();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
- if (action.equals("edit")) {
- switch (category) {
- case "ignoreBattle":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE));
- break;
- case "attackPower":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER));
- break;
- case "attackProbability":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY));
- break;
- case "attackVariance":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE));
- break;
- case "attackEffect":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT));
- break;
- case "attackEffectProbability":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY));
- break;
- case "defenseDamage":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE));
- break;
- case "defenseDamageProbability":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
- break;
- case "evasion":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
- break;
- case "speed":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
- break;
- case "category":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
- break;
- case "decisionAttack":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
- break;
- case "decisionDefend":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
- break;
- case "decisionFlee":
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
- break;
- default:
- Message exceptionMessage = new LiteralMessage("Invalid argument for \"/tbm-edit edit <category>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("defenseDamageProbability", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int defenseDamageProbability = IntegerArgumentType.getInteger(c, "defenseDamageProbability");
+ if(defenseDamageProbability < 0) {
+ defenseDamageProbability = 0;
+ } else if(defenseDamageProbability > 100) {
+ defenseDamageProbability = 100;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.defenseDamageProbability = defenseDamageProbability;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("evasion")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("evasion", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int evasion = IntegerArgumentType.getInteger(c, "evasion");
+ if(evasion < 0) {
+ evasion = 0;
+ } else if(evasion > 100) {
+ evasion = 100;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.evasion = evasion;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("speed")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("speed", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int speed = IntegerArgumentType.getInteger(c, "speed");
+ if(speed < 0) {
+ speed = 0;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.speed = speed;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else {
- Message exceptionMessage = new LiteralMessage("Invalid argument");
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
}
- } else if(editingInfo != null){
+ return 1;
+ }))
+ )
+ .then(Commands.literal("category")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY));
+ } else if(editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else {
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
}
return 1;
})
- .then(Commands.argument("value", StringArgumentType.greedyString()))
+ .then(Commands.argument("category", StringArgumentType.word())
.executes(c -> {
- String action = StringArgumentType.getString(c, "action").toLowerCase();
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
String category = StringArgumentType.getString(c, "category");
- String value = StringArgumentType.getString(c, "value").toLowerCase();
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.category = category;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("decisionAttack")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("decisionAttack", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int decisionAttack = IntegerArgumentType.getInteger(c, "decisionAttack");
+ if(decisionAttack < 0) {
+ decisionAttack = 0;
+ } else if(decisionAttack > 100) {
+ decisionAttack = 100;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.decisionAttack = decisionAttack;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("decisionDefend")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("decisionDefend", IntegerArgumentType.integer())
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int decisionDefend = IntegerArgumentType.getInteger(c, "decisionDefend");
+ if(decisionDefend < 0) {
+ decisionDefend = 0;
+ } else if(decisionDefend > 100) {
+ decisionDefend = 100;
+ }
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ editingInfo.entityInfo.decisionDefend = decisionDefend;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ }))
+ )
+ .then(Commands.literal("decisionFlee")
+ .executes(c -> {
+ ServerPlayerEntity player = c.getSource().asPlayer();
+ EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE));
+ } else if(editingInfo != null) {
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
+ } else {
+ Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
+ throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
+ }
+ return 1;
+ })
+ .then(Commands.argument("decisionFlee", IntegerArgumentType.integer())
+ .executes(c -> {
ServerPlayerEntity player = c.getSource().asPlayer();
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getEntityId());
+ int decisionFlee = IntegerArgumentType.getInteger(c, "decisionFlee");
if(editingInfo != null && !editingInfo.isPendingEntitySelection) {
- if (action.equals("edit")) {
- switch (category) {
- case "ignoreBattle":
- if (value.equals("true")) {
- editingInfo.entityInfo.ignoreBattle = true;
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } else if (value.equals("false")) {
- editingInfo.entityInfo.ignoreBattle = false;
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } else {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit ignoreBattle <boolean>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "attackPower":
- try {
- editingInfo.entityInfo.attackPower = Integer.parseInt(value);
- if (editingInfo.entityInfo.attackPower < 0) {
- editingInfo.entityInfo.attackPower = 0;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit attackPower <integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "attackProbability":
- try {
- editingInfo.entityInfo.attackProbability = Integer.parseInt(value);
- if (editingInfo.entityInfo.attackProbability < 0) {
- editingInfo.entityInfo.attackProbability = 0;
- } else if (editingInfo.entityInfo.attackProbability > 100) {
- editingInfo.entityInfo.attackProbability = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit attackProbability <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "attackVariance":
- try {
- editingInfo.entityInfo.attackVariance = Integer.parseInt(value);
- if (editingInfo.entityInfo.attackVariance < 0) {
- editingInfo.entityInfo.attackVariance = 0;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit attackVariance <integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "attackEffect":
- editingInfo.entityInfo.attackEffect = EntityInfo.Effect.fromString(value);
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- break;
- case "attackEffectProbability":
- try {
- editingInfo.entityInfo.attackEffectProbability = Integer.parseInt(value);
- if (editingInfo.entityInfo.attackEffectProbability < 0) {
- editingInfo.entityInfo.attackEffectProbability = 0;
- } else if (editingInfo.entityInfo.attackEffectProbability > 100) {
- editingInfo.entityInfo.attackEffectProbability = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit attackEffectProbability <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "defenseDamage":
- try {
- editingInfo.entityInfo.defenseDamage = Integer.parseInt(value);
- if (editingInfo.entityInfo.defenseDamage < 0) {
- editingInfo.entityInfo.defenseDamage = 0;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit defenseDamage <integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "defenseDamageProbability":
- try {
- editingInfo.entityInfo.defenseDamageProbability = Integer.parseInt(value);
- if (editingInfo.entityInfo.defenseDamageProbability < 0) {
- editingInfo.entityInfo.defenseDamageProbability = 0;
- } else if (editingInfo.entityInfo.defenseDamageProbability > 100) {
- editingInfo.entityInfo.defenseDamageProbability = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit defenseDamageProbability <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "evasion":
- try {
- editingInfo.entityInfo.evasion = Integer.parseInt(value);
- if (editingInfo.entityInfo.evasion < 0) {
- editingInfo.entityInfo.evasion = 0;
- } else if (editingInfo.entityInfo.evasion > 100) {
- editingInfo.entityInfo.evasion = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit evasion <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "speed":
- try {
- editingInfo.entityInfo.speed = Integer.parseInt(value);
- if (editingInfo.entityInfo.speed < 0) {
- editingInfo.entityInfo.speed = 0;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit speed <integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "category":
- editingInfo.entityInfo.category = value;
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- break;
- case "decisionAttack":
- try {
- editingInfo.entityInfo.decisionAttack = Integer.parseInt(value);
- if (editingInfo.entityInfo.decisionAttack < 0) {
- editingInfo.entityInfo.decisionAttack = 0;
- } else if (editingInfo.entityInfo.decisionAttack > 100) {
- editingInfo.entityInfo.decisionAttack = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit decisionAttack <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "decisionDefend":
- try {
- editingInfo.entityInfo.decisionDefend = Integer.parseInt(value);
- if (editingInfo.entityInfo.decisionDefend < 0) {
- editingInfo.entityInfo.decisionDefend = 0;
- } else if (editingInfo.entityInfo.decisionDefend > 100) {
- editingInfo.entityInfo.decisionDefend = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit decisionDefend <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- case "decisionFlee":
- try {
- editingInfo.entityInfo.decisionFlee = Integer.parseInt(value);
- if (editingInfo.entityInfo.decisionFlee < 0) {
- editingInfo.entityInfo.decisionFlee = 0;
- } else if (editingInfo.entityInfo.decisionFlee > 100) {
- editingInfo.entityInfo.decisionFlee = 100;
- }
- getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
- } catch (NumberFormatException e) {
- Message exceptionMessage = new LiteralMessage("Invalid value for \"/tbm-edit edit decisionFlee <percentage-integer>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- break;
- default:
- Message exceptionMessage = new LiteralMessage("Invalid category for \"/tbm-edit edit <category> <value>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
- } else {
- Message exceptionMessage = new LiteralMessage("Invalid args for \"/tbm-edit <args...>\"");
- throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
- }
+ editingInfo.entityInfo.decisionFlee = decisionFlee;
+ getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
} else if(editingInfo != null) {
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
} else {
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
}
return 1;
- })
- ))
+ }))
+ )
+ )
);
}
# decision_flee_probability: Percentage of entity choosing to flee on turn.
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityBlaze"
+name = "net.minecraft.entity.monster.BlazeEntity"
attack_power = 5
attack_probability = 50
attack_effect = "fire"
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityCaveSpider"
+name = "net.minecraft.entity.monster.CaveSpiderEntity"
attack_power = 2
attack_probability = 75
attack_effect = "poison"
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityCreeper"
+name = "net.minecraft.entity.monster.CreeperEntity"
ignore_battle = true
attack_power = 15
attack_probability = 17
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityElderGuardian"
+name = "net.minecraft.entity.monster.DrownedEntity"
+attack_power = 3
+attack_probability = 70
+attack_variance = 2
+evasion = 5
+category = "monster"
+speed = 25
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+
+[[server_config.entity]]
+name = "net.minecraft.entity.monster.ElderGuardianEntity"
attack_power = 8
attack_probability = 65
defense_damage = 2
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityEnderman"
+name = "net.minecraft.entity.monster.EndermanEntity"
attack_power = 7
attack_probability = 80
evasion = 40
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityEndermite"
+name = "net.minecraft.entity.monster.EndermiteEntity"
attack_power = 2
attack_probability = 80
evasion = 40
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityEvoker"
+name = "net.minecraft.entity.monster.EvokerEntity"
attack_power = 6
attack_probability = 60
evasion = 35
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityGhast"
+name = "net.minecraft.entity.monster.GhastEntity"
ignore_battle = true
attack_power = 13
attack_probability = 20
decision_flee_probability = 25
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityGiantZombie"
+name = "net.minecraft.entity.monster.GiantEntity"
attack_power = 11
attack_probability = 35
evasion = 2
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityGuardian"
+name = "net.minecraft.entity.monster.GuardianEntity"
attack_power = 6
attack_probability = 55
defense_damage = 2
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityHusk"
+name = "net.minecraft.entity.monster.HuskEntity"
attack_power = 3
attack_probability = 70
attack_effect = "hunger"
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityIronGolem"
+name = "net.minecraft.entity.monster.IllusionerEntity"
+attack_power = 2
+attack_probability = 70
+attack_variance = 2
+evasion = 5
+category = "monster"
+speed = 35
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+
+[[server_config.entity]]
+name = "net.minecraft.entity.monster.IronGolemEntity"
attack_power = 14
attack_probability = 85
attack_variance = 7
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityMagmaCube"
+name = "net.minecraft.entity.monster.MagmaCubeEntity"
attack_power = 3
attack_probability = 35
evasion = 12
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityPigZombie"
-attack_power = 8
-attack_probability = 70
+name = "net.minecraft.entity.monster.PhantomEntity"
+attack_power = 2
+attack_probability = 90
+attack_variance = 1
+evasion = 35
+category = "monster"
+speed = 65
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+
+[[server_config.entity]]
+name = "net.minecraft.entity.monster.PillagerEntity"
+attack_power = 3
+attack_probability = 60
+attack_variance = 1
evasion = 10
category = "monster"
-speed = 50
+speed = 30
decision_attack_probability = 100
decision_defend_probability = 0
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityPolarBear"
-attack_power = 6
-attack_probability = 67
-evasion = 5
-category = "animal"
+name = "net.minecraft.entity.monster.RavagerEntity"
+attack_power = 12
+attack_probability = 70
+attack_variance = 4
+evasion = 4
+category = "monster"
speed = 35
-decision_attack_probability = 100
+decision_attack_probability = 90
decision_defend_probability = 0
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityShulker"
+name = "net.minecraft.entity.monster.ShulkerEntity"
attack_power = 4
attack_probability = 80
evasion = 15
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntitySilverfish"
+name = "net.minecraft.entity.monster.SilverfishEntity"
attack_power = 1
attack_probability = 85
evasion = 37
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntitySkeleton"
+name = "net.minecraft.entity.monster.SkeletonEntity"
attack_power = 3
attack_probability = 75
attack_variance = 1
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntitySlime"
+name = "net.minecraft.entity.monster.SlimeEntity"
attack_power = 2
attack_probability = 35
evasion = 10
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntitySnowman"
-attack_power = 0
-attack_probability = 80
-evasion = 5
-category = "passive"
-speed = 60
-decision_attack_probability = 100
-decision_defend_probability = 0
-decision_flee_probability = 0
-
-[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntitySpider"
+name = "net.minecraft.entity.monster.SpiderEntity"
attack_power = 2
attack_probability = 70
evasion = 25
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityStray"
+name = "net.minecraft.entity.monster.StrayEntity"
attack_power = 3
attack_probability = 75
attack_variance = 1
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityVex"
+name = "net.minecraft.entity.monster.VexEntity"
attack_power = 9
attack_probability = 65
evasion = 30
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityVindicator"
+name = "net.minecraft.entity.monster.VindicatorEntity"
attack_power = 13
attack_probability = 70
evasion = 10
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityWitch"
+name = "net.minecraft.entity.monster.WitchEntity"
attack_power = 5
attack_probability = 75
attack_variance = 1
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityWitherSkeleton"
+name = "net.minecraft.entity.monster.WitherSkeletonEntity"
attack_power = 8
attack_probability = 70
attack_effect = "wither"
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityZombie"
+name = "net.minecraft.entity.monster.ZombieEntity"
attack_power = 3
attack_probability = 70
evasion = 5
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.monster.EntityZombieVillager"
+name = "net.minecraft.entity.monster.ZombiePigmanEntity"
+attack_power = 8
+attack_probability = 70
+evasion = 10
+category = "monster"
+speed = 50
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+
+[[server_config.entity]]
+name = "net.minecraft.entity.monster.ZombieVillagerEntity"
attack_power = 3
attack_probability = 70
evasion = 5
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityBat"
+name = "net.minecraft.entity.passive.BatEntity"
attack_power = 0
attack_probability = 70
evasion = 35
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityChicken"
+name = "net.minecraft.entity.passive.ChickenEntity"
attack_power = 0
attack_probability = 70
evasion = 10
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityCow"
+name = "net.minecraft.entity.passive.CowEntity"
attack_power = 0
attack_probability = 50
evasion = 1
decision_flee_probability = 80
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityDonkey"
+name = "net.minecraft.entity.passive.DolphinEntity"
+attack_power = 3
+attack_probability = 80
+attack_variance = 1
+evasion = 45
+category = "passive"
+speed = 75
+decision_attack_probability = 70
+decision_defend_probability = 0
+decision_flee_probability = 30
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.horse.DonkeyEntity"
attack_power = 0
attack_probability = 70
evasion = 10
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityHorse"
+name = "net.minecraft.entity.passive.horse.HorseEntity"
attack_power = 0
attack_probability = 70
evasion = 10
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityLlama"
+name = "net.minecraft.entity.passive.horse.LlamaEntity"
attack_power = 1
attack_probability = 70
evasion = 10
decision_flee_probability = 25
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityMooshroom"
+name = "net.minecraft.entity.passive.MooshroomEntity"
attack_power = 0
attack_probability = 70
evasion = 1
decision_flee_probability = 80
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityMule"
+name = "net.minecraft.entity.passive.horse.MuleEntity"
attack_power = 0
attack_probability = 70
evasion = 10
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityOcelot"
+name = "net.minecraft.entity.passive.OcelotEntity"
attack_power = 1
attack_probability = 70
attack_variance = 1
-evasion = 10
+evasion = 30
category = "passive"
speed = 75
decision_attack_probability = 0
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityParrot"
+name = "net.minecraft.entity.passive.PandaEntity"
+attack_power = 6
+attack_probability = 60
+evasion = 10
+category = "passive"
+speed = 30
+decision_attack_probability = 45
+decision_defend_probability = 25
+decision_flee_probability = 30
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.ParrotEntity"
attack_power = 0
attack_probability = 70
evasion = 35
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityPig"
+name = "net.minecraft.entity.passive.PigEntity"
attack_power = 0
attack_probability = 70
evasion = 10
decision_flee_probability = 85
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityRabbit"
+name = "net.minecraft.entity.passive.PolarBearEntity"
+attack_power = 6
+attack_probability = 67
+evasion = 5
+category = "animal"
+speed = 35
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.RabbitEntity"
attack_power = 0
attack_probability = 70
evasion = 40
decision_flee_probability = 100
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntitySheep"
+name = "net.minecraft.entity.passive.SheepEntity"
attack_power = 0
attack_probability = 70
evasion = 5
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntitySkeletonHorse"
+name = "net.minecraft.entity.passive.horse.SkeletonHorseEntity"
attack_power = 0
attack_probability = 70
evasion = 5
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntitySquid"
+name = "net.minecraft.entity.passive.SnowGolemEntity"
+attack_power = 0
+attack_probability = 80
+evasion = 5
+category = "passive"
+speed = 60
+decision_attack_probability = 100
+decision_defend_probability = 0
+decision_flee_probability = 0
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.SquidEntity"
attack_power = 0
attack_probability = 70
evasion = 15
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityVillager"
+name = "net.minecraft.entity.passive.horse.TraderLlamaEntity"
+attack_power = 1
+attack_probability = 70
+evasion = 10
+category = "passive"
+speed = 50
+decision_attack_probability = 65
+decision_defend_probability = 0
+decision_flee_probability = 25
+
+[[server_config.entity]]
+name = "net.minecraft.entity.merchant.villager.VillagerEntity"
attack_power = 0
attack_probability = 70
evasion = 5
decision_flee_probability = 80
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityWolf"
+name = "net.minecraft.entity.passive.WolfEntity"
attack_power = 4
attack_probability = 70
evasion = 20
decision_flee_probability = 5
[[server_config.entity]]
-name = "net.minecraft.entity.passive.EntityZombieHorse"
+name = "net.minecraft.entity.passive.horse.ZombieHorseEntity"
attack_power = 0
attack_probability = 70
evasion = 8
decision_flee_probability = 90
[[server_config.entity]]
-name = "net.minecraft.entity.boss.EntityDragon"
+name = "net.minecraft.entity.passive.fish.CodEntity"
+attack_power = 0
+attack_probability = 50
+evasion = 50
+category = "passive"
+speed = 75
+decision_attack_probability = 25
+decision_defend_probability = 0
+decision_flee_probability = 75
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.fish.PufferfishEntity"
+attack_power = 0
+attack_probability = 50
+defense_damage = 3
+defense_damage_probability = 75
+evasion = 25
+category = "passive"
+speed = 45
+decision_attack_probability = 35
+decision_defend_probability = 0
+decision_flee_probability = 65
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.fish.SalmonEntity"
+attack_power = 0
+attack_probability = 50
+evasion = 50
+category = "passive"
+speed = 75
+decision_attack_probability = 25
+decision_defend_probability = 0
+decision_flee_probability = 75
+
+[[server_config.entity]]
+name = "net.minecraft.entity.passive.fish.TropicalFishEntity"
+attack_power = 0
+attack_probability = 50
+evasion = 50
+category = "passive"
+speed = 75
+decision_attack_probability = 25
+decision_defend_probability = 0
+decision_flee_probability = 75
+
+[[server_config.entity]]
+name = "net.minecraft.entity.boss.dragon.EnderDragonEntity"
attack_power = 10
attack_probability = 70
attack_variance = 2
decision_flee_probability = 0
[[server_config.entity]]
-name = "net.minecraft.entity.boss.EntityWither"
+name = "net.minecraft.entity.boss.WitherEntity"
attack_power = 8
attack_probability = 70
attack_effect = "wither"