Support Minecraft 1.20.4

This commit is contained in:
FlorianMichael 2024-01-02 18:04:38 +01:00
parent 6c7c81c89d
commit 5975f2728c
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
4 changed files with 11 additions and 11 deletions

View File

@ -25,7 +25,7 @@ version = project.maven_version
group = project.maven_group
dependencies {
compileOnly "com.viaversion:viaversion-api:4.6.2"
compileOnly "com.viaversion:viaversion-api:4.9.3-SNAPSHOT"
compileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
}

View File

@ -80,7 +80,7 @@ public class BukkitPlugin extends JavaPlugin {
}
// Added in 15w44b (1.9)
if (serverProtocol >= ProtocolVersion.v1_9.getVersion() && config.getBoolean("lily-pad-fix")) {
BoundingBoxFixer.fixLilyPad(getLogger());
BoundingBoxFixer.fixLilyPad(getLogger(), serverProtocol);
}
if (serverProtocol >= ProtocolVersion.v1_14_4.getVersion() && config.getBoolean("carpet-fix")) {
BoundingBoxFixer.fixCarpet(getLogger(), serverProtocol);

View File

@ -19,7 +19,6 @@
package com.viaversion.viarewind.legacysupport.injector;
import com.viaversion.viarewind.legacysupport.reflection.ReflectionAPI;
import com.viaversion.viarewind.legacysupport.BukkitPlugin;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.lang.reflect.Field;
@ -31,9 +30,9 @@ import java.util.logging.Logger;
public class BoundingBoxFixer {
public static void fixLilyPad(final Logger logger) {
public static void fixLilyPad(final Logger logger, final int serverVersion) {
try {
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(NMSReflection.getNMSBlock("BlockWaterLily"), "a");
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(NMSReflection.getNMSBlock("BlockWaterLily"), serverVersion <= ProtocolVersion.v1_20_2.getVersion() ? "a" : "b");
setBoundingBox(boundingBoxField.get(null), 0.0625, 0.0, 0.0625, 0.9375, 0.015625, 0.9375);
} catch (Exception ex) {
@ -45,7 +44,7 @@ public class BoundingBoxFixer {
try {
final Class<?> blockCarpetClass = serverVersion <= ProtocolVersion.v1_16_4.getVersion() ? NMSReflection.getNMSBlock("BlockCarpet") : NMSReflection.getNMSBlock("CarpetBlock");
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(blockCarpetClass, "a");
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(blockCarpetClass, serverVersion <= ProtocolVersion.v1_20_2.getVersion() ? "a" : "b");
setBoundingBox(boundingBoxField.get(0), 0.0D, -0.0000001D, 0.0D, 1.0D, 0.0000001D, 1.0D);
} catch (Exception ex) {
logger.log(Level.SEVERE, "Could not fix carpet bounding box.", ex);
@ -57,13 +56,14 @@ public class BoundingBoxFixer {
final boolean pre1_12_2 = serverVersion <= ProtocolVersion.v1_12_2.getVersion();
final boolean pre1_13_2 = serverVersion <= ProtocolVersion.v1_13_2.getVersion();
final boolean pre1_16_4 = serverVersion <= ProtocolVersion.v1_16_4.getVersion();
final boolean pre1_20_2 = serverVersion <= ProtocolVersion.v1_20_2.getVersion();
final Class<?> blockLadderClass = NMSReflection.getNMSBlock("BlockLadder");
final Field boundingBoxEastField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "b" : pre1_13_2 ? "c" : pre1_16_4 ? "c" : "d");
final Field boundingBoxWestField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "c" : pre1_13_2 ? "o" : pre1_16_4 ? "d" : "e");
final Field boundingBoxSouthField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "d" : pre1_13_2 ? "p" : pre1_16_4 ? "e" : "f");
final Field boundingBoxNorthField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "e" : pre1_13_2 ? "q" : pre1_16_4 ? "f" : "g");
final Field boundingBoxEastField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "b" : pre1_13_2 ? "c" : pre1_16_4 ? "c" : pre1_20_2 ? "d" : "e");
final Field boundingBoxWestField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "c" : pre1_13_2 ? "o" : pre1_16_4 ? "d" : pre1_20_2 ? "e" : "f");
final Field boundingBoxSouthField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "d" : pre1_13_2 ? "p" : pre1_16_4 ? "e" : pre1_20_2 ? "f" : "g");
final Field boundingBoxNorthField = ReflectionAPI.getFieldAccessible(blockLadderClass, pre1_12_2 ? "e" : pre1_13_2 ? "q" : pre1_16_4 ? "f" : pre1_20_2 ? "g" : "h");
setBoundingBox(boundingBoxEastField.get(null), 0.0D, 0.0D, 0.0D, 0.125D, 1.0D, 1.0D);
setBoundingBox(boundingBoxWestField.get(null), 0.875D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);

View File

@ -117,7 +117,7 @@ public class ReflectionAPI {
field.set(object, value);
}
public static void setValue(Class clazz, Object object, String fieldname, Object value) throws NoSuchFieldException, IllegalAccessException {
public static void setValue(Class clazz, Object object, String fieldname, Object value) throws IllegalAccessException {
setValue(clazz, object, fieldname, value, false);
}