WIP - minor fixes

This commit is contained in:
Stephen Seo 2018-09-11 16:39:46 +09:00
parent de48b8401c
commit 3d6354e808
3 changed files with 32 additions and 5 deletions

View file

@ -268,6 +268,7 @@ public class BattleGui extends GuiScreen
break; break;
case DECIDE_USE_ITEM: case DECIDE_USE_ITEM:
setState(MenuState.USE_ITEM); setState(MenuState.USE_ITEM);
break;
case CANCEL: case CANCEL:
setState(MenuState.MAIN_MENU); setState(MenuState.MAIN_MENU);
break; break;

View file

@ -795,6 +795,11 @@ public class Battle
} }
break; break;
case USE_ITEM: case USE_ITEM:
if(next.itemToUse < 0 || next.itemToUse > 8)
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getEntityId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue());
break;
}
ItemStack targetItemStack = ((EntityPlayer)next.entity).inventory.getStackInSlot(next.itemToUse); ItemStack targetItemStack = ((EntityPlayer)next.entity).inventory.getStackInSlot(next.itemToUse);
Item targetItem = targetItemStack.getItem(); Item targetItem = targetItemStack.getItem();
if(targetItem == null) if(targetItem == null)
@ -819,8 +824,13 @@ public class Battle
} }
break; break;
case SWITCH_ITEM: case SWITCH_ITEM:
if(next.itemToUse < 0 || next.itemToUse > 8)
{
sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 0);
break;
}
((EntityPlayer)next.entity).inventory.currentItem = next.itemToUse; ((EntityPlayer)next.entity).inventory.currentItem = next.itemToUse;
sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 0); sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 1);
break; break;
} }
next = turnOrderQueue.poll(); next = turnOrderQueue.poll();

View file

@ -297,8 +297,16 @@ public class PacketBattleMessage implements IMessage
from + " tried to use nothing!")); from + " tried to use nothing!"));
break; break;
case USED_INVALID: case USED_INVALID:
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString( if(message.custom.length() > 0)
from + " tried to consume " + message.custom + " and failed!")); {
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
from + " tried to consume " + message.custom + " and failed!"));
}
else
{
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
from + " tried to consume an invalid item and failed!"));
}
break; break;
case USED_FOOD: case USED_FOOD:
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString( Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
@ -327,8 +335,16 @@ public class PacketBattleMessage implements IMessage
} }
break; break;
case SWITCHED_ITEM: case SWITCHED_ITEM:
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString( if(message.amount != 0)
to + " switched to a different item!")); {
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
to + " switched to a different item!"));
}
else
{
Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
to + " switched to a different item but failed because it was invalid!"));
}
break; break;
} }
return null; return null;