Fix bytecode breakage with StructureModifier

Fixes #935
This commit is contained in:
Dan Mulloy 2020-08-24 11:40:47 -04:00
parent b871eb3d54
commit 13f5c14599
No known key found for this signature in database
GPG Key ID: 2B62F7DACFF133E8
2 changed files with 15 additions and 3 deletions

View File

@ -926,7 +926,7 @@ public class PacketContainer implements Serializable {
*/ */
public StructureModifier<Integer> getDimensions() { public StructureModifier<Integer> getDimensions() {
if (NEW_DIMENSIONS) { if (NEW_DIMENSIONS) {
return structureModifier.withType( return structureModifier.withParamType(
MinecraftReflection.getMinecraftClass("ResourceKey"), MinecraftReflection.getMinecraftClass("ResourceKey"),
BukkitConverters.getDimensionIDConverter(), BukkitConverters.getDimensionIDConverter(),
MinecraftReflection.getMinecraftClass("DimensionManager") MinecraftReflection.getMinecraftClass("DimensionManager")
@ -977,7 +977,7 @@ public class PacketContainer implements Serializable {
* @return The Structure Modifier * @return The Structure Modifier
*/ */
public StructureModifier<World> getWorldKeys() { public StructureModifier<World> getWorldKeys() {
return structureModifier.withType( return structureModifier.withParamType(
MinecraftReflection.getMinecraftClass("ResourceKey"), MinecraftReflection.getMinecraftClass("ResourceKey"),
BukkitConverters.getWorldKeyConverter(), BukkitConverters.getWorldKeyConverter(),
MinecraftReflection.getNmsWorldClass() MinecraftReflection.getNmsWorldClass()

View File

@ -477,8 +477,20 @@ public class StructureModifier<TField> {
* @param converter - converts objects into the given type. * @param converter - converts objects into the given type.
* @return A structure modifier for fields of this type. * @return A structure modifier for fields of this type.
*/ */
public <T> StructureModifier<T> withType(Class fieldType, EquivalentConverter<T> converter) {
return withParamType(fieldType, converter);
}
/**
* Retrieves a structure modifier that only reads and writes fields of a given type.
* @param <T> Type
* @param fieldType - the type, or supertype, of every field to modify.
* @param converter - converts objects into the given type.
* @param paramTypes - field type parameters
* @return A structure modifier for fields of this type.
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> StructureModifier<T> withType(Class fieldType, EquivalentConverter<T> converter, Class... paramTypes) { public <T> StructureModifier<T> withParamType(Class fieldType, EquivalentConverter<T> converter, Class... paramTypes) {
if (fieldType == null) { if (fieldType == null) {
// It's not supported in this version, so return an empty modifier // It's not supported in this version, so return an empty modifier
return new StructureModifier<T>() { return new StructureModifier<T>() {