Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-09 17:50:20 +01:00
Fix first load crashing; fix NPE
Dieser Commit ist enthalten in:
Ursprung
1dc6d4fbdc
Commit
d547b31b38
@ -13,7 +13,6 @@ import java.util.List;
|
|||||||
public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator {
|
public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator {
|
||||||
@Override
|
@Override
|
||||||
public List<Tag<?>> translateTag(CompoundTag tag) {
|
public List<Tag<?>> translateTag(CompoundTag tag) {
|
||||||
System.out.println(tag);
|
|
||||||
List<Tag<?>> tags = new ArrayList<>();
|
List<Tag<?>> tags = new ArrayList<>();
|
||||||
tags.add(new IntTag("Age", (int) (long) tag.get("Age").getValue()));
|
tags.add(new IntTag("Age", (int) (long) tag.get("Age").getValue()));
|
||||||
// Java sometimes does not provide this tag, but Bedrock crashes if it doesn't exist
|
// Java sometimes does not provide this tag, but Bedrock crashes if it doesn't exist
|
||||||
@ -37,14 +36,18 @@ public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public com.nukkitx.nbt.tag.CompoundTag getDefaultBedrockTag(String bedrockId, int x, int y, int z) {
|
public com.nukkitx.nbt.tag.CompoundTag getDefaultBedrockTag(String bedrockId, int x, int y, int z) {
|
||||||
System.out.println("Default Bedrock tag being created");
|
|
||||||
CompoundTagBuilder tagBuilder = getConstantBedrockTag(bedrockId, x, y, z).toBuilder();
|
CompoundTagBuilder tagBuilder = getConstantBedrockTag(bedrockId, x, y, z).toBuilder();
|
||||||
tagBuilder.listTag("ExitPortal", IntTag.class, new ArrayList<>());
|
List<IntTag> tagsList = new ArrayList<>();
|
||||||
|
tagsList.add(new IntTag("", 0));
|
||||||
|
tagsList.add(new IntTag("", 0));
|
||||||
|
tagsList.add(new IntTag("", 0));
|
||||||
|
tagBuilder.listTag("ExitPortal", IntTag.class, tagsList);
|
||||||
return tagBuilder.buildRootTag();
|
return tagBuilder.buildRootTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getExitPortalCoordinate(CompoundTag tag, String axis) {
|
private int getExitPortalCoordinate(CompoundTag tag, String axis) {
|
||||||
if (tag.get("ExitPortal").getValue() != null) {
|
// Return 0 if it doesn't exist, otherwise give proper value
|
||||||
|
if (tag.get("ExitPortal") != null) {
|
||||||
LinkedHashMap compoundTag = (LinkedHashMap) tag.get("ExitPortal").getValue();
|
LinkedHashMap compoundTag = (LinkedHashMap) tag.get("ExitPortal").getValue();
|
||||||
com.github.steveice10.opennbt.tag.builtin.IntTag intTag = (com.github.steveice10.opennbt.tag.builtin.IntTag) compoundTag.get(axis);
|
com.github.steveice10.opennbt.tag.builtin.IntTag intTag = (com.github.steveice10.opennbt.tag.builtin.IntTag) compoundTag.get(axis);
|
||||||
return intTag.getValue();
|
return intTag.getValue();
|
||||||
|
@ -110,10 +110,18 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||||||
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z));
|
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Object2IntMap.Entry<CompoundTag> blockEntityEntry : chunkData.gateways.object2IntEntrySet()) {
|
||||||
|
int x = blockEntityEntry.getKey().getInt("x");
|
||||||
|
int y = blockEntityEntry.getKey().getInt("y");
|
||||||
|
int z = blockEntityEntry.getKey().getInt("z");
|
||||||
|
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
for (Map.Entry<Position, BlockState> blockEntityEntry: chunkData.beds.entrySet()) {
|
for (Map.Entry<Position, BlockState> blockEntityEntry: chunkData.beds.entrySet()) {
|
||||||
ChunkUtils.updateBlock(session, blockEntityEntry.getValue(), blockEntityEntry.getKey());
|
ChunkUtils.updateBlock(session, blockEntityEntry.getValue(), blockEntityEntry.getKey());
|
||||||
}
|
}
|
||||||
chunkData.signs.clear();
|
chunkData.signs.clear();
|
||||||
|
chunkData.gateways.clear();
|
||||||
chunkData.beds.clear();
|
chunkData.beds.clear();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -78,6 +78,9 @@ public class ChunkUtils {
|
|||||||
if (BlockTranslator.getBlockEntityString(blockState) != null && BlockTranslator.getBlockEntityString(blockState).contains("sign[")) {
|
if (BlockTranslator.getBlockEntityString(blockState) != null && BlockTranslator.getBlockEntityString(blockState).contains("sign[")) {
|
||||||
Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z);
|
Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z);
|
||||||
chunkData.signs.put(Translators.getBlockEntityTranslators().get("Sign").getDefaultBedrockTag("Sign", pos.getX(), pos.getY(), pos.getZ()), blockState.getId());
|
chunkData.signs.put(Translators.getBlockEntityTranslators().get("Sign").getDefaultBedrockTag("Sign", pos.getX(), pos.getY(), pos.getZ()), blockState.getId());
|
||||||
|
} else if (BlockTranslator.getBlockEntityString(blockState) != null && BlockTranslator.getBlockEntityString(blockState).contains("end_gateway")) {
|
||||||
|
Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z);
|
||||||
|
chunkData.gateways.put(Translators.getBlockEntityTranslators().get("EndGateway").getDefaultBedrockTag("EndGateway", pos.getX(), pos.getY(), pos.getZ()), blockState.getId());
|
||||||
} else if (BlockTranslator.getBedColor(blockState) > -1) {
|
} else if (BlockTranslator.getBedColor(blockState) > -1) {
|
||||||
Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z);
|
Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z);
|
||||||
// Beds need to be updated separately to add the bed color tag
|
// Beds need to be updated separately to add the bed color tag
|
||||||
@ -189,6 +192,7 @@ public class ChunkUtils {
|
|||||||
|
|
||||||
public com.nukkitx.nbt.tag.CompoundTag[] blockEntities = new com.nukkitx.nbt.tag.CompoundTag[0];
|
public com.nukkitx.nbt.tag.CompoundTag[] blockEntities = new com.nukkitx.nbt.tag.CompoundTag[0];
|
||||||
public Object2IntMap<com.nukkitx.nbt.tag.CompoundTag> signs = new Object2IntOpenHashMap<>();
|
public Object2IntMap<com.nukkitx.nbt.tag.CompoundTag> signs = new Object2IntOpenHashMap<>();
|
||||||
|
public Object2IntMap<com.nukkitx.nbt.tag.CompoundTag> gateways = new Object2IntOpenHashMap<>();
|
||||||
public Map<Position, BlockState> beds = new HashMap<>();
|
public Map<Position, BlockState> beds = new HashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren