3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00
* Fix signs on everything except Paper

* Fix sign line placement

* Update shulker box block entity

Co-authored-by: James Harrison <james@fasttortoise.co.uk>
Dieser Commit ist enthalten in:
Camotoy 2020-05-06 17:52:57 -04:00 committet von GitHub
Ursprung 5ae95433e5
Commit f11bae0bf0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
11 geänderte Dateien mit 95 neuen und 115 gelöschten Zeilen

Datei anzeigen

@ -30,19 +30,13 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdate
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.network.translators.world.block.entity.BlockEntity;
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
import org.geysermc.connector.utils.BlockEntityUtils;
import org.geysermc.connector.utils.ChunkUtils;
import java.util.concurrent.TimeUnit;
@Translator(packet = ServerUpdateTileEntityPacket.class)
public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdateTileEntityPacket> {
// This should be modified if sign text is not showing up
private static final int DELAY = 500;
@Override
public void translate(ServerUpdateTileEntityPacket packet, GeyserSession session) {
String id = BlockEntityUtils.getBedrockBlockEntityId(packet.getType().name());
@ -52,11 +46,6 @@ public class JavaUpdateTileEntityTranslator extends PacketTranslator<ServerUpdat
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(),
ChunkUtils.CACHED_BLOCK_ENTITIES.get(packet.getPosition())), packet.getPosition());
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(packet.getPosition());
} else if (translator.getClass().getAnnotation(BlockEntity.class).delay()) {
// Delay so chunks can finish sending
session.getConnector().getGeneralThreadPool().schedule(() ->
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), null), packet.getPosition()),
DELAY, TimeUnit.MILLISECONDS);
} else {
BlockEntityUtils.updateBlockEntity(session, translator.getBlockEntityTag(id, packet.getNbt(), null), packet.getPosition());
}

Datei anzeigen

@ -37,7 +37,7 @@ import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList;
import java.util.List;
@BlockEntity(name = "Banner", delay = false, regex = "banner")
@BlockEntity(name = "Banner", regex = "banner")
public class BannerBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override

Datei anzeigen

@ -35,7 +35,7 @@ import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList;
import java.util.List;
@BlockEntity(name = "Bed", delay = false, regex = "bed")
@BlockEntity(name = "Bed", regex = "bed")
public class BedBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override

Datei anzeigen

