Archiviert
13
0

Correctly wrap and unwrap ItemStacks in WrappedWatchableObject.

This should make it possible to set and retrieve watchable objects 
of the type ItemStack.
Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-11-10 20:47:32 +01:00
Ursprung b6809f6ce6
Commit 8c8ca3746b

Datei anzeigen

@ -280,6 +280,8 @@ public class WrappedWatchableObject {
return ChunkPosition.class; return ChunkPosition.class;
else if (unwrapped.equals(MinecraftReflection.getChunkCoordinatesClass())) else if (unwrapped.equals(MinecraftReflection.getChunkCoordinatesClass()))
return WrappedChunkCoordinate.class; return WrappedChunkCoordinate.class;
else if (unwrapped.equals(MinecraftReflection.getItemStackClass()))
return ItemStack.class;
else else
return unwrapped; return unwrapped;
} }
@ -291,7 +293,10 @@ public class WrappedWatchableObject {
*/ */
static Object getUnwrapped(Object wrapped) { static Object getUnwrapped(Object wrapped) {
// Convert special cases // Convert special cases
if (wrapped instanceof WrappedChunkCoordinate) if (wrapped instanceof ChunkPosition)
return ChunkPosition.getConverter().getGeneric(
MinecraftReflection.getChunkPositionClass(), (ChunkPosition) wrapped);
else if (wrapped instanceof WrappedChunkCoordinate)
return ((WrappedChunkCoordinate) wrapped).getHandle(); return ((WrappedChunkCoordinate) wrapped).getHandle();
else if (wrapped instanceof ItemStack) else if (wrapped instanceof ItemStack)
return BukkitConverters.getItemStackConverter().getGeneric( return BukkitConverters.getItemStackConverter().getGeneric(