3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-24 15:20:25 +01: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 java.util.Map;
import java.util.Set;
public interface CustomBlockComponents {
BoxComponent selectionBox();
@ -52,6 +53,8 @@ public interface CustomBlockComponents {
boolean placeAir();
Set<String> tags();
interface Builder {
Builder selectionBox(BoxComponent selectionBox);
@ -75,6 +78,8 @@ public interface CustomBlockComponents {
Builder placeAir(boolean placeAir);
Builder tags(Set<String> tags);
CustomBlockComponents build();
}
}

Datei anzeigen

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

Datei anzeigen

@ -26,6 +26,8 @@
package org.geysermc.geyser.registry.mappings.versions;
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 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();
return components;

Datei anzeigen

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