Make mana flasks instant-use in creative mode
This commit is contained in:
@@ -84,8 +84,15 @@ public class ItemManaFlask extends Item {
|
||||
stacks.addAll(player.inventory.armorInventory); // player#getArmorInventoryList() only returns an Iterable
|
||||
|
||||
if(stacks.stream().anyMatch(s -> s.getItem() instanceof IManaStoringItem && !((IManaStoringItem)s.getItem()).isManaFull(s))){
|
||||
|
||||
if(player.capabilities.isCreativeMode){
|
||||
findAndChargeItem(flask, player);
|
||||
}else{
|
||||
player.setActiveHand(hand);
|
||||
}
|
||||
|
||||
return new ActionResult<>(EnumActionResult.SUCCESS, flask);
|
||||
|
||||
}else{
|
||||
return new ActionResult<>(EnumActionResult.FAIL, flask);
|
||||
}
|
||||
@@ -106,8 +113,13 @@ public class ItemManaFlask extends Item {
|
||||
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entity){
|
||||
|
||||
if(entity instanceof EntityPlayer){
|
||||
findAndChargeItem(stack, (EntityPlayer)entity);
|
||||
}
|
||||
|
||||
EntityPlayer player = (EntityPlayer)entity;
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void findAndChargeItem(ItemStack stack, EntityPlayer player){
|
||||
|
||||
List<ItemStack> stacks = InventoryUtils.getPrioritisedHotbarAndOffhand(player);
|
||||
stacks.addAll(player.inventory.armorInventory); // player#getArmorInventoryList() only returns an Iterable
|
||||
@@ -129,7 +141,4 @@ public class ItemManaFlask extends Item {
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user