3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-02 08:00:07 +02:00
Dieser Commit ist enthalten in:
Joshua Castle 2023-01-05 19:46:33 -08:00
Ursprung 96967dafa2
Commit 010e99d2dc
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: F674F38216C35D5D
4 geänderte Dateien mit 40 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ package org.geysermc.geyser.api.block.custom.component;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Map; import java.util.Map;
import java.util.Set;
public interface CustomBlockComponents { public interface CustomBlockComponents {
BoxComponent selectionBox(); BoxComponent selectionBox();
@ -52,6 +53,8 @@ public interface CustomBlockComponents {
boolean placeAir(); boolean placeAir();
Set<String> tags();
interface Builder { interface Builder {
Builder selectionBox(BoxComponent selectionBox); Builder selectionBox(BoxComponent selectionBox);
@ -75,6 +78,8 @@ public interface CustomBlockComponents {
Builder placeAir(boolean placeAir); Builder placeAir(boolean placeAir);
Builder tags(Set<String> tags);
CustomBlockComponents build(); CustomBlockComponents build();
} }
} }

Datei anzeigen

@ -25,7 +25,9 @@
package org.geysermc.geyser.level.block; package org.geysermc.geyser.level.block;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.block.custom.component.BoxComponent; import org.geysermc.geyser.api.block.custom.component.BoxComponent;
@ -53,6 +55,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
Integer lightDampening; Integer lightDampening;
RotationComponent rotation; RotationComponent rotation;
boolean placeAir; boolean placeAir;
Set<String> tags;
private GeyserCustomBlockComponents(CustomBlockComponentsBuilder builder) { private GeyserCustomBlockComponents(CustomBlockComponentsBuilder builder) {
this.selectionBox = builder.selectionBox; this.selectionBox = builder.selectionBox;
@ -70,6 +73,11 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
this.lightDampening = builder.lightDampening; this.lightDampening = builder.lightDampening;
this.rotation = builder.rotation; this.rotation = builder.rotation;
this.placeAir = builder.placeAir; this.placeAir = builder.placeAir;
if (builder.tags.isEmpty()) {
this.tags = Set.of();
} else {
this.tags = Set.copyOf(builder.tags);
}
} }
@Override @Override
@ -127,6 +135,11 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
return placeAir; return placeAir;
} }
@Override
public Set<String> tags() {
return tags;
}
public static class CustomBlockComponentsBuilder implements Builder { public static class CustomBlockComponentsBuilder implements Builder {
protected BoxComponent selectionBox; protected BoxComponent selectionBox;
protected BoxComponent collisionBox; protected BoxComponent collisionBox;
@ -139,6 +152,7 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
protected Integer lightDampening; protected Integer lightDampening;
protected RotationComponent rotation; protected RotationComponent rotation;
protected boolean placeAir = false; protected boolean placeAir = false;
protected final Set<String> tags = new HashSet<>();
private void validateBox(BoxComponent box) { private void validateBox(BoxComponent box) {
if (box == null) { if (box == null) {
@ -247,6 +261,12 @@ public class GeyserCustomBlockComponents implements CustomBlockComponents {
return this; return this;
} }
@Override
public Builder tags(Set<String> tags) {
this.tags.addAll(tags);
return this;
}
@Override @Override
public CustomBlockComponents build() { public CustomBlockComponents build() {
return new GeyserCustomBlockComponents(this); return new GeyserCustomBlockComponents(this);

Datei anzeigen

@ -26,6 +26,8 @@
package org.geysermc.geyser.registry.mappings.versions; package org.geysermc.geyser.registry.mappings.versions;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.base.CharMatcher; import com.google.common.base.CharMatcher;
import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserImpl;
@ -383,6 +385,16 @@ public class MappingsReader_v1 extends MappingsReader {
} }
} }
if (node.has("tags")) {
JsonNode tags = node.get("tags");
if (tags.isArray()) {
ArrayNode tagsArray = (ArrayNode) tags;
Set<String> tagsSet = new HashSet<>();
tagsArray.forEach(tag -> tagsSet.add(tag.asText()));
builder.tags(tagsSet);
}
}
CustomBlockComponents components = builder.build(); CustomBlockComponents components = builder.build();
return components; return components;

Datei anzeigen

@ -227,6 +227,9 @@ public class CustomBlockRegistryPopulator {
.putString("triggerType", "geyser:place_event") .putString("triggerType", "geyser:place_event")
.build()); .build());
} }
if (!components.tags().isEmpty()) {
components.tags().forEach(tag -> builder.putCompound("tag:" + tag, NbtMap.EMPTY));
}
return builder.build(); return builder.build();
} }