diff --git a/core/src/main/java/org/geysermc/geyser/entity/vehicle/VehicleComponent.java b/core/src/main/java/org/geysermc/geyser/entity/vehicle/VehicleComponent.java index 91f54162b..61875ec90 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/vehicle/VehicleComponent.java +++ b/core/src/main/java/org/geysermc/geyser/entity/vehicle/VehicleComponent.java @@ -105,6 +105,10 @@ public class VehicleComponent { boundingBox.setMiddleZ(z); } + public void moveAbsolute(Vector3d vec) { + moveAbsolute(vec.getX(), vec.getY(), vec.getZ()); + } + public void moveRelative(double x, double y, double z) { boundingBox.translate(x, y, z); } @@ -756,7 +760,7 @@ public class VehicleComponent { vehicle.getSession().sendUpstreamPacket(moveEntityDeltaPacket); } - ServerboundMoveVehiclePacket moveVehiclePacket = new ServerboundMoveVehiclePacket(javaPos.getX(), javaPos.getY(), javaPos.getZ(), rotation.getX(), rotation.getY()); + ServerboundMoveVehiclePacket moveVehiclePacket = new ServerboundMoveVehiclePacket(javaPos, rotation.getX(), rotation.getY(), vehicle.isOnGround()); vehicle.getSession().sendDownstreamPacket(moveVehiclePacket); } diff --git a/core/src/main/java/org/geysermc/geyser/item/Items.java b/core/src/main/java/org/geysermc/geyser/item/Items.java index 7af5aadce..c7ab076b4 100644 --- a/core/src/main/java/org/geysermc/geyser/item/Items.java +++ b/core/src/main/java/org/geysermc/geyser/item/Items.java @@ -70,6 +70,11 @@ import static org.geysermc.geyser.item.type.Item.builder; */ @SuppressWarnings("unused") public final class Items { + + static { + // Load data components here + } + public static final Item AIR = register(new Item("air", builder())); public static final Item STONE = register(new BlockItem(builder(), Blocks.STONE)); public static final Item GRANITE = register(new BlockItem(builder(), Blocks.GRANITE)); 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 249936e5a..0155c4e35 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 @@ -62,12 +62,16 @@ public class Item { private static final Map BLOCK_TO_ITEM = new HashMap<>(); protected final Key javaIdentifier; private int javaId = -1; + + // TODO remove these private final int stackSize; private final int attackDamage; private final int maxDamage; private final Rarity rarity; private final boolean glint; + private DataComponents dataComponents; + public Item(String javaIdentifier, Builder builder) { this.javaIdentifier = MinecraftKey.key(javaIdentifier); this.stackSize = builder.stackSize; @@ -86,7 +90,7 @@ public class Item { } public int maxDamage() { - return maxDamage; + return dataComponents.getOrDefault(DataComponentType.MAX_DAMAGE, 0); } public int attackDamage() { @@ -94,7 +98,7 @@ public class Item { } public int maxStackSize() { - return stackSize; + return dataComponents.getOrDefault(DataComponentType.MAX_STACK_SIZE, 1); } public Rarity rarity() { @@ -317,16 +321,6 @@ public class Item { return this; } - public Builder rarity(Rarity rarity) { - this.rarity = rarity; - return this; - } - - public Builder glint(boolean glintOverride) { - this.glint = glintOverride; - return this; - } - private Builder() { } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/item/CustomItemTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/item/CustomItemTranslator.java index 91eee3895..b65b06431 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/item/CustomItemTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/item/CustomItemTranslator.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.translator.item; +import org.geysermc.mcprotocollib.protocol.data.game.item.component.CustomModelData; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType; import it.unimi.dsi.fastutil.Pair; @@ -52,7 +53,15 @@ public final class CustomItemTranslator { return null; } - int customModelData = components.getOrDefault(DataComponentType.CUSTOM_MODEL_DATA, 0); + // TODO 1.21.4 + float customModelDataInt = 0; + CustomModelData customModelData = components.get(DataComponentType.CUSTOM_MODEL_DATA); + if (customModelData != null) { + if (!customModelData.floats().isEmpty()) { + customModelDataInt = customModelData.floats().get(0); + } + } + boolean checkDamage = mapping.getJavaItem().maxDamage() > 0; int damage = !checkDamage ? 0 : components.getOrDefault(DataComponentType.DAMAGE, 0); boolean unbreakable = checkDamage && !isDamaged(components, damage); @@ -88,7 +97,7 @@ public final class CustomItemTranslator { } OptionalInt customModelDataOption = options.customModelData(); - if (customModelDataOption.isPresent() && customModelData < customModelDataOption.getAsInt()) { + if (customModelDataOption.isPresent() && customModelDataInt < customModelDataOption.getAsInt()) { continue; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java index 8e2781a98..b57187018 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java @@ -312,8 +312,9 @@ public final class BedrockPlayerAuthInputTranslator extends PacketTranslator { @@ -42,9 +41,9 @@ public class JavaMoveVehicleTranslator extends PacketTranslator