Fix usage of throwable potions in battle
Add (experimental) "right-click" support for items when "Use" is invoked on an item in battle.
This commit is contained in:
parent
6f0c223c9d
commit
9fab572800
1 changed files with 5 additions and 2 deletions
|
@ -1102,7 +1102,7 @@ public class Battle {
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
final int nextItemToUse = next.itemToUse;
|
final int nextItemToUse = next.itemToUse;
|
||||||
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
|
((Player) nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
|
||||||
} else if (targetItem instanceof PotionItem) {
|
} else if (targetItem instanceof PotionItem && !(targetItem instanceof ThrowablePotionItem)) {
|
||||||
debugLog += " potion";
|
debugLog += " potion";
|
||||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_POTION.getValue(), targetItemStack.getDisplayName().getString());
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
|
@ -1113,7 +1113,10 @@ public class Battle {
|
||||||
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
|
sendMessageToAllPlayers(PacketBattleMessage.MessageType.USED_ITEM, next.entity.getId(), 0, PacketBattleMessage.UsedItemAction.USED_INVALID.getValue(), targetItemStack.getDisplayName().getString());
|
||||||
final Entity nextEntity = next.entity;
|
final Entity nextEntity = next.entity;
|
||||||
final int nextItemToUse = next.itemToUse;
|
final int nextItemToUse = next.itemToUse;
|
||||||
((Player)nextEntity).getInventory().setItem(nextItemToUse, targetItem.finishUsingItem(targetItemStack, nextEntity.level(), (LivingEntity) nextEntity));
|
final int prevItem = ((Player)nextEntity).getInventory().selected;
|
||||||
|
((Player)nextEntity).getInventory().selected = nextItemToUse;
|
||||||
|
((Player)nextEntity).getInventory().setItem(nextItemToUse, targetItem.use(nextEntity.level(), (Player)nextEntity, InteractionHand.MAIN_HAND).getObject());
|
||||||
|
((Player)nextEntity).getInventory().selected = prevItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue