Skip to content

Commit

Permalink
Fix bamboo collision for 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed May 13, 2024
1 parent 99a5f77 commit de9ade8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.jetbrains.annotations.Contract;

import java.lang.reflect.*;
import java.util.Arrays;

public final class CollisionFix implements Listener {
private final boolean bambooEnabled;
Expand All @@ -33,7 +34,9 @@ public CollisionFix(Plugin plugin, boolean bambooEnabled, boolean pointedDripsto
if (bambooEnabled) {
try {
final Class<?> bambooBlockClass = NMSReflection.getNMSClass("world.level.block", "BlockBamboo");
final Field bambooBoundingBox = ReflectionAPI.getFieldAccessible(bambooBlockClass, NMSReflection.mojmap ? "f" : "c"); // Bounding box for "no leaves", according to Yarn.
// Codec field being first bumps all fields - as of 1.20.5
boolean hasCodec = Arrays.stream(bambooBlockClass.getFields()).anyMatch(field -> field.getType().getSimpleName().equals("MapCodec"));
final Field bambooBoundingBox = ReflectionAPI.getFieldAccessible(bambooBlockClass, hasCodec ? "g" : NMSReflection.mojmap ? "f" : "c"); // Bounding box for "no leaves", according to Yarn.
applyNoBoundingBox(bambooBoundingBox);
plugin.getLogger().info("Bamboo collision hack enabled.");
} catch (Exception e) {
Expand Down

0 comments on commit de9ade8

Please sign in to comment.