Deprecate unit cube in block components (#4470)

* Depricate unit cube

* Didn't mean to remove that
This commit is contained in:
rtm516 2024-03-02 00:56:35 +00:00 committed by GitHub
parent f8e6d26fc2
commit 3c4a1a82c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 9 deletions

View file

@ -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);

View file

@ -58,7 +58,6 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
Integer lightEmission;
Integer lightDampening;
TransformationComponent transformation;
boolean unitCube;
boolean placeAir;
Set<String> 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

View file

@ -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")) {

View file

@ -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