Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
Fix beds and signs
Dieser Commit ist enthalten in:
Ursprung
1de12bcdee
Commit
81c9e4f165
@ -39,6 +39,7 @@ import io.netty.buffer.ByteBufOutputStream;
|
|||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.BiomeTranslator;
|
import org.geysermc.connector.network.translators.BiomeTranslator;
|
||||||
@ -47,6 +48,8 @@ import org.geysermc.connector.network.translators.Translator;
|
|||||||
import org.geysermc.connector.utils.ChunkUtils;
|
import org.geysermc.connector.utils.ChunkUtils;
|
||||||
import org.geysermc.connector.world.chunk.ChunkSection;
|
import org.geysermc.connector.world.chunk.ChunkSection;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@Translator(packet = ServerChunkDataPacket.class)
|
@Translator(packet = ServerChunkDataPacket.class)
|
||||||
public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPacket> {
|
public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPacket> {
|
||||||
|
|
||||||
@ -102,20 +105,15 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
|||||||
session.getUpstream().sendPacket(levelChunkPacket);
|
session.getUpstream().sendPacket(levelChunkPacket);
|
||||||
|
|
||||||
// Signs have to be sent after the chunk since in later versions they aren't included in the block entities
|
// Signs have to be sent after the chunk since in later versions they aren't included in the block entities
|
||||||
for (Int2ObjectMap.Entry<CompoundTag> blockEntityEntry : chunkData.signs.int2ObjectEntrySet()) {
|
for (Object2IntMap.Entry<CompoundTag> blockEntityEntry : chunkData.signs.object2IntEntrySet()) {
|
||||||
int x = blockEntityEntry.getValue().getInt("x");
|
int x = blockEntityEntry.getKey().getInt("x");
|
||||||
int y = blockEntityEntry.getValue().getInt("y");
|
int y = blockEntityEntry.getKey().getInt("y");
|
||||||
int z = blockEntityEntry.getValue().getInt("z");
|
int z = blockEntityEntry.getKey().getInt("z");
|
||||||
|
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntValue()), new Position(x, y, z));
|
||||||
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntKey()), new Position(x, y, z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Int2ObjectMap.Entry<CompoundTag> blockEntityEntry: chunkData.beds.int2ObjectEntrySet()) {
|
for (HashMap.Entry<Position, BlockState> blockEntityEntry: chunkData.beds.entrySet()) {
|
||||||
int x = blockEntityEntry.getValue().getInt("x");
|
ChunkUtils.updateBlock(session, blockEntityEntry.getValue(), blockEntityEntry.getKey());
|
||||||
int y = blockEntityEntry.getValue().getInt("y");
|
|
||||||
int z = blockEntityEntry.getValue().getInt("z");
|
|
||||||
|
|
||||||
ChunkUtils.updateBlock(session, new BlockState(blockEntityEntry.getIntKey()), new Position(x, y, z));
|
|
||||||
}
|
}
|
||||||
chunkData.signs.clear();
|
chunkData.signs.clear();
|
||||||
chunkData.beds.clear();
|
chunkData.beds.clear();
|
||||||
|
@ -39,6 +39,9 @@ import com.nukkitx.protocol.bedrock.packet.UpdateBlockPacket;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||||
|
|
||||||
import org.geysermc.connector.GeyserConnector;
|
import org.geysermc.connector.GeyserConnector;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator;
|
import org.geysermc.connector.network.translators.block.entity.BlockEntityTranslator;
|
||||||
@ -48,6 +51,9 @@ import org.geysermc.connector.network.translators.block.BlockTranslator;
|
|||||||
import org.geysermc.connector.network.translators.block.entity.BedBlockEntityTranslator;
|
import org.geysermc.connector.network.translators.block.entity.BedBlockEntityTranslator;
|
||||||
import org.geysermc.connector.world.chunk.ChunkSection;
|
import org.geysermc.connector.world.chunk.ChunkSection;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.geysermc.connector.network.translators.block.BlockTranslator.BEDROCK_WATER_ID;
|
import static org.geysermc.connector.network.translators.block.BlockTranslator.BEDROCK_WATER_ID;
|
||||||
|
|
||||||
public class ChunkUtils {
|
public class ChunkUtils {
|
||||||
@ -74,10 +80,13 @@ 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(blockState.getId(), Translators.getBlockEntityTranslators().get("Sign").getDefaultBedrockTag("Sign", pos.getX(), pos.getY(), pos.getZ()));
|
System.out.println("Sign! " + pos.toString());
|
||||||
|
chunkData.signs.put(Translators.getBlockEntityTranslators().get("Sign").getDefaultBedrockTag("Sign", 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);
|
||||||
chunkData.beds.put(blockState.getId(), BedBlockEntityTranslator.getBedTag(BlockTranslator.getBedColor(blockState), pos));
|
// Beds need to be updated separately to add the bed color tag
|
||||||
|
// Previously this was done by matching block state but this resulted in only one bed per color+orientation showing
|
||||||
|
chunkData.beds.put(pos, blockState);
|
||||||
} else {
|
} else {
|
||||||
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id);
|
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id);
|
||||||
}
|
}
|
||||||
@ -183,7 +192,7 @@ public class ChunkUtils {
|
|||||||
public ChunkSection[] sections;
|
public ChunkSection[] sections;
|
||||||
|
|
||||||
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 Int2ObjectMap<com.nukkitx.nbt.tag.CompoundTag> signs = new Int2ObjectOpenHashMap<>();
|
public Object2IntMap<com.nukkitx.nbt.tag.CompoundTag> signs = new Object2IntOpenHashMap<>();
|
||||||
public Int2ObjectMap<com.nukkitx.nbt.tag.CompoundTag> beds = new Int2ObjectOpenHashMap<>();
|
public Map<Position, BlockState> beds = new HashMap<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren