3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Strip unnecessary block entity tag from container NBT

Dieser Commit ist enthalten in:
RednedEpic 2023-06-13 22:54:55 -05:00
Ursprung 1b0d03824a
Commit d43a862491
3 geänderte Dateien mit 34 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -315,7 +315,7 @@ public final class Items {
public static final Item PURPUR_PILLAR = register(new BlockItem("purpur_pillar", builder())); public static final Item PURPUR_PILLAR = register(new BlockItem("purpur_pillar", builder()));
public static final Item PURPUR_STAIRS = register(new BlockItem("purpur_stairs", builder())); public static final Item PURPUR_STAIRS = register(new BlockItem("purpur_stairs", builder()));
public static final Item SPAWNER = register(new BlockItem("spawner", builder())); public static final Item SPAWNER = register(new BlockItem("spawner", builder()));
public static final Item CHEST = register(new BlockItem("chest", builder())); public static final Item CHEST = register(new ChestItem("chest", builder()));
public static final Item CRAFTING_TABLE = register(new BlockItem("crafting_table", builder())); public static final Item CRAFTING_TABLE = register(new BlockItem("crafting_table", builder()));
public static final Item FARMLAND = register(new BlockItem("farmland", builder())); public static final Item FARMLAND = register(new BlockItem("farmland", builder()));
public static final Item FURNACE = register(new BlockItem("furnace", builder())); public static final Item FURNACE = register(new BlockItem("furnace", builder()));
@ -397,7 +397,7 @@ public final class Items {
public static final Item END_STONE_BRICKS = register(new BlockItem("end_stone_bricks", builder())); public static final Item END_STONE_BRICKS = register(new BlockItem("end_stone_bricks", builder()));
public static final Item DRAGON_EGG = register(new BlockItem("dragon_egg", builder())); public static final Item DRAGON_EGG = register(new BlockItem("dragon_egg", builder()));
public static final Item SANDSTONE_STAIRS = register(new BlockItem("sandstone_stairs", builder())); public static final Item SANDSTONE_STAIRS = register(new BlockItem("sandstone_stairs", builder()));
public static final Item ENDER_CHEST = register(new BlockItem("ender_chest", builder())); public static final Item ENDER_CHEST = register(new ChestItem("ender_chest", builder()));
public static final Item EMERALD_BLOCK = register(new BlockItem("emerald_block", builder())); public static final Item EMERALD_BLOCK = register(new BlockItem("emerald_block", builder()));
public static final Item OAK_STAIRS = register(new BlockItem("oak_stairs", builder())); public static final Item OAK_STAIRS = register(new BlockItem("oak_stairs", builder()));
public static final Item SPRUCE_STAIRS = register(new BlockItem("spruce_stairs", builder())); public static final Item SPRUCE_STAIRS = register(new BlockItem("spruce_stairs", builder()));
@ -694,7 +694,7 @@ public final class Items {
public static final Item SCULK_SENSOR = register(new BlockItem("sculk_sensor", builder())); public static final Item SCULK_SENSOR = register(new BlockItem("sculk_sensor", builder()));
public static final Item CALIBRATED_SCULK_SENSOR = register(new BlockItem("calibrated_sculk_sensor", builder())); public static final Item CALIBRATED_SCULK_SENSOR = register(new BlockItem("calibrated_sculk_sensor", builder()));
public static final Item TRIPWIRE_HOOK = register(new BlockItem("tripwire_hook", builder())); public static final Item TRIPWIRE_HOOK = register(new BlockItem("tripwire_hook", builder()));
public static final Item TRAPPED_CHEST = register(new BlockItem("trapped_chest", builder())); public static final Item TRAPPED_CHEST = register(new ChestItem("trapped_chest", builder()));
public static final Item TNT = register(new BlockItem("tnt", builder())); public static final Item TNT = register(new BlockItem("tnt", builder()));
public static final Item REDSTONE_LAMP = register(new BlockItem("redstone_lamp", builder())); public static final Item REDSTONE_LAMP = register(new BlockItem("redstone_lamp", builder()));
public static final Item NOTE_BLOCK = register(new BlockItem("note_block", builder())); public static final Item NOTE_BLOCK = register(new BlockItem("note_block", builder()));
@ -1192,7 +1192,7 @@ public final class Items {
public static final Item PIGLIN_BANNER_PATTERN = register(new Item("piglin_banner_pattern", builder().stackSize(1))); public static final Item PIGLIN_BANNER_PATTERN = register(new Item("piglin_banner_pattern", builder().stackSize(1)));
public static final Item GOAT_HORN = register(new GoatHornItem("goat_horn", builder().stackSize(1))); public static final Item GOAT_HORN = register(new GoatHornItem("goat_horn", builder().stackSize(1)));
public static final Item COMPOSTER = register(new BlockItem("composter", builder())); public static final Item COMPOSTER = register(new BlockItem("composter", builder()));
public static final Item BARREL = register(new BlockItem("barrel", builder())); public static final Item BARREL = register(new ChestItem("barrel", builder()));
public static final Item SMOKER = register(new BlockItem("smoker", builder())); public static final Item SMOKER = register(new BlockItem("smoker", builder()));
public static final Item BLAST_FURNACE = register(new BlockItem("blast_furnace", builder())); public static final Item BLAST_FURNACE = register(new BlockItem("blast_furnace", builder()));
public static final Item CARTOGRAPHY_TABLE = register(new BlockItem("cartography_table", builder())); public static final Item CARTOGRAPHY_TABLE = register(new BlockItem("cartography_table", builder()));

Datei anzeigen

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org * Copyright (c) 2019-2023 GeyserMC. http://geysermc.org
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -23,42 +23,31 @@
* @link https://github.com/GeyserMC/Geyser * @link https://github.com/GeyserMC/Geyser
*/ */
package org.geysermc.geyser.translator.inventory.item; package org.geysermc.geyser.item.type;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import org.geysermc.geyser.item.type.Item; import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.registry.type.ItemMapping;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
public abstract class NbtItemStackTranslator { public class ChestItem extends BlockItem {
/**
* Translate the item NBT to Bedrock
* @param session the client's current session
* @param itemTag the item's CompoundTag (cloned from Geyser's cached copy)
* @param mapping Geyser's item mapping
*/
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemMapping mapping) {
public ChestItem(String javaIdentifier, Builder builder) {
super(javaIdentifier, builder);
} }
/** @Override
* Translate the item NBT to Java. public void translateNbtToBedrock(@NonNull GeyserSession session, @NonNull CompoundTag tag) {
* @param itemTag the item's CompoundTag super.translateNbtToBedrock(session, tag);
* @param mapping Geyser's item mapping
*/
public void translateToJava(CompoundTag itemTag, ItemMapping mapping) {
// Strip the BlockEntityTag from the chests contents
// sent to the client. The client does not parse this
// or use it for anything, as this tag is fully
// server-side, so we remove it to reduce bandwidth and
// solve potential issues with very large tags.
// There was a problem in the past where this would strip
// NBT data in creative mode, however with the new server
// authoritative inventories, this is no longer a concern.
tag.remove("BlockEntityTag");
} }
/**
* Gets whether this nbt translator takes in this item.
*
* @param item Geyser's item mapping
* @return if the item should be processed under this class
*/
public boolean acceptItem(Item item) {
return true;
} // TODO
} }

Datei anzeigen

@ -77,9 +77,17 @@ public class ShulkerBoxItem extends BlockItem {
itemsList.add(boxItemTag); itemsList.add(boxItemTag);
} }
tag.put(itemsList); tag.put(itemsList);
// Don't actually bother with removing the block entity tag. Too risky to translate
// if the user is on creative and messing with a shulker box // Strip the BlockEntityTag from the chests contents
//itemTag.remove("BlockEntityTag"); // sent to the client. The client does not parse this
// or use it for anything, as this tag is fully
// server-side, so we remove it to reduce bandwidth and
// solve potential issues with very large tags.
// There was a problem in the past where this would strip
// NBT data in creative mode, however with the new server
// authoritative inventories, this is no longer a concern.
tag.remove("BlockEntityTag");
} }
@Override @Override