Archiviert
13
0

Fix a few errors with data watchers

This is why we have unit tests lol
Dieser Commit ist enthalten in:
Dan Mulloy 2016-03-03 21:27:05 -05:00
Ursprung a20ff4645d
Commit 9b838df17d

Datei anzeigen

@ -342,7 +342,7 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable<Wrap
} }
public static class WrappedDataWatcherObject extends AbstractWrapper { public static class WrappedDataWatcherObject extends AbstractWrapper {
private static final Class<?> HANDLE_TYPE = MinecraftReflection.getDataWatcherSerializerClass(); private static final Class<?> HANDLE_TYPE = MinecraftReflection.getDataWatcherObjectClass();
private static Constructor<?> constructor = null; private static Constructor<?> constructor = null;
private StructureModifier<Object> modifier = new StructureModifier<Object>(HANDLE_TYPE); private StructureModifier<Object> modifier = new StructureModifier<Object>(HANDLE_TYPE);
@ -354,16 +354,18 @@ public class WrappedDataWatcher extends AbstractWrapper implements Iterable<Wrap
} }
public WrappedDataWatcherObject(int index, Serializer serializer) { public WrappedDataWatcherObject(int index, Serializer serializer) {
this(newHandle(index, serializer.getHandle())); this(newHandle(index, serializer));
} }
private static Object newHandle(int index, Object serializer) { private static Object newHandle(int index, Serializer serializer) {
if (constructor == null) { if (constructor == null) {
constructor = HANDLE_TYPE.getConstructors()[0]; constructor = HANDLE_TYPE.getConstructors()[0];
} }
Object handle = serializer != null ? serializer.getHandle() : null;
try { try {
return constructor.newInstance(index, serializer); return constructor.newInstance(index, handle);
} catch (ReflectiveOperationException e) { } catch (ReflectiveOperationException e) {
throw new RuntimeException("Failed to create new DataWatcherObject", e); throw new RuntimeException("Failed to create new DataWatcherObject", e);
} }