3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Fix banner block entity base colors with no patterns

Dieser Commit ist enthalten in:
Camotoy 2024-04-29 00:47:52 -04:00
Ursprung e8c1c2218f
Commit 88ae447fc6
4 geänderte Dateien mit 20 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.translator.level.block.entity; package org.geysermc.geyser.translator.level.block.entity;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder; import org.cloudburstmc.nbt.NbtMapBuilder;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
@ -40,9 +41,13 @@ public abstract class BlockEntityTranslator {
public abstract void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, NbtMap javaNbt, int blockState); public abstract void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, NbtMap javaNbt, int blockState);
public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, NbtMap javaNbt, int blockState) { public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, @Nullable NbtMap javaNbt, int blockState) {
NbtMapBuilder tagBuilder = getConstantBedrockTag(type, x, y, z); NbtMapBuilder tagBuilder = getConstantBedrockTag(type, x, y, z);
translateTag(session, tagBuilder, javaNbt, blockState); if (javaNbt != null || this instanceof RequiresBlockState) {
// Always process tags if the block state is part of the tag.
// See: banner base colors.
translateTag(session, tagBuilder, javaNbt, blockState);
}
return tagBuilder.build(); return tagBuilder.build();
} }

Datei anzeigen

@ -40,7 +40,10 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType
public class SpawnerBlockEntityTranslator extends BlockEntityTranslator { public class SpawnerBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, NbtMap javaNbt, int blockState) { public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, @Nullable NbtMap javaNbt, int blockState) {
if (javaNbt == null) {
return super.getBlockEntityTag(session, type, x, y, z, javaNbt, blockState);
}
// Sending an empty EntityIdentifier to empty the spawner is ignored by the client, so we send a whole new spawner! // Sending an empty EntityIdentifier to empty the spawner is ignored by the client, so we send a whole new spawner!
// Fixes https://github.com/GeyserMC/Geyser/issues/4214 // Fixes https://github.com/GeyserMC/Geyser/issues/4214
NbtMap spawnData = javaNbt.getCompound("SpawnData"); NbtMap spawnData = javaNbt.getCompound("SpawnData");

Datei anzeigen

@ -25,6 +25,7 @@
package org.geysermc.geyser.translator.level.block.entity; package org.geysermc.geyser.translator.level.block.entity;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.math.vector.Vector3i;
import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.nbt.NbtMapBuilder; import org.cloudburstmc.nbt.NbtMapBuilder;
@ -39,7 +40,10 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType
public class StructureBlockBlockEntityTranslator extends BlockEntityTranslator { public class StructureBlockBlockEntityTranslator extends BlockEntityTranslator {
@Override @Override
public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, NbtMap javaNbt, int blockState) { public NbtMap getBlockEntityTag(GeyserSession session, BlockEntityType type, int x, int y, int z, @Nullable NbtMap javaNbt, int blockState) {
if (javaNbt == null) {
return super.getBlockEntityTag(session, type, x, y, z, javaNbt, blockState);
}
// Sending a structure with size 0 doesn't clear the outline. Hence, we have to force it by replacing the block :/ // Sending a structure with size 0 doesn't clear the outline. Hence, we have to force it by replacing the block :/
int xStructureSize = javaNbt.getInt("sizeX"); int xStructureSize = javaNbt.getInt("sizeX");
int yStructureSize = javaNbt.getInt("sizeY"); int yStructureSize = javaNbt.getInt("sizeY");

Datei anzeigen

@ -412,13 +412,10 @@ public class JavaLevelChunkWithLightTranslator extends PacketTranslator<Clientbo
continue; continue;
} }
if (tag != null) { // Note that, since 1.20.5, tags can be null, but Bedrock still needs a default tag to render the item
BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(type); // Also, some properties - like banner base colors - are part of the tag and is processed here.
bedrockBlockEntities.add(blockEntityTranslator.getBlockEntityTag(session, type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState)); BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(type);
} else { bedrockBlockEntities.add(blockEntityTranslator.getBlockEntityTag(session, type, x + chunkBlockX, y, z + chunkBlockZ, tag, blockState));
// Since 1.20.5, tags can be null, but Bedrock still needs a default tag to render the item
bedrockBlockEntities.add(BlockEntityTranslator.getConstantBedrockTag(type, x + chunkBlockX, y, z + chunkBlockZ).build());
}
// Check for custom skulls // Check for custom skulls
if (session.getPreferencesCache().showCustomSkulls() && type == BlockEntityType.SKULL && tag != null && tag.containsKey("profile")) { if (session.getPreferencesCache().showCustomSkulls() && type == BlockEntityType.SKULL && tag != null && tag.containsKey("profile")) {