mirror of https://github.com/GeyserMC/Geyser.git
wip
This commit is contained in:
parent
76a5608851
commit
f308bd1104
|
@ -28,6 +28,7 @@ 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 org.cloudburstmc.nbt.NbtMapBuilder;
|
||||
import org.cloudburstmc.nbt.NbtUtils;
|
||||
import org.cloudburstmc.protocol.bedrock.data.structure.StructureMirror;
|
||||
import org.cloudburstmc.protocol.bedrock.data.structure.StructureRotation;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
|
@ -37,6 +38,7 @@ public class StructureBlockBlockEntityTranslator extends BlockEntityTranslator {
|
|||
|
||||
@Override
|
||||
public void translateTag(NbtMapBuilder builder, CompoundTag tag, int blockState) {
|
||||
GeyserImpl.getInstance().getLogger().info(NbtUtils.toString(tag));
|
||||
if (tag.size() < 5) {
|
||||
return; // These values aren't here
|
||||
}
|
||||
|
@ -147,5 +149,6 @@ public class StructureBlockBlockEntityTranslator extends BlockEntityTranslator {
|
|||
builder.putFloat("integrity", getOrDefault(tag.get("integrity"), 0f)); // Is 1.0f by default on Java but 100.0f on Bedrock
|
||||
|
||||
// Java's "showair" is unrepresented
|
||||
GeyserImpl.getInstance().getLogger().error(builder.toString());
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
|||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockEntityType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEntityDataPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
import org.cloudburstmc.nbt.NbtList;
|
||||
import org.cloudburstmc.nbt.NbtMap;
|
||||
|
@ -124,18 +125,17 @@ public class JavaBlockEntityDataTranslator extends PacketTranslator<ClientboundB
|
|||
packet.getPosition().equals(session.getCurrentStructureBlock()) && packet.getNbt() != null && packet.getNbt().size() > 5) {
|
||||
CompoundTag map = packet.getNbt();
|
||||
|
||||
String mode = (String) map.get("mode").getValue();
|
||||
String mode = getOrDefault(map.get("mode"), "");
|
||||
if (!mode.equalsIgnoreCase("LOAD")) {
|
||||
GeyserImpl.getInstance().getLogger().info(mode);
|
||||
return;
|
||||
}
|
||||
|
||||
int x = (int) map.get("sizeX").getValue();
|
||||
int y = (int) map.get("sizeY").getValue();
|
||||
int z = (int) map.get("sizeZ").getValue();
|
||||
int x = getOrDefault(map.get("sizeX"), 0);
|
||||
int y = getOrDefault(map.get("sizeY"), 0);
|
||||
int z = getOrDefault(map.get("sizeZ"), 0);
|
||||
|
||||
StructureTemplateDataResponsePacket responsePacket = new StructureTemplateDataResponsePacket();
|
||||
responsePacket.setName((String) map.get("name").getValue());
|
||||
responsePacket.setName(getOrDefault(map.get("name"), " "));
|
||||
responsePacket.setSave(true);
|
||||
responsePacket.setTag(EMPTY_STRUCTURE_DATA.toBuilder()
|
||||
.putList("size", NbtType.INT, x, y, z)
|
||||
|
@ -147,4 +147,10 @@ public class JavaBlockEntityDataTranslator extends PacketTranslator<ClientboundB
|
|||
session.setCurrentStructureBlock(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected <T> T getOrDefault(Tag tag, T defaultValue) {
|
||||
//noinspection unchecked
|
||||
return (tag != null && tag.getValue() != null) ? (T) tag.getValue() : defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue