Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 08:10:11 +01:00
ominous banners - this really isn't ideal
Dieser Commit ist enthalten in:
Ursprung
8b7b8cdffd
Commit
5d3630cf23
@ -244,8 +244,8 @@ public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
|
|||||||
|
|
||||||
if (Boolean.parseBoolean(System.getProperty("Geyser.UseDirectAdapters", "true"))) {
|
if (Boolean.parseBoolean(System.getProperty("Geyser.UseDirectAdapters", "true"))) {
|
||||||
try {
|
try {
|
||||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
String version = Bukkit.getBukkitVersion().split("-")[0];
|
||||||
String nmsVersion = name.substring(name.lastIndexOf('.') + 1);
|
String nmsVersion = "v" + version.replace(".", "_");
|
||||||
SpigotAdapters.registerWorldAdapter(nmsVersion);
|
SpigotAdapters.registerWorldAdapter(nmsVersion);
|
||||||
if (isViaVersion && isViaVersionNeeded()) {
|
if (isViaVersion && isViaVersionNeeded()) {
|
||||||
this.geyserWorldManager = new GeyserSpigotLegacyNativeWorldManager(this);
|
this.geyserWorldManager = new GeyserSpigotLegacyNativeWorldManager(this);
|
||||||
|
@ -45,7 +45,7 @@ public enum BannerPattern {
|
|||||||
STRIPE_MIDDLE("ms"),
|
STRIPE_MIDDLE("ms"),
|
||||||
STRIPE_DOWNRIGHT("drs"),
|
STRIPE_DOWNRIGHT("drs"),
|
||||||
STRIPE_DOWNLEFT("dls"),
|
STRIPE_DOWNLEFT("dls"),
|
||||||
SMALL_STRIPES("ss"),
|
STRIPE_SMALL("ss"),
|
||||||
CROSS("cr"),
|
CROSS("cr"),
|
||||||
STRAIGHT_CROSS("sc"),
|
STRAIGHT_CROSS("sc"),
|
||||||
TRIANGLE_BOTTOM("bt"),
|
TRIANGLE_BOTTOM("bt"),
|
||||||
@ -53,15 +53,15 @@ public enum BannerPattern {
|
|||||||
TRIANGLES_BOTTOM("bts"),
|
TRIANGLES_BOTTOM("bts"),
|
||||||
TRIANGLES_TOP("tts"),
|
TRIANGLES_TOP("tts"),
|
||||||
DIAGONAL_LEFT("ld"),
|
DIAGONAL_LEFT("ld"),
|
||||||
DIAGONAL_UP_RIGHT("rd"),
|
DIAGONAL_RIGHT("rd"),
|
||||||
DIAGONAL_UP_LEFT("lud"),
|
DIAGONAL_LEFT_MIRROR("lud"),
|
||||||
DIAGONAL_RIGHT("rud"),
|
DIAGONAL_RIGHT_MIRROR("rud"),
|
||||||
CIRCLE("mc"),
|
CIRCLE_MIDDLE("mc"),
|
||||||
RHOMBUS("mr"),
|
RHOMBUS_MIDDLE("mr"),
|
||||||
HALF_VERTICAL("vh"),
|
HALF_VERTICAL("vh"),
|
||||||
HALF_HORIZONTAL("hh"),
|
HALF_HORIZONTAL("hh"),
|
||||||
HALF_VERTICAL_RIGHT("vhr"),
|
HALF_VERTICAL_MIRROR("vhr"),
|
||||||
HALF_HORIZONTAL_BOTTOM("hhb"),
|
HALF_HORIZONTAL_MIRROR("hhb"),
|
||||||
BORDER("bo"),
|
BORDER("bo"),
|
||||||
CURLY_BORDER("cbo"),
|
CURLY_BORDER("cbo"),
|
||||||
GRADIENT("gra"),
|
GRADIENT("gra"),
|
||||||
|
@ -26,18 +26,26 @@
|
|||||||
package org.geysermc.geyser.item.type;
|
package org.geysermc.geyser.item.type;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
import it.unimi.dsi.fastutil.Pair;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.Style;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.cloudburstmc.nbt.NbtList;
|
import org.cloudburstmc.nbt.NbtList;
|
||||||
import org.cloudburstmc.nbt.NbtMap;
|
import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.cloudburstmc.nbt.NbtType;
|
import org.cloudburstmc.nbt.NbtType;
|
||||||
|
import org.cloudburstmc.protocol.common.util.Int2ObjectBiMap;
|
||||||
import org.geysermc.geyser.inventory.item.BannerPattern;
|
import org.geysermc.geyser.inventory.item.BannerPattern;
|
||||||
import org.geysermc.geyser.inventory.item.DyeColor;
|
import org.geysermc.geyser.inventory.item.DyeColor;
|
||||||
import org.geysermc.geyser.registry.type.ItemMapping;
|
import org.geysermc.geyser.registry.type.ItemMapping;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
import org.geysermc.geyser.text.GeyserLocale;
|
||||||
|
import org.geysermc.geyser.text.MinecraftLocale;
|
||||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.Holder;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||||
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.Unit;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -56,13 +64,13 @@ public class BannerItem extends BlockItem {
|
|||||||
static {
|
static {
|
||||||
// Construct what an ominous banner is supposed to look like
|
// Construct what an ominous banner is supposed to look like
|
||||||
OMINOUS_BANNER_PATTERN = List.of(
|
OMINOUS_BANNER_PATTERN = List.of(
|
||||||
Pair.of(BannerPattern.RHOMBUS, DyeColor.CYAN),
|
Pair.of(BannerPattern.RHOMBUS_MIDDLE, DyeColor.CYAN),
|
||||||
Pair.of(BannerPattern.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY),
|
Pair.of(BannerPattern.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY),
|
||||||
Pair.of(BannerPattern.STRIPE_CENTER, DyeColor.GRAY),
|
Pair.of(BannerPattern.STRIPE_CENTER, DyeColor.GRAY),
|
||||||
Pair.of(BannerPattern.BORDER, DyeColor.LIGHT_GRAY),
|
Pair.of(BannerPattern.BORDER, DyeColor.LIGHT_GRAY),
|
||||||
Pair.of(BannerPattern.STRIPE_MIDDLE, DyeColor.BLACK),
|
Pair.of(BannerPattern.STRIPE_MIDDLE, DyeColor.BLACK),
|
||||||
Pair.of(BannerPattern.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY),
|
Pair.of(BannerPattern.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY),
|
||||||
Pair.of(BannerPattern.CIRCLE, DyeColor.LIGHT_GRAY),
|
Pair.of(BannerPattern.CIRCLE_MIDDLE, DyeColor.LIGHT_GRAY),
|
||||||
Pair.of(BannerPattern.BORDER, DyeColor.BLACK)
|
Pair.of(BannerPattern.BORDER, DyeColor.BLACK)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -171,14 +179,13 @@ public class BannerItem extends BlockItem {
|
|||||||
* @return The Java edition format pattern layer
|
* @return The Java edition format pattern layer
|
||||||
*/
|
*/
|
||||||
public static BannerPatternLayer getJavaBannerPattern(GeyserSession session, NbtMap pattern) {
|
public static BannerPatternLayer getJavaBannerPattern(GeyserSession session, NbtMap pattern) {
|
||||||
return null; // TODO
|
Int2ObjectBiMap<BannerPattern> registry = session.getRegistryCache().bannerPatterns();
|
||||||
/*Int2ObjectBiMap<BannerPattern> registry = session.getRegistryCache().bannerPatterns();
|
|
||||||
BannerPattern bannerPattern = BannerPattern.getByBedrockIdentifier(pattern.getString("Pattern"));
|
BannerPattern bannerPattern = BannerPattern.getByBedrockIdentifier(pattern.getString("Pattern"));
|
||||||
DyeColor dyeColor = DyeColor.getById(15 - pattern.getInt("Color"));
|
DyeColor dyeColor = DyeColor.getById(15 - pattern.getInt("Color"));
|
||||||
if (bannerPattern != null && dyeColor != null && registry.containsValue(bannerPattern)) {
|
if (bannerPattern != null && dyeColor != null && registry.containsValue(bannerPattern)) {
|
||||||
return new BannerPatternLayer(Holder.ofId(registry.get(bannerPattern)), dyeColor.ordinal());
|
return new BannerPatternLayer(Holder.ofId(registry.get(bannerPattern)), dyeColor.ordinal());
|
||||||
}
|
}
|
||||||
return null;*/
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BannerItem(String javaIdentifier, Builder builder) {
|
public BannerItem(String javaIdentifier, Builder builder) {
|
||||||
@ -196,13 +203,22 @@ public class BannerItem extends BlockItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateNbtToJava(@NonNull NbtMap bedrockTag, @NonNull DataComponents components, @NonNull ItemMapping mapping) { // TODO
|
public void translateNbtToJava(@NonNull NbtMap bedrockTag, @NonNull DataComponents components, @NonNull ItemMapping mapping) {
|
||||||
super.translateNbtToJava(bedrockTag, components, mapping);
|
super.translateNbtToJava(bedrockTag, components, mapping);
|
||||||
|
|
||||||
if (bedrockTag.getInt("Type") == 1) {
|
if (bedrockTag.getInt("Type") == 1) {
|
||||||
// Ominous banner pattern
|
// Ominous banner pattern
|
||||||
// TODO more registry stuff
|
List<BannerPatternLayer> patternLayers = new ArrayList<>();
|
||||||
//components.put(DataComponentType.BANNER_PATTERNS);
|
for (Pair<BannerPattern, DyeColor> pair : OMINOUS_BANNER_PATTERN) {
|
||||||
|
patternLayers.add(new BannerPatternLayer(Holder.ofId(pair.left().ordinal()), pair.right().ordinal()));
|
||||||
|
}
|
||||||
|
|
||||||
|
components.put(DataComponentType.BANNER_PATTERNS, patternLayers);
|
||||||
|
components.put(DataComponentType.HIDE_ADDITIONAL_TOOLTIP, Unit.INSTANCE);
|
||||||
|
components.put(DataComponentType.ITEM_NAME, Component.text(
|
||||||
|
MinecraftLocale.getLocaleString("block.minecraft.ominous_banner", GeyserLocale.getDefaultLocale())
|
||||||
|
).style(Style.style(TextColor.color(16755200)))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Bedrock's creative inventory does not support other patterns as of 1.20.5
|
// Bedrock's creative inventory does not support other patterns as of 1.20.5
|
||||||
}
|
}
|
||||||
|
@ -579,6 +579,7 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource {
|
|||||||
|
|
||||||
private final GeyserEntityData entityData;
|
private final GeyserEntityData entityData;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private MinecraftProtocol protocol;
|
private MinecraftProtocol protocol;
|
||||||
|
|
||||||
public GeyserSession(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop eventLoop) {
|
public GeyserSession(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop eventLoop) {
|
||||||
|
@ -34,6 +34,7 @@ import lombok.Getter;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.TrimMaterial;
|
import org.cloudburstmc.protocol.bedrock.data.TrimMaterial;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
|
import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
|
||||||
|
import org.cloudburstmc.protocol.common.util.Int2ObjectBiMap;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.entity.type.living.animal.tameable.WolfEntity;
|
import org.geysermc.geyser.entity.type.living.animal.tameable.WolfEntity;
|
||||||
import org.geysermc.geyser.inventory.item.BannerPattern;
|
import org.geysermc.geyser.inventory.item.BannerPattern;
|
||||||
@ -70,7 +71,7 @@ public final class RegistryCache {
|
|||||||
register("trim_material", cache -> cache.trimMaterials, TrimRecipe::readTrimMaterial);
|
register("trim_material", cache -> cache.trimMaterials, TrimRecipe::readTrimMaterial);
|
||||||
register("trim_pattern", cache -> cache.trimPatterns, TrimRecipe::readTrimPattern);
|
register("trim_pattern", cache -> cache.trimPatterns, TrimRecipe::readTrimPattern);
|
||||||
register("worldgen/biome", (cache, array) -> cache.biomeTranslations = array, BiomeTranslator::loadServerBiome);
|
register("worldgen/biome", (cache, array) -> cache.biomeTranslations = array, BiomeTranslator::loadServerBiome);
|
||||||
register("banner_pattern", cache -> cache.bannerPatterns, ($, entry) -> BannerPattern.getByJavaIdentifier(entry.getId()));
|
registerBannerRegistry(($, entry) -> BannerPattern.getByJavaIdentifier(entry.getId()));
|
||||||
register("wolf_variant", cache -> cache.wolfVariants, ($, entry) -> WolfEntity.WolfVariant.getByJavaIdentifier(entry.getId()));
|
register("wolf_variant", cache -> cache.wolfVariants, ($, entry) -> WolfEntity.WolfVariant.getByJavaIdentifier(entry.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +90,7 @@ public final class RegistryCache {
|
|||||||
private final Int2ObjectMap<TrimMaterial> trimMaterials = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<TrimMaterial> trimMaterials = new Int2ObjectOpenHashMap<>();
|
||||||
private final Int2ObjectMap<TrimPattern> trimPatterns = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<TrimPattern> trimPatterns = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
private final Int2ObjectMap<BannerPattern> bannerPatterns = new Int2ObjectOpenHashMap<>();
|
private Int2ObjectBiMap<BannerPattern> bannerPatterns = new Int2ObjectBiMap<>();
|
||||||
private final Int2ObjectMap<WolfEntity.WolfVariant> wolfVariants = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<WolfEntity.WolfVariant> wolfVariants = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
public RegistryCache(GeyserSession session) {
|
public RegistryCache(GeyserSession session) {
|
||||||
@ -108,6 +109,20 @@ public final class RegistryCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> void registerBannerRegistry(BiFunction<GeyserSession, RegistryEntry, T> reader) {
|
||||||
|
REGISTRIES.put("minecraft:banner_pattern", ((registryCache, entries) -> {
|
||||||
|
// Clear each local cache every time a new registry entry is given to us
|
||||||
|
// (e.g. proxy server switches)
|
||||||
|
registryCache.bannerPatterns = new Int2ObjectBiMap<>();
|
||||||
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
|
RegistryEntry entry = entries.get(i);
|
||||||
|
// This is what Geyser wants to keep as a value for this registry.
|
||||||
|
T cacheEntry = reader.apply(registryCache.session, entry);
|
||||||
|
registryCache.bannerPatterns.put(i, (BannerPattern) cacheEntry);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param registry the Java registry resource location, without the "minecraft:" prefix.
|
* @param registry the Java registry resource location, without the "minecraft:" prefix.
|
||||||
* @param localCacheFunction which local field in RegistryCache are we caching entries for this registry?
|
* @param localCacheFunction which local field in RegistryCache are we caching entries for this registry?
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren