From b2d9095815450620c7efb021d8abaa283c049f46 Mon Sep 17 00:00:00 2001 From: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> Date: Tue, 17 Jan 2023 21:37:27 -0800 Subject: [PATCH] Address @Camotoy's review Signed-off-by: Joshua Castle <26531652+Kas-tle@users.noreply.github.com> --- .../custom/component/MaterialInstance.java | 1 - .../placementfilter/PlacementFilter.java | 1 - .../block/custom/property/PropertyType.java | 7 +- .../configuration/GeyserConfiguration.java | 4 - .../GeyserJacksonConfiguration.java | 10 --- .../block/GeyserCustomBlockComponents.java | 17 ++-- .../geyser/pack/SkullResourcePackManager.java | 2 +- .../geysermc/geyser/registry/Registries.java | 18 ++++- .../mappings/versions/MappingsReader.java | 1 - .../populator/BlockRegistryPopulator.java | 44 +++++----- .../CustomBlockRegistryPopulator.java | 28 +++---- .../CustomSkullRegistryPopulator.java | 2 +- .../populator/ItemRegistryPopulator.java | 80 +++++++++---------- .../geyser/session/GeyserSession.java | 5 ++ .../inventory/item/ItemTranslator.java | 45 +++++------ core/src/main/resources/config.yml | 3 +- 16 files changed, 130 insertions(+), 138 deletions(-) diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java index bea22d321..a14bb2cef 100644 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java +++ b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/MaterialInstance.java @@ -31,5 +31,4 @@ import org.checkerframework.checker.nullness.qual.NonNull; * This class is used to store a material instance for a custom block. */ public record MaterialInstance(@NonNull String texture, @NonNull String renderMethod, boolean faceDimming, boolean ambientOcclusion) { - } diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/placementfilter/PlacementFilter.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/placementfilter/PlacementFilter.java index 14a25adeb..77e40bac4 100644 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/placementfilter/PlacementFilter.java +++ b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/component/placementfilter/PlacementFilter.java @@ -33,5 +33,4 @@ import org.checkerframework.checker.nullness.qual.NonNull; * This class is used to store a placement filter for a custom block. */ public record PlacementFilter(@NonNull List conditions) { - } diff --git a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/property/PropertyType.java b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/property/PropertyType.java index 099bc0a45..18afe9629 100644 --- a/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/property/PropertyType.java +++ b/api/geyser/src/main/java/org/geysermc/geyser/api/block/custom/property/PropertyType.java @@ -25,8 +25,6 @@ package org.geysermc.geyser.api.block.custom.property; -import lombok.Getter; - /** * This class is used to define a custom block property's type. */ @@ -35,9 +33,12 @@ public class PropertyType { public static final PropertyType INTEGER = new PropertyType(Integer.class); public static final PropertyType STRING = new PropertyType(String.class); - @Getter private final Class typeClass; + public Class getTypeClass() { + return typeClass; + } + private PropertyType(Class typeClass) { this.typeClass = typeClass; } diff --git a/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java b/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java index 73271d1db..4843df72b 100644 --- a/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java +++ b/core/src/main/java/org/geysermc/geyser/configuration/GeyserConfiguration.java @@ -93,10 +93,6 @@ public interface GeyserConfiguration { boolean isAddNonBedrockItems(); - boolean isAddCustomBlocks(); - - boolean isAddCustomSkullBlocks(); - boolean isAboveBedrockNetherBuilding(); boolean isForceResourcePacks(); diff --git a/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java b/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java index 9c05b6ded..dc675319b 100644 --- a/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java +++ b/core/src/main/java/org/geysermc/geyser/configuration/GeyserJacksonConfiguration.java @@ -142,12 +142,6 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration @JsonProperty("above-bedrock-nether-building") private boolean aboveBedrockNetherBuilding = false; - @JsonProperty("add-custom-blocks") - boolean addCustomBlocks = true; - - @JsonProperty("add-custom-skull-blocks") - boolean addCustomSkullBlocks = false; - @JsonProperty("force-resource-packs") private boolean forceResourcePacks = true; @@ -347,10 +341,6 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration @JsonProperty("config-version") private int configVersion = 0; - public boolean isAddCustomSkullBlocks() { - return addCustomBlocks && addCustomSkullBlocks; - } - /** * Ensure that the port deserializes in the config as a number no matter what. */ diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java index 47ccb4f41..cbe60eb47 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockComponents.java @@ -25,10 +25,11 @@ package org.geysermc.geyser.level.block; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import lombok.Value; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.api.block.custom.component.BoxComponent; import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; @@ -37,11 +38,9 @@ import org.geysermc.geyser.api.block.custom.component.RotationComponent; import org.geysermc.geyser.api.block.custom.component.placementfilter.PlacementFilter; import org.jetbrains.annotations.NotNull; -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import lombok.Value; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; @Value public class GeyserCustomBlockComponents implements CustomBlockComponents { diff --git a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java index 199cd64f0..4c938ee2b 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java +++ b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java @@ -73,7 +73,7 @@ public class SkullResourcePackManager { Path packPath = cachePath.resolve("player_skulls.mcpack"); File packFile = packPath.toFile(); - if (BlockRegistries.CUSTOM_SKULLS.get().isEmpty() || !GeyserImpl.getInstance().getConfig().isAddCustomSkullBlocks()) { + if (BlockRegistries.CUSTOM_SKULLS.get().isEmpty() || !GeyserImpl.getInstance().getConfig().isAddNonBedrockItems()) { packFile.delete(); // No need to keep resource pack return null; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/Registries.java b/core/src/main/java/org/geysermc/geyser/registry/Registries.java index e1b23e371..ecfc2cd09 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/Registries.java +++ b/core/src/main/java/org/geysermc/geyser/registry/Registries.java @@ -36,7 +36,6 @@ import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.protocol.bedrock.BedrockPacket; import com.nukkitx.protocol.bedrock.data.inventory.CraftingData; import com.nukkitx.protocol.bedrock.data.inventory.PotionMixData; - import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntMap; @@ -44,7 +43,16 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.inventory.item.Enchantment.JavaEnchantment; import org.geysermc.geyser.inventory.recipe.GeyserRecipe; -import org.geysermc.geyser.registry.loader.*; +import org.geysermc.geyser.registry.loader.BiomeIdentifierRegistryLoader; +import org.geysermc.geyser.registry.loader.BlockEntityRegistryLoader; +import org.geysermc.geyser.registry.loader.EnchantmentRegistryLoader; +import org.geysermc.geyser.registry.loader.ParticleTypesRegistryLoader; +import org.geysermc.geyser.registry.loader.PotionMixRegistryLoader; +import org.geysermc.geyser.registry.loader.ProviderRegistryLoader; +import org.geysermc.geyser.registry.loader.RegistryLoaders; +import org.geysermc.geyser.registry.loader.SoundEventsRegistryLoader; +import org.geysermc.geyser.registry.loader.SoundRegistryLoader; +import org.geysermc.geyser.registry.loader.SoundTranslatorRegistryLoader; import org.geysermc.geyser.registry.populator.ItemRegistryPopulator; import org.geysermc.geyser.registry.populator.PacketRegistryPopulator; import org.geysermc.geyser.registry.populator.RecipeRegistryPopulator; @@ -58,7 +66,11 @@ import org.geysermc.geyser.translator.level.event.LevelEventTranslator; import org.geysermc.geyser.translator.sound.SoundInteractionTranslator; import org.geysermc.geyser.translator.sound.SoundTranslator; -import java.util.*; +import java.util.EnumMap; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * Holds all the common registries in Geyser. diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader.java index d94f78251..e76df2834 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader.java @@ -26,7 +26,6 @@ package org.geysermc.geyser.registry.mappings.versions; import com.fasterxml.jackson.databind.JsonNode; - import org.geysermc.geyser.api.item.custom.CustomItemData; import org.geysermc.geyser.api.item.custom.CustomRenderOffsets; import org.geysermc.geyser.item.exception.InvalidCustomMappingsFileException; diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java index ceacf8a2b..da8511a7f 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/BlockRegistryPopulator.java @@ -25,28 +25,6 @@ package org.geysermc.geyser.registry.populator; -import java.io.DataInputStream; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.function.BiFunction; -import java.util.zip.GZIPInputStream; - -import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.api.block.custom.CustomBlockData; -import org.geysermc.geyser.api.block.custom.CustomBlockState; -import org.geysermc.geyser.level.block.BlockStateValues; -import org.geysermc.geyser.level.physics.PistonBehavior; -import org.geysermc.geyser.registry.BlockRegistries; -import org.geysermc.geyser.registry.type.BlockMapping; -import org.geysermc.geyser.registry.type.BlockMappings; -import org.geysermc.geyser.util.BlockUtils; - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.google.common.collect.ImmutableMap; @@ -58,7 +36,6 @@ import com.nukkitx.nbt.NbtType; import com.nukkitx.protocol.bedrock.data.BlockPropertyData; import com.nukkitx.protocol.bedrock.v544.Bedrock_v544; import com.nukkitx.protocol.bedrock.v560.Bedrock_v560; - import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; import it.unimi.dsi.fastutil.objects.Object2IntMap; @@ -66,6 +43,27 @@ import it.unimi.dsi.fastutil.objects.Object2IntMaps; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectIntPair; +import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.api.block.custom.CustomBlockData; +import org.geysermc.geyser.api.block.custom.CustomBlockState; +import org.geysermc.geyser.level.block.BlockStateValues; +import org.geysermc.geyser.level.physics.PistonBehavior; +import org.geysermc.geyser.registry.BlockRegistries; +import org.geysermc.geyser.registry.type.BlockMapping; +import org.geysermc.geyser.registry.type.BlockMappings; +import org.geysermc.geyser.util.BlockUtils; + +import java.io.DataInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Deque; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.function.BiFunction; +import java.util.zip.GZIPInputStream; /** * Populates the block registries. diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java index f3bf5f052..48a8a8259 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomBlockRegistryPopulator.java @@ -1,11 +1,11 @@ package org.geysermc.geyser.registry.populator; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - +import com.nukkitx.nbt.NbtMap; +import com.nukkitx.nbt.NbtMapBuilder; +import com.nukkitx.nbt.NbtType; +import com.nukkitx.protocol.bedrock.data.BlockPropertyData; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.GeyserImpl; @@ -15,8 +15,8 @@ import org.geysermc.geyser.api.block.custom.CustomBlockState; import org.geysermc.geyser.api.block.custom.component.BoxComponent; import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; import org.geysermc.geyser.api.block.custom.component.MaterialInstance; -import org.geysermc.geyser.api.block.custom.component.placementfilter.PlacementFilter; import org.geysermc.geyser.api.block.custom.component.placementfilter.Conditions.Face; +import org.geysermc.geyser.api.block.custom.component.placementfilter.PlacementFilter; import org.geysermc.geyser.api.block.custom.property.CustomBlockProperty; import org.geysermc.geyser.api.block.custom.property.PropertyType; import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCustomBlocksEvent; @@ -25,13 +25,11 @@ import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.mappings.MappingsConfigReader; import org.geysermc.geyser.registry.type.CustomSkull; -import com.nukkitx.nbt.NbtMap; -import com.nukkitx.nbt.NbtMapBuilder; -import com.nukkitx.nbt.NbtType; -import com.nukkitx.protocol.bedrock.data.BlockPropertyData; - -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; public class CustomBlockRegistryPopulator { @@ -39,7 +37,7 @@ public class CustomBlockRegistryPopulator { * Registers all custom blocks defined by extensions and user supplied mappings */ public static void registerCustomBedrockBlocks() { - if (!GeyserImpl.getInstance().getConfig().isAddCustomBlocks()) { + if (!GeyserImpl.getInstance().getConfig().isAddNonBedrockItems()) { return; } Set customBlockNames = new ObjectOpenHashSet<>(); diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java index c0b24bc65..bb2afce5b 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java @@ -52,7 +52,7 @@ public class CustomSkullRegistryPopulator { SkullResourcePackManager.SKULL_SKINS.clear(); // Remove skins after reloading BlockRegistries.CUSTOM_SKULLS.set(Object2ObjectMaps.emptyMap()); - if (!GeyserImpl.getInstance().getConfig().isAddCustomSkullBlocks()) { + if (!GeyserImpl.getInstance().getConfig().isAddNonBedrockItems()) { return; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java index b307e9a04..17661e760 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java @@ -25,18 +25,34 @@ package org.geysermc.geyser.registry.populator; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Base64; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; - +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.common.collect.Multimap; +import com.google.common.collect.MultimapBuilder; +import com.nukkitx.nbt.NbtMap; +import com.nukkitx.nbt.NbtMapBuilder; +import com.nukkitx.nbt.NbtType; +import com.nukkitx.nbt.NbtUtils; +import com.nukkitx.protocol.bedrock.data.SoundEvent; +import com.nukkitx.protocol.bedrock.data.inventory.ComponentItemData; +import com.nukkitx.protocol.bedrock.data.inventory.ItemData; +import com.nukkitx.protocol.bedrock.packet.StartGamePacket; +import com.nukkitx.protocol.bedrock.v544.Bedrock_v544; +import com.nukkitx.protocol.bedrock.v560.Bedrock_v560; +import it.unimi.dsi.fastutil.ints.Int2IntMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; +import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +import it.unimi.dsi.fastutil.ints.IntSet; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntMaps; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectIntPair; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.Constants; import org.geysermc.geyser.GeyserBootstrap; @@ -60,35 +76,17 @@ import org.geysermc.geyser.registry.type.PaletteItem; import org.geysermc.geyser.util.ItemUtils; import org.geysermc.geyser.util.collection.FixedInt2IntMap; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.JsonNode; -import com.google.common.collect.Multimap; -import com.google.common.collect.MultimapBuilder; -import com.nukkitx.nbt.NbtMap; -import com.nukkitx.nbt.NbtMapBuilder; -import com.nukkitx.nbt.NbtType; -import com.nukkitx.nbt.NbtUtils; -import com.nukkitx.protocol.bedrock.data.SoundEvent; -import com.nukkitx.protocol.bedrock.data.inventory.ComponentItemData; -import com.nukkitx.protocol.bedrock.data.inventory.ItemData; -import com.nukkitx.protocol.bedrock.packet.StartGamePacket; -import com.nukkitx.protocol.bedrock.v544.Bedrock_v544; -import com.nukkitx.protocol.bedrock.v560.Bedrock_v560; - -import it.unimi.dsi.fastutil.ints.Int2IntMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectMap; -import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.ints.IntArrayList; -import it.unimi.dsi.fastutil.ints.IntList; -import it.unimi.dsi.fastutil.ints.IntOpenHashSet; -import it.unimi.dsi.fastutil.ints.IntSet; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntMaps; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import it.unimi.dsi.fastutil.objects.ObjectIntPair; -import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; /** * Populates the item registries. diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index e9cd3833e..e01769ea6 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -1491,10 +1491,15 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { startGamePacket.setMultiplayerCorrelationId(""); startGamePacket.setItemEntries(this.itemMappings.getItemEntries()); + // Needed for custom block mappings and custom skulls system startGamePacket.getBlockProperties().addAll(this.blockMappings.getBlockProperties()); + // See https://learn.microsoft.com/en-us/minecraft/creator/documents/experimentalfeaturestoggle for info on each experiment + // data_driven_items (Holiday Creator Features) is needed for blocks and items startGamePacket.getExperiments().add(new ExperimentData("data_driven_items", true)); + // Needed for block properties for states startGamePacket.getExperiments().add(new ExperimentData("upcoming_creator_features", true)); + // Needed for certain molang queries used in blocks and items startGamePacket.getExperiments().add(new ExperimentData("experimental_molang_features", true)); startGamePacket.setVanillaVersion("*"); diff --git a/core/src/main/java/org/geysermc/geyser/translator/inventory/item/ItemTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/inventory/item/ItemTranslator.java index 7a8010484..b6235dba5 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/inventory/item/ItemTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/inventory/item/ItemTranslator.java @@ -25,29 +25,6 @@ package org.geysermc.geyser.translator.inventory.item; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; - -import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.api.block.custom.CustomBlockData; -import org.geysermc.geyser.inventory.GeyserItemStack; -import org.geysermc.geyser.registry.BlockRegistries; -import org.geysermc.geyser.registry.type.CustomSkull; -import org.geysermc.geyser.registry.type.ItemMapping; -import org.geysermc.geyser.registry.type.ItemMappings; -import org.geysermc.geyser.session.GeyserSession; -import org.geysermc.geyser.skin.SkinManager; -import org.geysermc.geyser.text.MinecraftLocale; -import org.geysermc.geyser.translator.text.MessageTranslator; -import org.geysermc.geyser.util.FileUtils; - import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack; import com.github.steveice10.opennbt.tag.builtin.ByteArrayTag; import com.github.steveice10.opennbt.tag.builtin.ByteTag; @@ -67,11 +44,31 @@ import com.nukkitx.nbt.NbtMap; import com.nukkitx.nbt.NbtMapBuilder; import com.nukkitx.nbt.NbtType; import com.nukkitx.protocol.bedrock.data.inventory.ItemData; - import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; +import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.api.block.custom.CustomBlockData; +import org.geysermc.geyser.inventory.GeyserItemStack; +import org.geysermc.geyser.registry.BlockRegistries; +import org.geysermc.geyser.registry.type.CustomSkull; +import org.geysermc.geyser.registry.type.ItemMapping; +import org.geysermc.geyser.registry.type.ItemMappings; +import org.geysermc.geyser.session.GeyserSession; +import org.geysermc.geyser.skin.SkinManager; +import org.geysermc.geyser.text.MinecraftLocale; +import org.geysermc.geyser.translator.text.MessageTranslator; +import org.geysermc.geyser.util.FileUtils; + +import javax.annotation.Nonnull; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; public abstract class ItemTranslator { private static final Int2ObjectMap ITEM_STACK_TRANSLATORS = new Int2ObjectOpenHashMap<>(); diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index c123e3cb1..46ad9f733 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -158,9 +158,10 @@ max-visible-custom-skulls: 128 # The radius in blocks around the player in which custom skulls are displayed. custom-skull-render-distance: 32 -# Whether to add (at this time, only) the furnace minecart as a separate item in the game, which normally does not exist in Bedrock Edition. +# Whether to add any items and blocks which normally does not exist in Bedrock Edition. # This should only need to be disabled if using a proxy that does not use the "transfer packet" style of server switching. # If this is disabled, furnace minecart items will be mapped to hopper minecart items. +# Geyser's block, item, and skull mappings systems will also be disabled. # This option requires a restart of Geyser in order to change its setting. add-non-bedrock-items: true