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

Fix translateTag NPE

Dieser Commit ist enthalten in:
AJ Ferguson 2024-04-29 04:20:24 -04:00
Ursprung a82a156419
Commit 4ff746e48a
3 geänderte Dateien mit 14 neuen und 3 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.cloudburstmc.nbt.NbtType; import org.cloudburstmc.nbt.NbtType;
@ -38,7 +39,7 @@ import java.util.List;
@BlockEntity(type = BlockEntityType.BANNER) @BlockEntity(type = BlockEntityType.BANNER)
public class BannerBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class BannerBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override @Override
public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, NbtMap javaNbt, int blockState) { public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, @Nullable NbtMap javaNbt, int blockState) {
int bannerColor = BlockStateValues.getBannerColor(blockState); int bannerColor = BlockStateValues.getBannerColor(blockState);
if (bannerColor != -1) { if (bannerColor != -1) {
bedrockNbt.putInt("Base", 15 - bannerColor); bedrockNbt.putInt("Base", 15 - bannerColor);

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.item.Items; import org.geysermc.geyser.item.Items;
@ -37,7 +38,11 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType
public class BrushableBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class BrushableBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override @Override
public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, NbtMap javaNbt, int blockState) { public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, @Nullable NbtMap javaNbt, int blockState) {
if (javaNbt == null) {
return;
}
NbtMap itemTag = javaNbt.getCompound("item"); NbtMap itemTag = javaNbt.getCompound("item");
if (itemTag.isEmpty()) { if (itemTag.isEmpty()) {
return; return;

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.level.block.BlockStateValues; import org.geysermc.geyser.level.block.BlockStateValues;
@ -34,7 +35,11 @@ import org.geysermc.mcprotocollib.protocol.data.game.level.block.BlockEntityType
@BlockEntity(type = BlockEntityType.JIGSAW) @BlockEntity(type = BlockEntityType.JIGSAW)
public class JigsawBlockBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState { public class JigsawBlockBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override @Override
public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, NbtMap javaNbt, int blockState) { public void translateTag(GeyserSession session, NbtMapBuilder bedrockNbt, @Nullable NbtMap javaNbt, int blockState) {
if (javaNbt == null) {
return;
}
String joint = javaNbt.getString("joint", null); String joint = javaNbt.getString("joint", null);
if (joint != null) { if (joint != null) {
bedrockNbt.putString("joint", joint); bedrockNbt.putString("joint", joint);