Skip to content

Commit

Permalink
Generate missing shape-exceeds-cube flag
Browse files Browse the repository at this point in the history
Thanks to retrooper/packetevents#1109 (comment)

Suggested-by: spring-dependency-management <193335777+spring-dependency-management@users.noreply.github.com>
  • Loading branch information
booky10 committed Jan 9, 2025
1 parent 4e68a9f commit 13cf9f6
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();");
}
}
Expand Down

0 comments on commit 13cf9f6

Please sign in to comment.