diff --git a/MinecraftClient/Inventory/Container.cs b/MinecraftClient/Inventory/Container.cs
index 9e93be8a..be63b301 100644
--- a/MinecraftClient/Inventory/Container.cs
+++ b/MinecraftClient/Inventory/Container.cs
@@ -26,10 +26,11 @@ namespace MinecraftClient.Inventory
Title = title;
Items = items;
}
- public Container(int id, Protocol.InventoryType type, string title)
+ public Container(int id, ContainerTypeOld type, string title)
{
ID = id;
Title = title;
+ Type = ConvertType.ToNew(type);
}
public Container(int id, int typeID, string title)
{
diff --git a/MinecraftClient/Inventory/ContainerType.cs b/MinecraftClient/Inventory/ContainerType.cs
index c1276a7b..eb4c3ddd 100644
--- a/MinecraftClient/Inventory/ContainerType.cs
+++ b/MinecraftClient/Inventory/ContainerType.cs
@@ -31,8 +31,47 @@ namespace MinecraftClient.Inventory
Smoker,
Cartography,
Stonecutter,
- // not in the list
+ // not in the wiki.vg list
PlayerInventory,
Unknown
}
+ public enum ContainerTypeOld
+ {
+ CONTAINER,
+ CHEST,
+ CRAFTING_TABLE,
+ FURNACE,
+ DISPENSER,
+ ENCHANTING_TABLE,
+ BREWING_STAND,
+ VILLAGER,
+ BEACON,
+ ANVIL,
+ HOPPER,
+ DROPPER,
+ SHULKER_BOX,
+ ENTITYHORSE
+ }
+ public static class ConvertType
+ {
+ public static ContainerType ToNew(ContainerTypeOld type)
+ {
+ switch (type)
+ {
+ case ContainerTypeOld.CONTAINER: return ContainerType.Unknown;
+ case ContainerTypeOld.CHEST: return ContainerType.Generic_9x3;
+ case ContainerTypeOld.CRAFTING_TABLE: return ContainerType.Crafting;
+ case ContainerTypeOld.FURNACE: return ContainerType.Furnace;
+ case ContainerTypeOld.DISPENSER: return ContainerType.Generic_3x3;
+ case ContainerTypeOld.ENCHANTING_TABLE: return ContainerType.Enchantment;
+ case ContainerTypeOld.BREWING_STAND: return ContainerType.BrewingStand;
+ case ContainerTypeOld.VILLAGER: return ContainerType.Merchant;
+ case ContainerTypeOld.HOPPER: return ContainerType.Hopper;
+ case ContainerTypeOld.DROPPER: return ContainerType.Generic_3x3;
+ case ContainerTypeOld.SHULKER_BOX: return ContainerType.ShulkerBox;
+ case ContainerTypeOld.ENTITYHORSE: return ContainerType.Unknown;
+ default: return ContainerType.Unknown;
+ }
+ }
+ }
}
diff --git a/MinecraftClient/MinecraftClient.csproj b/MinecraftClient/MinecraftClient.csproj
index 9773fe0b..30ef5863 100644
--- a/MinecraftClient/MinecraftClient.csproj
+++ b/MinecraftClient/MinecraftClient.csproj
@@ -262,9 +262,6 @@
-
-
-
diff --git a/MinecraftClient/Protocol/Handlers/Protocol18.cs b/MinecraftClient/Protocol/Handlers/Protocol18.cs
index 880f5d1b..38164159 100644
--- a/MinecraftClient/Protocol/Handlers/Protocol18.cs
+++ b/MinecraftClient/Protocol/Handlers/Protocol18.cs
@@ -10,6 +10,7 @@ using System.Security.Cryptography;
using MinecraftClient.Mapping;
using MinecraftClient.Mapping.BlockPalettes;
using MinecraftClient.Protocol.Handlers.Forge;
+using MinecraftClient.Inventory;
namespace MinecraftClient.Protocol.Handlers
{
@@ -494,12 +495,11 @@ namespace MinecraftClient.Protocol.Handlers
{
byte windowID = dataTypes.ReadNextByte(packetData);
string type = dataTypes.ReadNextString(packetData).Replace("minecraft:", "").ToUpper();
- InventoryType inventoryType = (InventoryType)Enum.Parse(typeof(InventoryType), type);
+ ContainerTypeOld inventoryType = (ContainerTypeOld)Enum.Parse(typeof(ContainerTypeOld), type);
string title = dataTypes.ReadNextString(packetData);
byte slots = dataTypes.ReadNextByte(packetData);
-
- // TODO:
- MinecraftClient.Inventory.Container inventory = new MinecraftClient.Inventory.Container(windowID, inventoryType, title);
+
+ Container inventory = new Container(windowID, inventoryType, title);
handler.OnInventoryOpen(inventory);
}
@@ -508,7 +508,7 @@ namespace MinecraftClient.Protocol.Handlers
int WindowID = dataTypes.ReadNextVarInt(packetData);
int WindowType = dataTypes.ReadNextVarInt(packetData);
string title = dataTypes.ReadNextString(packetData);
- MinecraftClient.Inventory.Container inventory = new MinecraftClient.Inventory.Container(WindowID, WindowType, title);
+ Container inventory = new Container(WindowID, WindowType, title);
handler.OnInventoryOpen(inventory);
}
@@ -547,7 +547,7 @@ namespace MinecraftClient.Protocol.Handlers
*/
byte id = dataTypes.ReadNextByte(packetData);
short elements = dataTypes.ReadNextShort(packetData);
- Dictionary itemsList = new Dictionary(); // index is SlotID
+ Dictionary itemsList = new Dictionary(); // index is SlotID
for(int i = 0; i < elements; i++)
{
bool haveItem = dataTypes.ReadNextBool(packetData);
@@ -557,7 +557,7 @@ namespace MinecraftClient.Protocol.Handlers
byte itemCount = dataTypes.ReadNextByte(packetData);
dataTypes.ReadNextNbt(packetData);
- MinecraftClient.Inventory.Item item = new MinecraftClient.Inventory.Item(itemID, itemCount);
+ Item item = new Item(itemID, itemCount);
itemsList.Add(i, item);
}
}
diff --git a/MinecraftClient/Protocol/InventoryType.cs b/MinecraftClient/Protocol/InventoryType.cs
deleted file mode 100644
index 100b27f6..00000000
--- a/MinecraftClient/Protocol/InventoryType.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-namespace MinecraftClient.Protocol
-{
- public enum InventoryType
- {
- CONTAINER,
- CHEST,
- CRAFTING_TABLE,
- FURNACE,
- DISPENSER,
- ENCHANTING_TABLE,
- BREWING_STAND,
- VILLAGER,
- BEACON,
- ANVIL,
- HOPPER,
- DROPPER,
- SHULKER_BOX,
- ENTITYHORSE
- }
-}