From 13cf9f6688b1959dc363d53ccbc895992fb87b5b Mon Sep 17 00:00:00 2001 From: booky10 Date: Thu, 9 Jan 2025 17:52:26 +0100 Subject: [PATCH] Generate missing shape-exceeds-cube flag Thanks to https://github.com/retrooper/packetevents/pull/1109#issuecomment-2578133562 Suggested-by: spring-dependency-management <193335777+spring-dependency-management@users.noreply.github.com> --- .../generators/StateTypesGenerator.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/booky/generation/generators/StateTypesGenerator.java b/src/main/java/dev/booky/generation/generators/StateTypesGenerator.java index 2b7259e..734cf41 100644 --- a/src/main/java/dev/booky/generation/generators/StateTypesGenerator.java +++ b/src/main/java/dev/booky/generation/generators/StateTypesGenerator.java @@ -9,6 +9,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; import org.slf4j.Logger; import java.io.BufferedWriter; @@ -75,13 +76,27 @@ public void generate(Path outDir, String genName) throws IOException { writer.write("\")"); Block block = BuiltInRegistries.BLOCK.get(addedBlock).orElseThrow().value(); + BlockState defState = block.defaultBlockState(); writer.write(".blastResistance(" + block.getExplosionResistance() + "f)"); writer.write(".hardness(" + block.defaultDestroyTime() + "f)"); writer.write(".isBlocking(" + block.properties().hasCollision + ")"); writer.write(".requiresCorrectTool(" + block.properties().requiresCorrectToolForDrops + ")"); - writer.write(".isSolid(" + block.defaultBlockState().isSolid() + ")"); + writer.write(".isSolid(" + defState.isSolid() + ")"); writer.write(".setMaterial(FIXME)"); + if (defState.hasLargeCollisionShape()) { + writer.write(".isShapeExceedsCube("); + if (defState.cache != null) { + // static collision shape, definitely exceeds cube + writer.write("true"); + } else { + // dynamic collision shape, depends on surroundings; + // this needs to be manually fixed + writer.write("FIXME"); + } + writer.write(')'); + } + writer.write(".build();"); } }