3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 22:40:18 +01:00

Fix custom blocks in 1.19.50

Dieser Commit ist enthalten in:
Joshua Castle 2022-12-20 22:22:09 -08:00
Ursprung f2d4176054
Commit 3257f3cef3
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: F674F38216C35D5D
4 geänderte Dateien mit 14 neuen und 44 gelöschten Zeilen

Datei anzeigen

@ -28,7 +28,7 @@ package org.geysermc.geyser.api.event.lifecycle;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.block.custom.CustomBlockData;
import org.geysermc.geyser.api.block.custom.CustomBlockState;
import org.geysermc.geyser.api.event.Event;
import org.geysermc.event.Event;
public abstract class GeyserDefineCustomBlocksEvent implements Event {

Datei anzeigen

@ -144,7 +144,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
header.getUuid().toString(), header.getVersionString(), resourcePack.getFile().length(),
resourcePack.getContentKey(), "", header.getUuid().toString(), false, false));
}
resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks() || GeyserImpl.getInstance().getConfig().isAddCustomSkullBlocks());
resourcePacksInfo.setForcedToAccept(GeyserImpl.getInstance().getConfig().isForceResourcePacks());
session.sendUpstreamPacket(resourcePacksInfo);
GeyserLocale.loadGeyserLocale(session.locale());

Datei anzeigen

@ -30,7 +30,6 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
import com.google.common.collect.ImmutableMap;
import com.nukkitx.nbt.*;
import com.nukkitx.protocol.bedrock.data.BlockPropertyData;
import com.nukkitx.protocol.bedrock.v527.Bedrock_v527;
import com.nukkitx.protocol.bedrock.v544.Bedrock_v544;
import com.nukkitx.protocol.bedrock.v560.Bedrock_v560;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -180,7 +179,12 @@ public final class BlockRegistryPopulator {
NbtMap propertyTag = NbtMap.builder()
.putCompound("components", convertComponents(customBlock.components(), protocolVersion))
.putInt("molangVersion", 0)
.putCompound("menu_category", NbtMap.builder()
.putString("category", "none")
.putString("group", "")
.putBoolean("is_hidden_in_commands", false)
.build())
.putInt("molangVersion", 1)
.putList("permutations", NbtType.COMPOUND, permutations)
.putList("properties", NbtType.COMPOUND, properties)
.build();
@ -199,7 +203,7 @@ public final class BlockRegistryPopulator {
NbtList<NbtMap> blocksTag;
List<NbtMap> blockStates;
try (InputStream stream = GeyserImpl.getInstance().getBootstrap().getResource(String.format("bedrock/block_palette.%s.nbt", palette.getKey().key()));
NBTInputStream nbtInputStream = new NBTInputStream(new DataInputStream(new GZIPInputStream(stream)), true, true)) {
NBTInputStream nbtInputStream = new NBTInputStream(new DataInputStream(new GZIPInputStream(stream)), true, true)) {
NbtMap blockPalette = (NbtMap) nbtInputStream.readTag();
blocksTag = (NbtList<NbtMap>) blockPalette.getList("blocks", NbtType.COMPOUND);
blockStates = new ArrayList<>(blocksTag);
@ -366,14 +370,10 @@ public final class BlockRegistryPopulator {
}
NbtMapBuilder builder = NbtMap.builder();
if (components.selectionBox() != null) {
builder.putCompound("minecraft:aim_collision", convertBox(components.selectionBox()));
builder.putCompound("minecraft:selection_box", convertBox(components.selectionBox()));
}
if (components.collisionBox() != null) {
String tagName = "minecraft:block_collision";
if (protocolVersion >= Bedrock_v534.V534_CODEC.getProtocolVersion()) {
tagName = "minecraft:collision_box";
}
builder.putCompound(tagName, convertBox(components.collisionBox()));
builder.putCompound("minecraft:collision_box", convertBox(components.collisionBox()));
}
if (components.geometry() != null) {
builder.putCompound("minecraft:geometry", NbtMap.builder()
@ -397,7 +397,7 @@ public final class BlockRegistryPopulator {
.build());
}
if (components.destroyTime() != null) {
builder.putCompound("minecraft:destroy_time", NbtMap.builder()
builder.putCompound("minecraft:destructible_by_mining", NbtMap.builder()
.putFloat("value", components.destroyTime())
.build());
}
@ -407,8 +407,8 @@ public final class BlockRegistryPopulator {
.build());
}
if (components.lightEmission() != null) {
builder.putCompound("minecraft:block_light_emission", NbtMap.builder()
.putFloat("value", ((float) components.lightEmission()) / 15f)
builder.putCompound("minecraft:light_emission", NbtMap.builder()
.putInt("value", components.lightEmission())
.build());
}
if (components.lightDampening() != null) {

Datei anzeigen

@ -560,34 +560,4 @@ public abstract class ItemTranslator {
}
}
private static CustomSkull getCustomSkull(GeyserSession session, CompoundTag nbt) {
if (nbt != null && nbt.contains("SkullOwner")) {
if (!(nbt.get("SkullOwner") instanceof CompoundTag skullOwner)) {
// It's a username give up d:
return null;
}
SkinManager.GameProfileData data = SkinManager.GameProfileData.from(skullOwner);
if (data == null) {
session.getGeyser().getLogger().debug("Not sure how to handle skull head item display. " + nbt);
return null;
}
String skinHash = data.skinUrl().substring(data.skinUrl().lastIndexOf('/') + 1);
return BlockRegistries.CUSTOM_SKULLS.get(skinHash);
}
return null;
}
private static void translatePlayerHead(GeyserSession session, CompoundTag nbt, ItemData.Builder builder) {
CustomSkull customSkull = getCustomSkull(session, nbt);
if (customSkull != null) {
CustomBlockData customBlockData = customSkull.getCustomBlockData();
int itemId = session.getItemMappings().getCustomBlockItemIds().getInt(customBlockData);
int blockRuntimeId = session.getBlockMappings().getCustomBlockStateIds().getInt(customBlockData.defaultBlockState());
builder.id(itemId);
builder.blockRuntimeId(blockRuntimeId);
}
}
}