@ -31,12 +31,6 @@ import java.lang.annotation.RetentionPolicy;
@Retention(value = RetentionPolicy.RUNTIME)
public @interface BlockEntity {
/**
* Whether to delay the sending of the block entity
* @return the delay for when sending the block entity
*/
boolean delay();
/**
* The block entity name
* @return the name of the block entity

Datei anzeigen

@ -38,7 +38,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@BlockEntity(name = "Campfire", delay = false, regex = "campfire")
@BlockEntity(name = "Campfire", regex = "campfire")
public class CampfireBlockEntityTranslator extends BlockEntityTranslator {
@Override

Datei anzeigen

@ -32,7 +32,7 @@ import com.nukkitx.nbt.tag.Tag;
import java.util.ArrayList;
import java.util.List;
@BlockEntity(name = "Empty", delay = false, regex = "")
@BlockEntity(name = "Empty", regex = "")
public class EmptyBlockEntityTranslator extends BlockEntityTranslator {
@Override

Datei anzeigen

@ -36,7 +36,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@BlockEntity(name = "EndGateway", delay = true, regex = "end_gateway")
@BlockEntity(name = "EndGateway", regex = "end_gateway")
public class EndGatewayBlockEntityTranslator extends BlockEntityTranslator {
@Override

Datei anzeigen

@ -36,7 +36,7 @@ import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList;
import java.util.List;
@BlockEntity(name = "ShulkerBox", delay = false, regex = "shulker_box")
@BlockEntity(name = "ShulkerBox", regex = "shulker_box")
public class ShulkerBoxBlockEntityTranslator extends BlockEntityTranslator {
@Override

Datei anzeigen

@ -31,29 +31,35 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.nukkitx.nbt.CompoundTagBuilder;
import com.nukkitx.nbt.tag.StringTag;
import com.nukkitx.nbt.tag.Tag;
import io.netty.util.internal.StringUtil;
import org.geysermc.connector.utils.MessageUtils;
import java.util.ArrayList;
import java.util.List;
@BlockEntity(name = "Sign", delay = true, regex = "sign")
@BlockEntity(name = "Sign", regex = "sign")
public class SignBlockEntityTranslator extends BlockEntityTranslator {
@Override
public List<Tag<?>> translateTag(CompoundTag tag, BlockState blockState) {
List<Tag<?>> tags = new ArrayList<>();
String line1 = getOrDefault(tag.getValue().get("Text1"), "");
String line2 = getOrDefault(tag.getValue().get("Text2"), "");
String line3 = getOrDefault(tag.getValue().get("Text3"), "");
String line4 = getOrDefault(tag.getValue().get("Text4"), "");
StringBuilder signText = new StringBuilder();
for(int i = 0; i < 4; i++) {
int currentLine = i+1;
String signLine = getOrDefault(tag.getValue().get("Text" + currentLine), "");
signLine = MessageUtils.getBedrockMessage(Message.fromString(signLine));
tags.add(new StringTag("Text", MessageUtils.getBedrockMessage(Message.fromString(line1))
+ "\n" + MessageUtils.getBedrockMessage(Message.fromString(line2))
+ "\n" + MessageUtils.getBedrockMessage(Message.fromString(line3))
+ "\n" + MessageUtils.getBedrockMessage(Message.fromString(line4))
));
//Java allows up to 16+ characters on certain symbols.
if(signLine.length() >= 15 && (signLine.contains("-") || signLine.contains("="))) {
signLine = signLine.substring(0, 14);
}
signText.append(signLine);
signText.append("\n");
}
tags.add(new StringTag("Text", MessageUtils.getBedrockMessage(Message.fromString(signText.toString()))));
return tags;
}

Datei anzeigen

@ -36,7 +36,7 @@ import org.geysermc.connector.network.translators.world.block.BlockStateValues;
import java.util.ArrayList;
import java.util.List;
@BlockEntity(name = "Skull", delay = false, regex = "skull")
@BlockEntity(name = "Skull", regex = "skull")
public class SkullBlockEntityTranslator extends BlockEntityTranslator implements RequiresBlockState {
@Override

Datei anzeigen

@ -89,21 +89,12 @@ public class ChunkUtils {
// Check to see if the name is in BlockTranslator.getBlockEntityString, and therefore must be handled differently
if (BlockTranslator.getBlockEntityString(blockState) != null) {
// Get the block entity translator
BlockEntityTranslator blockEntityTranslator = BlockEntityUtils.getBlockEntityTranslator(BlockTranslator.getBlockEntityString(blockState));
Position pos = new ChunkPosition(column.getX(), column.getZ()).getBlock(x, (chunkY << 4) + y, z);
blockEntityPositions.put(pos, blockState);
// If there is a delay required for the block, allow it.
if (blockEntityTranslator.getClass().getAnnotation(BlockEntity.class).delay()) {
chunkData.loadBlockEntitiesLater.put(blockEntityTranslator.getDefaultBedrockTag(BlockEntityUtils.getBedrockBlockEntityId(BlockTranslator.getBlockEntityString(blockState)),
pos.getX(), pos.getY(), pos.getZ()), blockState.getId());
} else {
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id);
}
} else {
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id);
}
section.getBlockStorageArray()[0].setFullBlock(ChunkSection.blockPosition(x, y, z), id);
// Check if block is piston or flower - only block entities in Bedrock
if (BlockStateValues.getFlowerPotValues().containsKey(blockState.getId()) ||
BlockStateValues.getPistonValues().containsKey(blockState.getId())) {