diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 29cb49dc2..b0ea5fdf6 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -71,10 +71,6 @@ dependencies { api(libs.events) } -tasks.test { - enabled = false -} - tasks.processResources { // This is solely for backwards compatibility for other programs that used this file before the switch to gradle. // It used to be generated by the maven Git-Commit-Id-Plugin diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java index 7a443d6e8..2bdbb56df 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/player/PlayerEntity.java @@ -335,7 +335,7 @@ public class PlayerEntity extends LivingEntity implements GeyserPlayerEntity { parrot.updateBedrockMetadata(); SetEntityLinkPacket linkPacket = new SetEntityLinkPacket(); EntityLinkData.Type type = isLeft ? EntityLinkData.Type.RIDER : EntityLinkData.Type.PASSENGER; - linkPacket.setEntityLink(new EntityLinkData(geyserId, parrot.getGeyserId(), type, false, false)); + linkPacket.setEntityLink(new EntityLinkData(geyserId, parrot.getGeyserId(), type, false, false, 0f)); // Delay, or else spawned-in players won't get the link // TODO: Find a better solution. session.scheduleInEventLoop(() -> session.sendUpstreamPacket(linkPacket), 500, TimeUnit.MILLISECONDS); diff --git a/core/src/main/java/org/geysermc/geyser/item/type/Item.java b/core/src/main/java/org/geysermc/geyser/item/type/Item.java index 9b2603284..b12ab4d67 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/Item.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/Item.java @@ -64,11 +64,13 @@ public class Item { protected final Key javaIdentifier; private int javaId = -1; private final int attackDamage; - private final DataComponents baseComponents; // unmodifiable + private DataComponents baseComponents; // unmodifiable public Item(String javaIdentifier, Builder builder) { this.javaIdentifier = MinecraftKey.key(javaIdentifier); - this.baseComponents = builder.components == null ? Registries.DEFAULT_DATA_COMPONENTS.get(javaId) : builder.components; + if (builder.components != null) { + this.baseComponents = builder.components; + } this.attackDamage = builder.attackDamage; } @@ -272,6 +274,9 @@ public class Item { throw new RuntimeException("Item ID has already been set!"); } this.javaId = javaId; + if (this.baseComponents == null) { + this.baseComponents = Registries.DEFAULT_DATA_COMPONENTS.get(javaId); + } } @Override diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion766_748.java b/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion766_748.java index 79265552f..4568d0154 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion766_748.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/Conversion766_748.java @@ -25,19 +25,20 @@ package org.geysermc.geyser.registry.populator; -import io.jsonwebtoken.lang.Collections; import org.cloudburstmc.nbt.NbtMap; -import org.geysermc.geyser.GeyserImpl; +import org.cloudburstmc.nbt.NbtMapBuilder; import org.geysermc.geyser.level.block.Blocks; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class Conversion766_748 { - static List newBlockIds = new ArrayList<>(); - static List bedrockIds = new ArrayList<>(); // TODO temp remove + static List PALE_WOODEN_BLOCKS = new ArrayList<>(); + static List OTHER_NEW_BLOCKS = new ArrayList<>(); + static { - var blocks = Collections.of( + Set.of( Blocks.PALE_OAK_WOOD, Blocks.PALE_OAK_PLANKS, Blocks.PALE_OAK_SAPLING, @@ -45,27 +46,29 @@ public class Conversion766_748 { Blocks.STRIPPED_PALE_OAK_LOG, Blocks.STRIPPED_PALE_OAK_WOOD, Blocks.PALE_OAK_LEAVES, - Blocks.PALE_OAK_SIGN, - Blocks.PALE_OAK_WALL_SIGN, Blocks.PALE_OAK_HANGING_SIGN, - Blocks.PALE_OAK_WALL_HANGING_SIGN, Blocks.PALE_OAK_PRESSURE_PLATE, Blocks.PALE_OAK_TRAPDOOR, - Blocks.POTTED_PALE_OAK_SAPLING, Blocks.PALE_OAK_BUTTON, Blocks.PALE_OAK_STAIRS, Blocks.PALE_OAK_SLAB, Blocks.PALE_OAK_FENCE_GATE, Blocks.PALE_OAK_FENCE, - Blocks.PALE_OAK_DOOR, + Blocks.PALE_OAK_DOOR + ).forEach(block -> PALE_WOODEN_BLOCKS.add(block.javaIdentifier().value())); + + // Some things are of course stupid + PALE_WOODEN_BLOCKS.add("pale_oak_standing_sign"); + PALE_WOODEN_BLOCKS.add("pale_oak_wall_sign"); + PALE_WOODEN_BLOCKS.add("pale_oak_double_slab"); + + Set.of( Blocks.PALE_MOSS_BLOCK, Blocks.PALE_MOSS_CARPET, Blocks.PALE_HANGING_MOSS, Blocks.OPEN_EYEBLOSSOM, Blocks.CLOSED_EYEBLOSSOM, - Blocks.POTTED_OPEN_EYEBLOSSOM, - Blocks.POTTED_CLOSED_EYEBLOSSOM, Blocks.RESIN_CLUMP, Blocks.RESIN_BLOCK, @@ -76,29 +79,50 @@ public class Conversion766_748 { Blocks.CHISELED_RESIN_BRICKS, Blocks.CREAKING_HEART - ); + ).forEach(block -> OTHER_NEW_BLOCKS.add(block.javaIdentifier().value())); - blocks.forEach(block -> newBlockIds.add(block.javaIdentifier().value())); + OTHER_NEW_BLOCKS.add("resin_brick_double_slab"); } static NbtMap remapBlock(NbtMap tag) { - - GeyserImpl.getInstance().getLogger().info(tag.toString()); - - String name = tag.getString("name"); - if (newBlockIds.contains(name)) { - bedrockIds.add(name); - // TODO - return tag.toBuilder() - .putCompound("states", NbtMap.builder().build()) - .putString("name", "minecraft:unknown") - .build(); + String name = tag.getString("name").replace("minecraft:", ""); + if (PALE_WOODEN_BLOCKS.contains(name)) { + return withName(tag, name.replace("pale_oak", "birch")); } - if (name.contains("resin") || name.contains("creaking") || name.contains("pale")) { - throw new RuntimeException("ya missed " + name); + if (OTHER_NEW_BLOCKS.contains(name)) { + return switch (name) { + case "resin_brick_double_slab" -> withName(tag,"red_sandstone_double_slab"); + case "pale_moss_block" -> withName(tag, "moss_block"); + case "pale_moss_carpet" -> withoutStates("moss_carpet"); + case "pale_hanging_moss" -> withoutStates("hanging_roots"); + case "open_eyeblossom" -> withoutStates("oxeye_daisy"); + case "closed_eyeblossom" -> withoutStates("white_tulip"); + case "resin_clump" -> withoutStates("unknown"); + case "resin_block" -> withoutStates("red_sandstone"); + case "resin_bricks" -> withoutStates("cut_red_sandstone"); + case "resin_brick_stairs" -> withName(tag, "red_sandstone_stairs"); + case "resin_brick_slab" -> withName(tag, "red_sandstone_slab"); + case "resin_brick_wall" -> withName(tag, "red_sandstone_wall"); + case "chiseled_resin_bricks" -> withName(tag, "chiseled_red_sandstone"); + case "creaking_heart" -> withoutStates("chiseled_polished_blackstone"); + default -> throw new IllegalStateException("missing replacement for new block! " + name); + }; } return tag; } + + static NbtMap withName(NbtMap tag, String name) { + NbtMapBuilder builder = tag.toBuilder(); + builder.replace("name", "minecraft:" + name); + return builder.build(); + } + + static NbtMap withoutStates(String name) { + NbtMapBuilder tagBuilder = NbtMap.builder(); + tagBuilder.putString("name", "minecraft:" + name); + tagBuilder.putCompound("states", NbtMap.builder().build()); + return tagBuilder.build(); + } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/inventory/MerchantInventoryTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/inventory/MerchantInventoryTranslator.java index c67b3b190..4ac159981 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/inventory/MerchantInventoryTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/inventory/MerchantInventoryTranslator.java @@ -112,7 +112,7 @@ public class MerchantInventoryTranslator extends BaseInventoryTranslator { SetEntityLinkPacket linkPacket = new SetEntityLinkPacket(); EntityLinkData.Type type = EntityLinkData.Type.PASSENGER; - linkPacket.setEntityLink(new EntityLinkData(session.getPlayerEntity().getGeyserId(), geyserId, type, true, false)); + linkPacket.setEntityLink(new EntityLinkData(session.getPlayerEntity().getGeyserId(), geyserId, type, true, false, 0f)); session.sendUpstreamPacket(linkPacket); merchantInventory.setVillager(villager); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockInteractTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockInteractTranslator.java index 2df77ad16..62487b20d 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockInteractTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockInteractTranslator.java @@ -91,7 +91,7 @@ public class BedrockInteractTranslator extends PacketTranslator // If the server doesn't agree with our dismount (sends a packet saying we dismounted), // then remount the player. SetEntityLinkPacket linkPacket = new SetEntityLinkPacket(); - linkPacket.setEntityLink(new EntityLinkData(vehicleBedrockId, session.getPlayerEntity().getGeyserId(), EntityLinkData.Type.PASSENGER, true, false)); + linkPacket.setEntityLink(new EntityLinkData(vehicleBedrockId, session.getPlayerEntity().getGeyserId(), EntityLinkData.Type.PASSENGER, true, false, 0f)); session.sendUpstreamPacket(linkPacket); } }, 1, TimeUnit.SECONDS)); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaSetPassengersTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaSetPassengersTranslator.java index 865ca0464..fe4a13748 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaSetPassengersTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaSetPassengersTranslator.java @@ -70,7 +70,7 @@ public class JavaSetPassengersTranslator extends PacketTranslator