From 3c4a1a82c9ca8c990dae89ad55a3e9c395f878ef Mon Sep 17 00:00:00 2001 From: rtm516 Date: Sat, 2 Mar 2024 00:56:35 +0000 Subject: [PATCH] Deprecate unit cube in block components (#4470) * Depricate unit cube * Didn't mean to remove that --- .../custom/component/CustomBlockComponents.java | 7 +++++++ .../level/block/GeyserCustomBlockComponents.java | 12 ++++++++---- .../mappings/versions/MappingsReader_v1.java | 4 +++- .../populator/CustomBlockRegistryPopulator.java | 4 ---- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/api/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java b/api/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java index 63788df8e..06608f787 100644 --- a/api/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java +++ b/api/src/main/java/org/geysermc/geyser/api/block/custom/component/CustomBlockComponents.java @@ -129,8 +129,11 @@ public interface CustomBlockComponents { * Gets the unit cube component * Equivalent to "minecraft:unit_cube" * + * @deprecated Use {@link #geometry()} and compare with `minecraft:geometry.full_block` instead. + * * @return The rotation. */ + @Deprecated boolean unitCube(); /** @@ -181,6 +184,10 @@ public interface CustomBlockComponents { Builder transformation(TransformationComponent transformation); + /** + * @deprecated Use {@link #geometry(GeometryComponent)} with `minecraft:geometry.full_block` instead. + */ + @Deprecated Builder unitCube(boolean unitCube); Builder placeAir(boolean placeAir); diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java index 1fa863d55..dfcb548ee 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java @@ -58,7 +58,6 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { Integer lightEmission; Integer lightDampening; TransformationComponent transformation; - boolean unitCube; boolean placeAir; Set tags; @@ -66,7 +65,13 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { this.selectionBox = builder.selectionBox; this.collisionBox = builder.collisionBox; this.displayName = builder.displayName; - this.geometry = builder.geometry; + GeometryComponent geo = builder.geometry; + if (builder.unitCube && geo == null) { + geo = GeometryComponent.builder() + .identifier("minecraft:geometry.full_block") + .build(); + } + this.geometry = geo; if (builder.materialInstances.isEmpty()) { this.materialInstances = Object2ObjectMaps.emptyMap(); } else { @@ -78,7 +83,6 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { this.lightEmission = builder.lightEmission; this.lightDampening = builder.lightDampening; this.transformation = builder.transformation; - this.unitCube = builder.unitCube; this.placeAir = builder.placeAir; if (builder.tags.isEmpty()) { this.tags = Set.of(); @@ -144,7 +148,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents { @Override public boolean unitCube() { - return unitCube; + return geometry.identifier().equals("minecraft:geometry.full_block"); } @Override diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java index 0bc55c7b1..ce4a8f30e 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java @@ -488,7 +488,9 @@ public class MappingsReader_v1 extends MappingsReader { } if (node.has("unit_cube")) { - builder.unitCube(node.get("unit_cube").asBoolean()); + builder.geometry(GeometryComponent.builder() + .identifier("minecraft:geometry.full_block") + .build()); } if (node.has("material_instances")) { diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java index ea33450bf..36b1fc859 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java @@ -422,10 +422,6 @@ public class CustomBlockRegistryPopulator { .build()); } - if (components.unitCube()) { - builder.putCompound("minecraft:unit_cube", NbtMap.EMPTY); - } - // place_air is not an actual component // We just apply a dummy event to prevent the client from trying to place a block // This mitigates the issue with the client sometimes double placing blocks