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;
case DECIDE_USE_ITEM:
setState(MenuState.USE_ITEM);
break;
case CANCEL:
setState(MenuState.MAIN_MENU);
break;

View file

@ -795,6 +795,11 @@ public class Battle
}
break;
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);
Item targetItem = targetItemStack.getItem();
if(targetItem == null)
@ -819,8 +824,13 @@ public class Battle
}
break;
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;
sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 0);
sendMessageToAllPlayers(PacketBattleMessage.MessageType.SWITCHED_ITEM, next.entity.getEntityId(), 0, 1);
break;
}
next = turnOrderQueue.poll();

View file

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