ChunkPosition was replaced by BlockPosition

This commit is contained in:
Dan Mulloy 2014-11-29 13:12:35 -05:00
parent d5a63e8e38
commit 1f6b873f84
2 changed files with 45 additions and 8 deletions

View File

@ -40,8 +40,7 @@ public class BukkitCloner implements Cloner {
List<Class<?>> classes = Lists.newArrayList();
classes.add(MinecraftReflection.getItemStackClass());
// TODO: Chunk position does not exist
// classes.add(MinecraftReflection.getChunkPositionClass());
classes.add(MinecraftReflection.getBlockPositionClass());
classes.add(MinecraftReflection.getDataWatcherClass());
if (MinecraftReflection.isUsingNetty()) {

View File

@ -418,12 +418,23 @@ public class MinecraftReflection {
/**
* Determine if a given object is a ChunkPosition.
* @param obj - the object to test.
* @deprecated ChunkPosition no longer exists
* @return TRUE if it can, FALSE otherwise.
*/
@Deprecated
public static boolean isChunkPosition(Object obj) {
return obj != null && getChunkPositionClass().isAssignableFrom(obj.getClass());
}
/**
* Determine if a given object is a BlockPosition.
* @param obj - the object to test.
* @return TRUE if it can, FALSE otherwise.
*/
public static boolean isBlockPosition(Object obj) {
return obj != null && getBlockPositionClass().isAssignableFrom(obj.getClass());
}
/**
* Determine if the given object is an NMS ChunkCoordIntPar.
* @param obj - the object.
@ -1167,26 +1178,53 @@ public class MinecraftReflection {
}
/**
* Retrieve the ChunkPosition class.
* Retrieves the ChunkPosition class.
*
* @deprecated ChunkPosition no longer exists. Replaced by BlockPosition.
* @return The ChunkPosition class.
*/
@Deprecated
public static Class<?> getChunkPositionClass() {
try {
return getMinecraftClass("ChunkPosition");
} catch (RuntimeException e) {
return getBlockPositionClass();
// Class<?> normalChunkGenerator = getCraftBukkitClass("generator.NormalChunkGenerator");
//
// // ChunkPosition a(net.minecraft.server.World world, String string, int i, int i1, int i2) {
// FuzzyMethodContract selected = FuzzyMethodContract.newBuilder()
// .banModifier(Modifier.STATIC)
// .parameterMatches(getMinecraftObjectMatcher(), 0)
// .parameterExactType(String.class, 1)
// .parameterExactType(int.class, 2)
// .parameterExactType(int.class, 3)
// .parameterExactType(int.class, 4)
// .build();
//
// return setMinecraftClass("ChunkPosition",
// FuzzyReflection.fromClass(normalChunkGenerator).getMethod(selected).getReturnType());
}
}
/**
* Retrieves the BlockPosition class.
* @return The BlockPosition class.
*/
public static Class<?> getBlockPositionClass() {
try {
return getMinecraftClass("BlockPosition");
} catch (RuntimeException e) {
Class<?> normalChunkGenerator = getCraftBukkitClass("generator.NormalChunkGenerator");
// ChunkPosition a(net.minecraft.server.World world, String string, int i, int i1, int i2) {
// BlockPosition findNearestMapFeature(World, String, BlockPosition)
FuzzyMethodContract selected = FuzzyMethodContract.newBuilder()
.banModifier(Modifier.STATIC)
.parameterMatches(getMinecraftObjectMatcher(), 0)
.parameterExactType(String.class, 1)
.parameterExactType(int.class, 2)
.parameterExactType(int.class, 3)
.parameterExactType(int.class, 4)
.parameterMatches(getMinecraftObjectMatcher(), 1)
.build();
return setMinecraftClass("ChunkPosition",
return setMinecraftClass("BlockPosition",
FuzzyReflection.fromClass(normalChunkGenerator).getMethod(selected).getReturnType());
}
}