Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Shanwer committed Mar 2, 2024
2 parents b73023c + 3c4a1a8 commit fb5d2de
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand Down Expand Up @@ -181,6 +184,10 @@ interface Builder {

Builder transformation(TransformationComponent transformation);

/**
* @deprecated Use {@link #geometry(GeometryComponent)} with `minecraft:geometry.full_block` instead.
*/
@Deprecated
Builder unitCube(boolean unitCube);

Builder placeAir(boolean placeAir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
Integer lightEmission;
Integer lightDampening;
TransformationComponent transformation;
boolean unitCube;
boolean placeAir;
Set<String> tags;

private GeyserCustomBlockComponents(Builder builder) {
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 {
Expand All @@ -78,7 +83,6 @@ private GeyserCustomBlockComponents(Builder builder) {
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();
Expand Down Expand Up @@ -144,7 +148,7 @@ public TransformationComponent transformation() {

@Override
public boolean unitCube() {
return unitCube;
return geometry.identifier().equals("minecraft:geometry.full_block");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,9 @@ private CustomBlockComponentsMapping createCustomBlockComponentsMapping(JsonNode
}

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")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,6 @@ private static NbtMap convertComponents(CustomBlockComponents components, int pr
.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
Expand Down

0 comments on commit fb5d2de

Please sign in to comment.