mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add Item type extension
This commit is contained in:
parent
31d45b0950
commit
b1121e91e3
3 changed files with 54 additions and 1 deletions
|
|
@ -50,7 +50,7 @@ namespace MinecraftClient.ChatBots
|
|||
Container inventory = GetPlayerInventory();
|
||||
bool found = false;
|
||||
LastSlot = CurrentSlot;
|
||||
if (inventory.Items.ContainsKey(CurrentSlot + 36) && inventory.Items[CurrentSlot + 36].IsFood())
|
||||
if (inventory.Items.ContainsKey(CurrentSlot + 36) && ItemTypeExtensions.IsFood(inventory.Items[CurrentSlot + 36].Type))
|
||||
{
|
||||
// no need to change slot
|
||||
found = true;
|
||||
|
|
|
|||
52
MinecraftClient/Inventory/ItemTypeExtensions.cs
Normal file
52
MinecraftClient/Inventory/ItemTypeExtensions.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Inventory
|
||||
{
|
||||
public static class ItemTypeExtensions
|
||||
{
|
||||
/**
|
||||
* I see "this" in the MaterialExtensions class method, why need that?
|
||||
* public static bool IsSolid(this Material m)
|
||||
* ^^^^
|
||||
*/
|
||||
public static bool IsFood(ItemType m)
|
||||
{
|
||||
ItemType[] t =
|
||||
{
|
||||
ItemType.Apple,
|
||||
ItemType.BakedPotato,
|
||||
ItemType.Beetroot,
|
||||
ItemType.Bread,
|
||||
ItemType.Carrot,
|
||||
ItemType.CookedChicken,
|
||||
ItemType.CookedCod,
|
||||
ItemType.CookedMutton,
|
||||
ItemType.CookedPorkchop,
|
||||
ItemType.CookedRabbit,
|
||||
ItemType.CookedSalmon,
|
||||
ItemType.Cookie,
|
||||
ItemType.DriedKelp,
|
||||
ItemType.EnchantedGoldenApple,
|
||||
ItemType.GoldenApple,
|
||||
ItemType.GoldenCarrot,
|
||||
ItemType.MelonSlice,
|
||||
ItemType.Potato,
|
||||
ItemType.PumpkinPie,
|
||||
ItemType.Beef,
|
||||
ItemType.Chicken,
|
||||
ItemType.Cod,
|
||||
ItemType.Mutton,
|
||||
ItemType.Porkchop,
|
||||
ItemType.Rabbit,
|
||||
ItemType.Salmon,
|
||||
ItemType.CookedBeef,
|
||||
ItemType.SweetBerries,
|
||||
ItemType.TropicalFish
|
||||
};
|
||||
return t.Contains(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -108,6 +108,7 @@
|
|||
<Compile Include="Inventory\ContainerType.cs" />
|
||||
<Compile Include="Inventory\Item.cs" />
|
||||
<Compile Include="Inventory\ItemType.cs" />
|
||||
<Compile Include="Inventory\ItemTypeExtensions.cs" />
|
||||
<Compile Include="Inventory\ItemTypeGenerator.cs" />
|
||||
<Compile Include="Mapping\BlockPalettes\Palette112.cs" />
|
||||
<Compile Include="Mapping\BlockPalettes\Palette113.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue