diff --git a/Changelog.md b/Changelog.md index ff42673..ac1ec89 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,9 @@ Fix bug where player can start battle with self. Change config to use ".toml" instead of ".xml". +Added command "/tbm-edit" that allows OPs to edit entity entries for TBM. +Can be used to add mobs from other mods easily. + Change how battle info text is displayed. # Version 1.5 diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleGui.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleGui.java index 631a628..44e97d0 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleGui.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleGui.java @@ -36,7 +36,7 @@ public class BattleGui extends GuiScreen private int value; - private MenuState(int value) + MenuState(int value) { this.value = value; } @@ -78,7 +78,7 @@ public class BattleGui extends GuiScreen private int value; - private ButtonAction(int value) + ButtonAction(int value) { this.value = value; } diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleMusic.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleMusic.java index f5d85d3..dd784f5 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleMusic.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/client/BattleMusic.java @@ -88,11 +88,7 @@ public class BattleMusic return false; } String ext = name.substring(extIndex + 1).toLowerCase(); - if(ext.equals("mid") || ext.equals("wav")) - { - return true; - } - return false; + return ext.equals("mid") || ext.equals("wav"); } }); for(File f : battleFiles) @@ -110,11 +106,7 @@ public class BattleMusic return false; } String ext = name.substring(extIndex + 1).toLowerCase(); - if(ext.equals("mid") || ext.equals("wav")) - { - return true; - } - return false; + return ext.equals("mid") || ext.equals("wav"); } }); for(File f : sillyFiles) diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/client/ClientProxy.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/client/ClientProxy.java index c71788c..e848231 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/client/ClientProxy.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/client/ClientProxy.java @@ -168,6 +168,12 @@ public class ClientProxy extends CommonProxy Minecraft.getMinecraft().player.sendMessage(prefix); } + @Override + public void displayTextComponent(ITextComponent text) + { + Minecraft.getMinecraft().player.sendMessage(text); + } + @Override public Entity getEntityByID(int id) { diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/AttackEventHandler.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/AttackEventHandler.java index 589798e..f5fc63a 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/AttackEventHandler.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/AttackEventHandler.java @@ -4,6 +4,8 @@ import java.util.Iterator; import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleMessage; +import com.seodisparate.TurnBasedMinecraft.common.networking.PacketEditingMessage; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -59,8 +61,32 @@ public class AttackEventHandler { return; } - Config config = TurnBasedMinecraftMod.proxy.getConfig(); - BattleManager battleManager = TurnBasedMinecraftMod.proxy.getBattleManager(); + CommonProxy proxy = TurnBasedMinecraftMod.proxy; + Config config = proxy.getConfig(); + BattleManager battleManager = proxy.getBattleManager(); + // handle edit entity, pick entity via attack + { + EditingInfo editingInfo = null; + if(event.getSource().getTrueSource() != null && event.getEntity() != null) + { + editingInfo = proxy.getEditingInfo(event.getSource().getTrueSource().getEntityId()); + if(editingInfo != null && editingInfo.isPendingEntitySelection) + { + editingInfo.isPendingEntitySelection = false; + event.setCanceled(true); + editingInfo.entityInfo = config.getMatchingEntityInfo(event.getEntity()); + if(editingInfo.entityInfo == null) + { + editingInfo.entityInfo = new EntityInfo(); + editingInfo.entityInfo.classType = event.getEntity().getClass(); + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)editingInfo.editor); + return; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)editingInfo.editor); + return; + } + } + } if((event.getEntity() != null && battleManager.isRecentlyLeftBattle(event.getEntity().getEntityId())) || (event.getSource().getTrueSource() != null && battleManager.isRecentlyLeftBattle(event.getSource().getTrueSource().getEntityId()))) { diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/Battle.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/Battle.java index 9f8d3c1..ba66980 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/Battle.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/Battle.java @@ -20,7 +20,6 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBow; import net.minecraft.item.ItemFood; @@ -63,7 +62,7 @@ public class Battle private int value; private static Map map = new HashMap(); - private State(int value) + State(int value) { this.value = value; } @@ -99,7 +98,7 @@ public class Battle private int value; private static Map map = new HashMap(); - private Decision(int value) + Decision(int value) { this.value = value; } @@ -892,11 +891,11 @@ public class Battle int hitChance = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability(); if(target.entity instanceof EntityPlayer) { - hitChance -= TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion(); + hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; } else { - hitChance -= target.entityInfo.evasion; + hitChance = hitChance * (100 - target.entityInfo.evasion) / 100; } if(hitChance < TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage()) { @@ -999,11 +998,11 @@ public class Battle int hitChance = next.entityInfo.attackProbability; if(target.entity instanceof EntityPlayer) { - hitChance -= TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion(); + hitChance = hitChance * (100 - TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion()) / 100; } else { - hitChance -= target.entityInfo.evasion; + hitChance = hitChance * (100 - target.entityInfo.evasion) / 100; } if(hitChance < TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage()) { @@ -1020,6 +1019,10 @@ public class Battle { damageAmount += (int)(Math.random() * (next.entityInfo.attackVariance * 2 + 1)) - next.entityInfo.attackVariance; } + if(damageAmount < 0) + { + damageAmount = 0; + } // attack final Entity nextEntity = next.entity; final EntityInfo nextEntityInfo = next.entityInfo; diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommandTBMEdit.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommandTBMEdit.java new file mode 100644 index 0000000..a707e2b --- /dev/null +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommandTBMEdit.java @@ -0,0 +1,416 @@ +package com.seodisparate.TurnBasedMinecraft.common; + +import com.seodisparate.TurnBasedMinecraft.common.networking.PacketEditingMessage; +import com.seodisparate.TurnBasedMinecraft.common.networking.PacketGeneralMessage; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; + +public class CommandTBMEdit extends CommandBase +{ + public static final String usage = "/tbm-edit (Invoke without parameters to start edit)"; + private Config config; + + public CommandTBMEdit(Config config) + { + this.config = config; + } + + @Override + public String getName() + { + return "tbm-edit"; + } + + @Override + public String getUsage(ICommandSender sender) + { + return usage; + } + + @Override + public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException + { + EntityPlayer senderEntity = null; + EditingInfo editingInfo = null; + try + { + senderEntity = (EntityPlayer) sender.getCommandSenderEntity(); + } catch (ClassCastException e) + { + // if sender is not EntityPlayer, ignore + return; + } + editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(senderEntity.getEntityId()); + if(args.length == 0) + { + if(editingInfo != null && !editingInfo.isPendingEntitySelection) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + else if(editingInfo != null) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), (EntityPlayerMP) senderEntity); + } + else + { + TurnBasedMinecraftMod.proxy.setEditingPlayer(senderEntity); + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), (EntityPlayerMP) senderEntity); + TurnBasedMinecraftMod.logger.info("Begin editing TBM Entity for player \"" + senderEntity.getName() + "\""); + } + } + else if(args.length == 1) + { + if(editingInfo != null && !editingInfo.isPendingEntitySelection) + { + if(args[0].toLowerCase().equals("finish")) + { + config.editEntityEntry(editingInfo.entityInfo); + TurnBasedMinecraftMod.proxy.removeEditingInfo(senderEntity.getEntityId()); + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Entity info saved in config and loaded."), (EntityPlayerMP) senderEntity); + } + else if(args[0].toLowerCase().equals("cancel")) + { + TurnBasedMinecraftMod.proxy.removeEditingInfo(senderEntity.getEntityId()); + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Cancelled editing entity."), (EntityPlayerMP)senderEntity); + } + else if(args[0].toLowerCase().equals("edit")) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit \"."), (EntityPlayerMP)senderEntity); + } + } + else if(editingInfo != null) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), (EntityPlayerMP) senderEntity); + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Cannot edit entity without starting editing process (use \"/tbm-edit\")."), (EntityPlayerMP)senderEntity); + } + } + else if(args.length == 2) + { + if(editingInfo != null && !editingInfo.isPendingEntitySelection) + { + if(args[0].toLowerCase().equals("edit")) + { + switch(args[1]) + { + case "ignoreBattle": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_IGNORE_BATTLE), (EntityPlayerMP) senderEntity); + break; + case "attackPower": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_POWER), (EntityPlayerMP) senderEntity); + break; + case "attackProbability": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_PROBABILITY), (EntityPlayerMP) senderEntity); + break; + case "attackVariance": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_VARIANCE), (EntityPlayerMP) senderEntity); + break; + case "attackEffect": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT), (EntityPlayerMP) senderEntity); + break; + case "attackEffectProbability": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_ATTACK_EFFECT_PROBABILITY), (EntityPlayerMP) senderEntity); + break; + case "defenseDamage": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE), (EntityPlayerMP) senderEntity); + break; + case "defenseDamageProbability": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DEFENSE_DAMAGE_PROBABILITY), (EntityPlayerMP) senderEntity); + break; + case "evasion": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_EVASION), (EntityPlayerMP) senderEntity); + break; + case "speed": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SPEED), (EntityPlayerMP) senderEntity); + break; + case "category": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_CATEGORY), (EntityPlayerMP) senderEntity); + break; + case "decisionAttack": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_ATTACK), (EntityPlayerMP) senderEntity); + break; + case "decisionDefend": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_DEFEND), (EntityPlayerMP) senderEntity); + break; + case "decisionFlee": + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.EDIT_DECISION_FLEE), (EntityPlayerMP) senderEntity); + break; + default: + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit \""), (EntityPlayerMP) senderEntity); + break; + } + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid arguments for \"/tbm-edit \"."), (EntityPlayerMP)senderEntity); + } + } + else if(editingInfo != null) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), (EntityPlayerMP)senderEntity); + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Cannot edit entity without starting editing process (use \"/tbm-edit\")."), (EntityPlayerMP)senderEntity); + } + } + else if(args.length == 3) + { + if(editingInfo != null && !editingInfo.isPendingEntitySelection) + { + if(args[0].toLowerCase().equals("edit")) + { + switch(args[1]) + { + case "ignoreBattle": + if(args[2].toLowerCase().equals("true")) + { + editingInfo.entityInfo.ignoreBattle = true; + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + else if(args[2].toLowerCase().equals("false")) + { + editingInfo.entityInfo.ignoreBattle = false; + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit ignoreBattle \""), (EntityPlayerMP)senderEntity); + } + break; + case "attackPower": + try + { + editingInfo.entityInfo.attackPower = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.attackPower < 0) + { + editingInfo.entityInfo.attackPower = 0; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit attackPower \""), (EntityPlayerMP)senderEntity); + } + break; + case "attackProbability": + try + { + editingInfo.entityInfo.attackProbability = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.attackProbability < 0) + { + editingInfo.entityInfo.attackProbability = 0; + } + else if(editingInfo.entityInfo.attackProbability > 100) + { + editingInfo.entityInfo.attackProbability = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit attackProbability \""), (EntityPlayerMP)senderEntity); + } + break; + case "attackVariance": + try + { + editingInfo.entityInfo.attackVariance = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.attackVariance < 0) + { + editingInfo.entityInfo.attackVariance = 0; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit attackVariance \""), (EntityPlayerMP)senderEntity); + } + break; + case "attackEffect": + editingInfo.entityInfo.attackEffect = EntityInfo.Effect.fromString(args[2]); + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + break; + case "attackEffectProbability": + try + { + editingInfo.entityInfo.attackEffectProbability = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.attackEffectProbability < 0) + { + editingInfo.entityInfo.attackEffectProbability = 0; + } + else if(editingInfo.entityInfo.attackEffectProbability > 100) + { + editingInfo.entityInfo.attackEffectProbability = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit attackEffectProbability \""), (EntityPlayerMP)senderEntity); + } + break; + case "defenseDamage": + try + { + editingInfo.entityInfo.defenseDamage = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.defenseDamage < 0) + { + editingInfo.entityInfo.defenseDamage = 0; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit defenseDamage \""), (EntityPlayerMP)senderEntity); + } + break; + case "defenseDamageProbability": + try + { + editingInfo.entityInfo.defenseDamageProbability = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.defenseDamageProbability < 0) + { + editingInfo.entityInfo.defenseDamageProbability = 0; + } + else if(editingInfo.entityInfo.defenseDamageProbability > 100) + { + editingInfo.entityInfo.defenseDamageProbability = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit defenseDamageProbability \""), (EntityPlayerMP)senderEntity); + } + break; + case "evasion": + try + { + editingInfo.entityInfo.evasion = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.evasion < 0) + { + editingInfo.entityInfo.evasion = 0; + } + else if(editingInfo.entityInfo.evasion > 100) + { + editingInfo.entityInfo.evasion = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit evasion \""), (EntityPlayerMP)senderEntity); + } + break; + case "speed": + try + { + editingInfo.entityInfo.speed = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.speed < 0) + { + editingInfo.entityInfo.speed = 0; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit speed \""), (EntityPlayerMP)senderEntity); + } + break; + case "category": + editingInfo.entityInfo.category = args[2]; + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + break; + case "decisionAttack": + try + { + editingInfo.entityInfo.decisionAttack = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.decisionAttack < 0) + { + editingInfo.entityInfo.decisionAttack = 0; + } + else if(editingInfo.entityInfo.decisionAttack > 100) + { + editingInfo.entityInfo.decisionAttack = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit decisionAttack \""), (EntityPlayerMP)senderEntity); + } + break; + case "decisionDefend": + try + { + editingInfo.entityInfo.decisionDefend = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.decisionDefend < 0) + { + editingInfo.entityInfo.decisionDefend = 0; + } + else if(editingInfo.entityInfo.decisionDefend > 100) + { + editingInfo.entityInfo.decisionDefend = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit decisionDefend \""), (EntityPlayerMP)senderEntity); + } + break; + case "decisionFlee": + try + { + editingInfo.entityInfo.decisionFlee = Integer.parseInt(args[2]); + if(editingInfo.entityInfo.decisionFlee < 0) + { + editingInfo.entityInfo.decisionFlee = 0; + } + else if(editingInfo.entityInfo.decisionFlee > 100) + { + editingInfo.entityInfo.decisionFlee = 100; + } + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo), (EntityPlayerMP)senderEntity); + } + catch (NumberFormatException e) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid argument for \"/tbm-edit edit decisionFlee \""), (EntityPlayerMP)senderEntity); + } + break; + default: + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid second argument for \"/tbm-edit edit \""), (EntityPlayerMP)senderEntity); + break; + } + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid arguments for \"/tbm-edit \"."), (EntityPlayerMP)senderEntity); + } + } + else if(editingInfo != null) + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY), (EntityPlayerMP)senderEntity); + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Cannot edit entity without starting editing process (use \"/tbm-edit\")."), (EntityPlayerMP)senderEntity); + } + } + else + { + TurnBasedMinecraftMod.NWINSTANCE.sendTo(new PacketGeneralMessage("Invalid arguments for \"/tbm-edit\"."), (EntityPlayerMP)senderEntity); + } + } +} diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommonProxy.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommonProxy.java index a954e57..e0d6a67 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommonProxy.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/CommonProxy.java @@ -1,8 +1,9 @@ package com.seodisparate.TurnBasedMinecraft.common; -import java.util.HashSet; -import java.util.Set; +import java.util.*; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.text.ITextComponent; import org.apache.logging.log4j.Logger; import net.minecraft.entity.Entity; @@ -16,10 +17,12 @@ public class CommonProxy private int attackingDamage = 0; private Config config = null; private Logger logger = null; + private Map editingPlayers; public final void initialize() { attackerViaBow = new HashSet(); + editingPlayers = new Hashtable(); initializeClient(); } @@ -84,6 +87,8 @@ public class CommonProxy public void typeLeftBattle(String type) {} public void displayString(String message) {} + + public void displayTextComponent(ITextComponent textComponent) {} public Entity getEntityByID(int id) { @@ -141,4 +146,19 @@ public class CommonProxy { return config; } + + protected final EditingInfo getEditingInfo(int id) + { + return editingPlayers.get(id); + } + + protected final EditingInfo setEditingPlayer(EntityPlayer player) + { + return editingPlayers.put(player.getEntityId(), new EditingInfo(player)); + } + + protected final EditingInfo removeEditingInfo(int id) + { + return editingPlayers.remove(id); + } } diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/EditingInfo.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/EditingInfo.java new file mode 100644 index 0000000..02737f2 --- /dev/null +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/EditingInfo.java @@ -0,0 +1,24 @@ +package com.seodisparate.TurnBasedMinecraft.common; + +import net.minecraft.entity.player.EntityPlayer; + +public class EditingInfo +{ + public EntityPlayer editor; + public EntityInfo entityInfo; + public boolean isPendingEntitySelection; + + public EditingInfo() + { + editor = null; + entityInfo = null; + isPendingEntitySelection = true; + } + + public EditingInfo(EntityPlayer player) + { + editor = player; + entityInfo = null; + isPendingEntitySelection = true; + } +} diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java index e9fb8b1..7c28a9a 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/TurnBasedMinecraftMod.java @@ -1,13 +1,8 @@ package com.seodisparate.TurnBasedMinecraft.common; +import com.seodisparate.TurnBasedMinecraft.common.networking.*; import org.apache.logging.log4j.Logger; -import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleDecision; -import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleInfo; -import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleMessage; -import com.seodisparate.TurnBasedMinecraft.common.networking.PacketBattleRequestInfo; -import com.seodisparate.TurnBasedMinecraft.common.networking.PacketGeneralMessage; - import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; @@ -80,6 +75,12 @@ public class TurnBasedMinecraftMod PacketGeneralMessage.class, packetHandlerID++, Side.CLIENT); + NWINSTANCE.registerMessage( + PacketEditingMessage.HandlerEditingMessage.class, + PacketEditingMessage.class, + packetHandlerID++, + Side.CLIENT + ); // register event handler(s) MinecraftForge.EVENT_BUS.register(new AttackEventHandler()); @@ -109,6 +110,7 @@ public class TurnBasedMinecraftMod event.registerServerCommand(new CommandTBMSet(proxy.getConfig())); event.registerServerCommand(new CommandTBMDisableAll(proxy.getConfig())); event.registerServerCommand(new CommandTBMEnableAll(proxy.getConfig())); + event.registerServerCommand(new CommandTBMEdit(proxy.getConfig())); } @EventHandler diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleMessage.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleMessage.java index 347c0ad..f346380 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleMessage.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleMessage.java @@ -41,7 +41,7 @@ public class PacketBattleMessage implements IMessage private int value; private static Map map = new HashMap(); - private MessageType(int value) + MessageType(int value) { this.value = value; } @@ -75,7 +75,7 @@ public class PacketBattleMessage implements IMessage private int value; private static Map map = new HashMap(); - private UsedItemAction(int value) + UsedItemAction(int value) { this.value = value; } diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java index 2595210..552a3d7 100644 --- a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleRequestInfo.java @@ -41,8 +41,7 @@ public class PacketBattleRequestInfo implements IMessage { return null; } - PacketBattleInfo battleInfo = new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerSeconds()); - return battleInfo; + return new PacketBattleInfo(b.getSideAIDs(), b.getSideBIDs(), b.getTimerSeconds()); } } } diff --git a/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketEditingMessage.java b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketEditingMessage.java new file mode 100644 index 0000000..b2ed44a --- /dev/null +++ b/src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketEditingMessage.java @@ -0,0 +1,721 @@ +package com.seodisparate.TurnBasedMinecraft.common.networking; + +import com.seodisparate.TurnBasedMinecraft.common.EntityInfo; +import com.seodisparate.TurnBasedMinecraft.common.TurnBasedMinecraftMod; +import io.netty.buffer.ByteBuf; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.event.ClickEvent; +import net.minecraft.util.text.event.HoverEvent; +import net.minecraftforge.fml.common.network.ByteBufUtils; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; + +import java.util.HashMap; +import java.util.Map; + +public class PacketEditingMessage implements IMessage +{ + public enum Type + { + ATTACK_ENTITY(0), + PICK_EDIT(1), + EDIT_IGNORE_BATTLE(2), + EDIT_ATTACK_POWER(3), + EDIT_ATTACK_PROBABILITY(4), + EDIT_ATTACK_VARIANCE(5), + EDIT_ATTACK_EFFECT(6), + EDIT_ATTACK_EFFECT_PROBABILITY(7), + EDIT_DEFENSE_DAMAGE(8), + EDIT_DEFENSE_DAMAGE_PROBABILITY(9), + EDIT_EVASION(10), + EDIT_SPEED(11), + EDIT_CATEGORY(12), + EDIT_DECISION_ATTACK(13), + EDIT_DECISION_DEFEND(14), + EDIT_DECISION_FLEE(15); + + Type(int value) + { + this.value = value; + } + + private static Map map; + private int value; + + static + { + map = new HashMap(); + for(Type t : values()) + { + map.put(t.value, t); + } + } + + public int getValue() + { + return value; + } + + public static Type valueOf(int value) + { + return map.get(value); + } + } + + Type type = Type.ATTACK_ENTITY; + EntityInfo entityInfo = new EntityInfo(); + + public PacketEditingMessage() {} + + public PacketEditingMessage(Type type) + { + this.type = type; + } + + public PacketEditingMessage(Type type, EntityInfo entityInfo) + { + this.type = type; + this.entityInfo = entityInfo; + } + + @Override + public void fromBytes(ByteBuf buf) + { + type = Type.valueOf(buf.readInt()); + try + { + entityInfo.classType = getClass().getClassLoader().loadClass(ByteBufUtils.readUTF8String(buf)); + } + catch (ClassNotFoundException e) { /* ignored */ } + entityInfo.ignoreBattle = buf.readBoolean(); + entityInfo.attackPower = buf.readInt(); + entityInfo.attackProbability = buf.readInt(); + entityInfo.attackVariance = buf.readInt(); + entityInfo.attackEffect = EntityInfo.Effect.fromString(ByteBufUtils.readUTF8String(buf)); + entityInfo.attackEffectProbability = buf.readInt(); + entityInfo.defenseDamage = buf.readInt(); + entityInfo.defenseDamageProbability = buf.readInt(); + entityInfo.evasion = buf.readInt(); + entityInfo.speed = buf.readInt(); + entityInfo.category = ByteBufUtils.readUTF8String(buf); + entityInfo.decisionAttack = buf.readInt(); + entityInfo.decisionDefend = buf.readInt(); + entityInfo.decisionFlee = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(type.getValue()); + if(entityInfo.classType != null) + { + ByteBufUtils.writeUTF8String(buf, entityInfo.classType.getName()); + } + else + { + ByteBufUtils.writeUTF8String(buf, "unknown"); + } + buf.writeBoolean(entityInfo.ignoreBattle); + buf.writeInt(entityInfo.attackPower); + buf.writeInt(entityInfo.attackProbability); + buf.writeInt(entityInfo.attackVariance); + ByteBufUtils.writeUTF8String(buf, entityInfo.attackEffect.toString()); + buf.writeInt(entityInfo.attackEffectProbability); + buf.writeInt(entityInfo.defenseDamage); + buf.writeInt(entityInfo.defenseDamageProbability); + buf.writeInt(entityInfo.evasion); + buf.writeInt(entityInfo.speed); + ByteBufUtils.writeUTF8String(buf, entityInfo.category); + buf.writeInt(entityInfo.decisionAttack); + buf.writeInt(entityInfo.decisionDefend); + buf.writeInt(entityInfo.decisionFlee); + } + + public static class HandlerEditingMessage implements IMessageHandler + { + @Override + public IMessage onMessage(PacketEditingMessage message, MessageContext ctx) + { + switch(message.type) + { + case ATTACK_ENTITY: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("Attack the entity you want to edit for TurnBasedMinecraftMod. "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + ITextComponent cancel = new TextComponentString("Cancel"); + cancel.getStyle().setColor(TextFormatting.RED).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")); + text.appendSibling(cancel); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case PICK_EDIT: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("Edit what value? "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + ITextComponent option = new TextComponentString("IgB"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("IgnoreBattle"))); + ITextComponent value = new TextComponentString("(" + message.entityInfo.ignoreBattle + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("AP"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("AttackPower"))); + value = new TextComponentString("(" + message.entityInfo.attackPower + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("APr"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("AttackProbability"))); + value = new TextComponentString("(" + message.entityInfo.attackProbability + "%) "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("AV"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("AttackVariance"))); + value = new TextComponentString("(" + message.entityInfo.attackVariance + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("AE"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("AttackEffect"))); + value = new TextComponentString("(" + message.entityInfo.attackEffect.toString() + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("AEPr"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("AttackEffectProbability"))); + value = new TextComponentString("(" + message.entityInfo.attackEffectProbability + "%) "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("DD"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("DefenseDamage"))); + value = new TextComponentString("(" + message.entityInfo.defenseDamage + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("DDPr"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("DefenseDamageProbability"))); + value = new TextComponentString("(" + message.entityInfo.defenseDamageProbability + "%) "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("E"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Evasion"))); + value = new TextComponentString("(" + message.entityInfo.evasion + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("S"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Speed"))); + value = new TextComponentString("(" + message.entityInfo.speed + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("C"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Category"))); + value = new TextComponentString("(" + message.entityInfo.category + ") "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("DecA"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("DecisionAttack"))); + value = new TextComponentString("(" + message.entityInfo.decisionAttack + "%) "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("DecD"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("DecisionDefend"))); + value = new TextComponentString("(" + message.entityInfo.decisionDefend + "%) "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("DecF"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee")) + .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("DecisionFlee"))); + value = new TextComponentString("(" + message.entityInfo.decisionFlee + "%) "); + value.getStyle().setColor(TextFormatting.WHITE); + option.appendSibling(value); + text.appendSibling(option); + + option = new TextComponentString("Finished Editing"); + option.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")); + text.appendSibling(option).appendText(" "); + + option = new TextComponentString("Cancel"); + option.getStyle().setColor(TextFormatting.RED).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit cancel")); + text.appendSibling(option); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_IGNORE_BATTLE: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("ignoreBattle: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + ITextComponent option = new TextComponentString("true"); + option.getStyle().setColor(TextFormatting.GREEN).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle true")); + text.appendSibling(option); + + text.appendText(" "); + + option = new TextComponentString("false"); + option.getStyle().setColor(TextFormatting.RED).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle false")); + text.appendSibling(option); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_ATTACK_POWER: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("attackPower: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 15; ++i) + { + ITextComponent option = new TextComponentString(Integer.toString(i)); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackPower " + Integer.toString(i))); + text.appendSibling(option); + if(i < 15) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit attackPower \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_ATTACK_PROBABILITY: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("attackProbability: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 10; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit attackProbability \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_ATTACK_VARIANCE: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("attackVariance: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 10; ++i) + { + ITextComponent option = new TextComponentString(Integer.toString(i)); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance " + Integer.toString(i))); + text.appendSibling(option); + if(i < 10) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit attackVariance \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_ATTACK_EFFECT: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("attackEffect: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(EntityInfo.Effect e : EntityInfo.Effect.values()) + { + ITextComponent option = new TextComponentString(e.toString()); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffect " + e.toString())); + text.appendSibling(option); + if(e != EntityInfo.Effect.UNKNOWN) + { + // TODO find a better way to handle printing comma for items before last + text.appendText(", "); + } + } + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_ATTACK_EFFECT_PROBABILITY: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("attackEffectProbability: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackEffectProbability " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit attackEffectProbability \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_DEFENSE_DAMAGE: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("defenseDamage: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 15; ++i) + { + ITextComponent option = new TextComponentString(Integer.toString(i)); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamage " + Integer.toString(i))); + text.appendSibling(option); + if(i < 15) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit defenseDamage \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_DEFENSE_DAMAGE_PROBABILITY: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("defenseDamageProbability: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit defenseDamageProbability " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit defenseDamageProbability \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_EVASION: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("evasion: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit evasion \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_SPEED: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("speed: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i)); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit speed " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + text.appendText(" (or use command \"/tbm-edit edit speed \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_CATEGORY: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("category: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + ITextComponent option = new TextComponentString("monster"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category monster")); + if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("monster")) + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("disabled"); + optionInfoBool.getStyle().setColor(TextFormatting.RED); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + else + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("enabled"); + optionInfoBool.getStyle().setColor(TextFormatting.GREEN); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + text.appendSibling(option).appendText(", "); + + option = new TextComponentString("animal"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category animal")); + if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("animal")) + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("disabled"); + optionInfoBool.getStyle().setColor(TextFormatting.RED); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + else + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("enabled"); + optionInfoBool.getStyle().setColor(TextFormatting.GREEN); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + text.appendSibling(option).appendText(", "); + + option = new TextComponentString("passive"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category passive")); + if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("passive")) + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("disabled"); + optionInfoBool.getStyle().setColor(TextFormatting.RED); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + else + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("enabled"); + optionInfoBool.getStyle().setColor(TextFormatting.GREEN); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + text.appendSibling(option).appendText(", "); + + option = new TextComponentString("boss"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category boss")); + if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("boss")) + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("disabled"); + optionInfoBool.getStyle().setColor(TextFormatting.RED); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + else + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("enabled"); + optionInfoBool.getStyle().setColor(TextFormatting.GREEN); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + text.appendSibling(option).appendText(", "); + + option = new TextComponentString("player"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category player")); + if(TurnBasedMinecraftMod.proxy.getConfig().isIgnoreBattleType("player")) + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("disabled"); + optionInfoBool.getStyle().setColor(TextFormatting.RED); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + else + { + ITextComponent optionInfo = new TextComponentString("(battle-"); + optionInfo.getStyle().setColor(TextFormatting.WHITE); + ITextComponent optionInfoBool = new TextComponentString("enabled"); + optionInfoBool.getStyle().setColor(TextFormatting.GREEN); + optionInfo.appendSibling(optionInfoBool).appendText(")"); + option.appendSibling(optionInfo); + } + text.appendSibling(option); + + text.appendText(" (or use command \"/tbm-edit edit category \")"); + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_DECISION_ATTACK: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("decisionAttack: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionAttack " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_DECISION_DEFEND: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("decisionDefend: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionDefend " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + case EDIT_DECISION_FLEE: + { + ITextComponent prefix = new TextComponentString("TBM: "); + prefix.getStyle().setColor(TextFormatting.GREEN).setBold(true); + ITextComponent text = new TextComponentString("decisionFlee: "); + text.getStyle().setColor(TextFormatting.WHITE).setBold(false); + + for(int i = 0; i <= 100; i += 10) + { + ITextComponent option = new TextComponentString(Integer.toString(i) + "%"); + option.getStyle().setColor(TextFormatting.YELLOW).setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit decisionFlee " + Integer.toString(i))); + text.appendSibling(option); + if(i < 100) + { + text.appendText(", "); + } + } + + prefix.appendSibling(text); + TurnBasedMinecraftMod.proxy.displayTextComponent(prefix); + break; + } + default: + break; + } + return null; + } + } +}