Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-19 22:40:18 +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:
Ursprung
f495c8522d
Commit
8f7d67bde0
@ -33,6 +33,7 @@ public interface CustomBlockComponents {
|
|||||||
BoxComponent selectionBox();
|
BoxComponent selectionBox();
|
||||||
|
|
||||||
BoxComponent collisionBox();
|
BoxComponent collisionBox();
|
||||||
|
String displayName();
|
||||||
|
|
||||||
String geometry();
|
String geometry();
|
||||||
|
|
||||||
@ -48,11 +49,15 @@ public interface CustomBlockComponents {
|
|||||||
|
|
||||||
RotationComponent rotation();
|
RotationComponent rotation();
|
||||||
|
|
||||||
|
boolean placeAir();
|
||||||
|
|
||||||
interface Builder {
|
interface Builder {
|
||||||
Builder selectionBox(BoxComponent selectionBox);
|
Builder selectionBox(BoxComponent selectionBox);
|
||||||
|
|
||||||
Builder collisionBox(BoxComponent collisionBox);
|
Builder collisionBox(BoxComponent collisionBox);
|
||||||
|
|
||||||
|
Builder displayName(String displayName);
|
||||||
|
|
||||||
Builder geometry(String geometry);
|
Builder geometry(String geometry);
|
||||||
|
|
||||||
Builder materialInstance(@NonNull String name, @NonNull MaterialInstance materialInstance);
|
Builder materialInstance(@NonNull String name, @NonNull MaterialInstance materialInstance);
|
||||||
@ -67,6 +72,8 @@ public interface CustomBlockComponents {
|
|||||||
|
|
||||||
Builder rotation(RotationComponent rotation);
|
Builder rotation(RotationComponent rotation);
|
||||||
|
|
||||||
|
Builder placeAir(boolean placeAir);
|
||||||
|
|
||||||
CustomBlockComponents build();
|
CustomBlockComponents build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import java.util.Set;
|
|||||||
public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
||||||
BoxComponent selectionBox;
|
BoxComponent selectionBox;
|
||||||
BoxComponent collisionBox;
|
BoxComponent collisionBox;
|
||||||
|
String displayName;
|
||||||
String geometry;
|
String geometry;
|
||||||
Map<String, MaterialInstance> materialInstances;
|
Map<String, MaterialInstance> materialInstances;
|
||||||
Float destroyTime;
|
Float destroyTime;
|
||||||
@ -52,10 +53,12 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
|||||||
Integer lightEmission;
|
Integer lightEmission;
|
||||||
Integer lightDampening;
|
Integer lightDampening;
|
||||||
RotationComponent rotation;
|
RotationComponent rotation;
|
||||||
|
boolean placeAir;
|
||||||
|
|
||||||
private GeyserCustomBlockComponents(CustomBlockComponentsBuilder builder) {
|
private GeyserCustomBlockComponents(CustomBlockComponentsBuilder builder) {
|
||||||
this.selectionBox = builder.selectionBox;
|
this.selectionBox = builder.selectionBox;
|
||||||
this.collisionBox = builder.collisionBox;
|
this.collisionBox = builder.collisionBox;
|
||||||
|
this.displayName = builder.displayName;
|
||||||
this.geometry = builder.geometry;
|
this.geometry = builder.geometry;
|
||||||
if (builder.materialInstances.isEmpty()) {
|
if (builder.materialInstances.isEmpty()) {
|
||||||
this.materialInstances = Object2ObjectMaps.emptyMap();
|
this.materialInstances = Object2ObjectMaps.emptyMap();
|
||||||
@ -67,6 +70,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
|||||||
this.lightEmission = builder.lightEmission;
|
this.lightEmission = builder.lightEmission;
|
||||||
this.lightDampening = builder.lightDampening;
|
this.lightDampening = builder.lightDampening;
|
||||||
this.rotation = builder.rotation;
|
this.rotation = builder.rotation;
|
||||||
|
this.placeAir = builder.placeAir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -79,6 +83,11 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
|||||||
return collisionBox;
|
return collisionBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String displayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String geometry() {
|
public String geometry() {
|
||||||
return geometry;
|
return geometry;
|
||||||
@ -114,6 +123,11 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
|||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeAir() {
|
||||||
|
return placeAir;
|
||||||
|
}
|
||||||
|
|
||||||
public static class CustomBlockComponentsBuilder implements Builder {
|
public static class CustomBlockComponentsBuilder implements Builder {
|
||||||
protected BoxComponent selectionBox;
|
protected BoxComponent selectionBox;
|
||||||
protected BoxComponent collisionBox;
|
protected BoxComponent collisionBox;
|
||||||
@ -125,6 +139,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
|||||||
protected Integer lightEmission;
|
protected Integer lightEmission;
|
||||||
protected Integer lightDampening;
|
protected Integer lightDampening;
|
||||||
protected RotationComponent rotation;
|
protected RotationComponent rotation;
|
||||||
|
protected boolean placeAir = false;
|
||||||
|
|
||||||
private static final Set<String> VALID_MATERIAL_INSTANCE_NAMES = ImmutableSet.of("*", "up", "down", "north", "south", "west", "east");
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder displayName(String displayName) {
|
||||||
|
this.displayName = displayName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder geometry(String geometry) {
|
public Builder geometry(String geometry) {
|
||||||
this.geometry = geometry;
|
this.geometry = geometry;
|
||||||
@ -226,6 +247,12 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Builder placeAir(boolean placeAir) {
|
||||||
|
this.placeAir = placeAir;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomBlockComponents build() {
|
public CustomBlockComponents build() {
|
||||||
return new GeyserCustomBlockComponents(this);
|
return new GeyserCustomBlockComponents(this);
|
||||||
|
@ -204,6 +204,11 @@ public class CustomBlockRegistryPopulator {
|
|||||||
.putFloat("z", components.rotation().z())
|
.putFloat("z", components.rotation().z())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
if (components.placeAir()) {
|
||||||
|
builder.putCompound("minecraft:on_player_placing", NbtMap.builder()
|
||||||
|
.putString("triggerType", "geyser:place_event")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ public class CustomSkull {
|
|||||||
.destroyTime(1.5f)
|
.destroyTime(1.5f)
|
||||||
.materialInstance("*", new MaterialInstance("geyser." + skinHash + "_player_skin", "alpha_test", true, true))
|
.materialInstance("*", new MaterialInstance("geyser." + skinHash + "_player_skin", "alpha_test", true, true))
|
||||||
.lightDampening(0)
|
.lightDampening(0)
|
||||||
|
.placeAir(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<CustomBlockPermutation> permutations = new ArrayList<>();
|
List<CustomBlockPermutation> permutations = new ArrayList<>();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren