3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Add display name component and add toggle for client block placing

The display name component allows blocks to use other locale keys.
placeAir will prevent the client from placing the default block state.
Dieser Commit ist enthalten in:
davchoo 2022-12-23 11:16:50 -05:00
Ursprung f495c8522d
Commit 8f7d67bde0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 501B6F4FD961CF9A
4 geänderte Dateien mit 40 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,7 @@ public interface CustomBlockComponents {
BoxComponent selectionBox();
BoxComponent collisionBox();
String displayName();
String geometry();
@ -48,11 +49,15 @@ public interface CustomBlockComponents {
RotationComponent rotation();
boolean placeAir();
interface Builder {
Builder selectionBox(BoxComponent selectionBox);
Builder collisionBox(BoxComponent collisionBox);
Builder displayName(String displayName);
Builder geometry(String geometry);
Builder materialInstance(@NonNull String name, @NonNull MaterialInstance materialInstance);
@ -67,6 +72,8 @@ public interface CustomBlockComponents {
Builder rotation(RotationComponent rotation);
Builder placeAir(boolean placeAir);
CustomBlockComponents build();
}
}

Datei anzeigen

@ -45,6 +45,7 @@ import java.util.Set;
public class GeyserCustomBlockComponents implements CustomBlockComponents {
BoxComponent selectionBox;
BoxComponent collisionBox;
String displayName;
String geometry;
Map<String, MaterialInstance> materialInstances;
Float destroyTime;
@ -52,10 +53,12 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
Integer lightEmission;
Integer lightDampening;
RotationComponent rotation;
boolean placeAir;
private GeyserCustomBlockComponents(CustomBlockComponentsBuilder builder) {
this.selectionBox = builder.selectionBox;
this.collisionBox = builder.collisionBox;
this.displayName = builder.displayName;
this.geometry = builder.geometry;
if (builder.materialInstances.isEmpty()) {
this.materialInstances = Object2ObjectMaps.emptyMap();
@ -67,6 +70,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
this.lightEmission = builder.lightEmission;
this.lightDampening = builder.lightDampening;
this.rotation = builder.rotation;
this.placeAir = builder.placeAir;
}
@Override
@ -79,6 +83,11 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
return collisionBox;
}
@Override
public String displayName() {
return displayName;
}
@Override
public String geometry() {
return geometry;
@ -114,6 +123,11 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
return rotation;
}
@Override
public boolean placeAir() {
return placeAir;
}
public static class CustomBlockComponentsBuilder implements Builder {
protected BoxComponent selectionBox;
protected BoxComponent collisionBox;
@ -125,6 +139,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
protected Integer lightEmission;
protected Integer lightDampening;
protected RotationComponent rotation;
protected boolean placeAir = false;
private static final Set<String> VALID_MATERIAL_INSTANCE_NAMES = ImmutableSet.of("*", "up", "down", "north", "south", "west", "east");
@ -160,6 +175,12 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
return this;
}
@Override
public Builder displayName(String displayName) {
this.displayName = displayName;
return this;
}
@Override
public Builder geometry(String geometry) {
this.geometry = geometry;
@ -226,6 +247,12 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
return this;
}
@Override
public Builder placeAir(boolean placeAir) {
this.placeAir = placeAir;
return this;
}
@Override
public CustomBlockComponents build() {
return new GeyserCustomBlockComponents(this);

Datei anzeigen

@ -204,6 +204,11 @@ public class CustomBlockRegistryPopulator {
.putFloat("z", components.rotation().z())
.build());
}
if (components.placeAir()) {
builder.putCompound("minecraft:on_player_placing", NbtMap.builder()
.putString("triggerType", "geyser:place_event")
.build());
}
return builder.build();
}

Datei anzeigen

@ -68,6 +68,7 @@ public class CustomSkull {
.destroyTime(1.5f)
.materialInstance("*", new MaterialInstance("geyser." + skinHash + "_player_skin", "alpha_test", true, true))
.lightDampening(0)
.placeAir(true)
.build();
List<CustomBlockPermutation> permutations = new ArrayList<>();