mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix NPEs when loading in chunks with double chests
This commit is contained in:
parent
44083b80af
commit
0d7bf7b71a
2 changed files with 4 additions and 16 deletions
|
@ -27,8 +27,6 @@ package org.geysermc.geyser.translator.level.block.entity;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
|
@ -49,15 +47,6 @@ public abstract class BlockEntityTranslator {
|
|||
return tagBuilder.build();
|
||||
}
|
||||
|
||||
protected CompoundTag getConstantJavaTag(String javaId, int x, int y, int z) {
|
||||
CompoundTag tag = new CompoundTag("");
|
||||
tag.put(new IntTag("x", x));
|
||||
tag.put(new IntTag("y", y));
|
||||
tag.put(new IntTag("z", z));
|
||||
tag.put(new StringTag("id", javaId));
|
||||
return tag;
|
||||
}
|
||||
|
||||
protected NbtMapBuilder getConstantBedrockTag(String bedrockId, int x, int y, int z) {
|
||||
return NbtMap.builder()
|
||||
.putInt("x", x)
|
||||
|
|
|
@ -46,18 +46,17 @@ public class DoubleChestBlockEntityTranslator extends BlockEntityTranslator impl
|
|||
|
||||
@Override
|
||||
public void updateBlock(GeyserSession session, int blockState, Vector3i position) {
|
||||
CompoundTag javaTag = getConstantJavaTag("chest", position.getX(), position.getY(), position.getZ());
|
||||
NbtMapBuilder tagBuilder = getConstantBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(BlockEntityType.CHEST), position.getX(), position.getY(), position.getZ());
|
||||
translateTag(tagBuilder, javaTag, blockState);
|
||||
translateTag(tagBuilder, null, blockState);
|
||||
BlockEntityUtils.updateBlockEntity(session, tagBuilder.build(), position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
DoubleChestValue chestValues = BlockStateValues.getDoubleChestValues().getOrDefault(blockState, null);
|
||||
DoubleChestValue chestValues = BlockStateValues.getDoubleChestValues().get(blockState);
|
||||
if (chestValues != null) {
|
||||
int x = (int) tag.getValue().get("x").getValue();
|
||||
int z = (int) tag.getValue().get("z").getValue();
|
||||
int x = (int) builder.get("x");
|
||||
int z = (int) builder.get("z");
|
||||
translateChestValue(builder, chestValues, x, z);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue