Start on 1.21.4 support

This commit is contained in:
onebeastchris 2024-11-28 02:17:11 +08:00
parent 47b68f8140
commit d53a1a5cc4
11 changed files with 46 additions and 33 deletions

View file

@ -105,6 +105,10 @@ public class VehicleComponent<T extends LivingEntity & ClientVehicle> {
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<T extends LivingEntity & ClientVehicle> {
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);
}

View file

@ -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));

View file

@ -62,12 +62,16 @@ public class Item {
private static final Map<Block, Item> 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() {
}
}

View file

@ -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;
}

View file

@ -312,8 +312,9 @@ public final class BedrockPlayerAuthInputTranslator extends PacketTranslator<Pla
vehicle.setPosition(vehiclePosition);
ServerboundMoveVehiclePacket moveVehiclePacket = new ServerboundMoveVehiclePacket(
vehiclePosition.getX(), vehiclePosition.getY(), vehiclePosition.getZ(),
vehicleRotation.getY() - 90, vehiclePosition.getX() // TODO I wonder if this is related to the horse spinning bugs...
vehiclePosition.toDouble(),
vehicleRotation.getY() - 90, vehiclePosition.getX(), // TODO I wonder if this is related to the horse spinning bugs...
vehicle.isOnGround()
);
session.sendDownstreamGamePacket(moveVehiclePacket);
}

View file

@ -25,13 +25,12 @@
package org.geysermc.geyser.translator.protocol.java.entity;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundMoveVehiclePacket;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.vehicle.ClientVehicle;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundMoveVehiclePacket;
@Translator(packet = ClientboundMoveVehiclePacket.class)
public class JavaMoveVehicleTranslator extends PacketTranslator<ClientboundMoveVehiclePacket> {
@ -42,9 +41,9 @@ public class JavaMoveVehicleTranslator extends PacketTranslator<ClientboundMoveV
if (entity == null) return;
if (entity instanceof ClientVehicle clientVehicle) {
clientVehicle.getVehicleComponent().moveAbsolute(packet.getX(), packet.getY(), packet.getZ());
clientVehicle.getVehicleComponent().moveAbsolute(packet.getPosition());
}
entity.moveAbsolute(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), false, true);
entity.moveAbsolute(packet.getPosition().toFloat(), packet.getYRot(), packet.getXRot(), false, true);
}
}

View file

@ -69,7 +69,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.SlotDis
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.TagSlotDisplay;
import org.geysermc.mcprotocollib.protocol.data.game.recipe.display.slot.WithRemainderSlotDisplay;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundContainerClosePacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPickItemPacket;
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundSetCreativeModeSlotPacket;
import org.jetbrains.annotations.Contract;
@ -305,8 +304,9 @@ public class InventoryUtils {
}
// If this is the item we're looking for
if (geyserItem.getJavaId() == itemStack.getId() && Objects.equals(geyserItem.getComponents(), itemStack.getDataComponents())) { //TODO verify
ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
session.sendDownstreamGamePacket(packetToSend);
//ServerboundPickItemFromBlockPacket packetToSend = new ServerboundPickItemFromBlockPacket(i); // https://wiki.vg/Protocol#Pick_Item
//session.sendDownstreamGamePacket(packetToSend);
// TODO 1.21.4
return;
}
}
@ -368,8 +368,9 @@ public class InventoryUtils {
continue;
}
ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
session.sendDownstreamGamePacket(packetToSend);
// TODO 1.21.4
//ServerboundPickItemPacket packetToSend = new ServerboundPickItemPacket(i); // https://wiki.vg/Protocol#Pick_Item
//session.sendDownstreamGamePacket(packetToSend);
return;
}

View file

@ -154,7 +154,7 @@ public class ScoreboardIssueTests {
new ClientboundPlayerInfoUpdatePacket(
EnumSet.of(PlayerListEntryAction.ADD_PLAYER, PlayerListEntryAction.UPDATE_LISTED),
new PlayerListEntry[] {
new PlayerListEntry(npcUuid, new GameProfile(npcUuid, "1297"), false, 0, GameMode.SURVIVAL, null, 0, null, 0, null, null)
new PlayerListEntry(npcUuid, new GameProfile(npcUuid, "1297"), false, 0, GameMode.SURVIVAL, null, false, 0, null, 0, null, null)
}));
//todo we don't have to remove an entry that was never in the playerlist in the first place

View file

@ -11,5 +11,5 @@ loom.ignoreDependencyLoomVersionValidation=true
group=org.geysermc
id=geyser
version=2.5.0-SNAPSHOT
version=2.6.0-SNAPSHOT
description=Allows for players from Minecraft: Bedrock Edition to join Minecraft: Java Edition servers.

View file

@ -15,7 +15,7 @@ protocol-common = "3.0.0.Beta5-20241022.154658-14"
protocol-codec = "3.0.0.Beta5-20241022.154658-14"
raknet = "1.0.0.CR3-20240416.144209-1"
minecraftauth = "4.1.1"
mcprotocollib = "1.21.2-20241107.110329-3"
mcprotocollib = "1.21.4-SNAPSHOT"
adventure = "4.14.0"
adventure-platform = "4.3.0"
junit = "5.9.2"
@ -34,12 +34,12 @@ bungeecord = "a7c6ede"
velocity = "3.3.0-SNAPSHOT"
viaproxy = "3.3.2-SNAPSHOT"
fabric-loader = "0.16.7"
fabric-api = "0.106.1+1.21.3"
fabric-api = "0.109.1+1.21.4"
fabric-permissions-api = "0.3.3"
neoforge-minecraft = "21.3.0-beta"
mixin = "0.8.5"
mixinextras = "0.3.5"
minecraft = "1.21.3"
minecraft = "1.21.4-pre3"
mockito = "5.+"
# plugin versions

View file

@ -20,7 +20,7 @@ include(":ap")
include(":api")
include(":bungeecord")
include(":fabric")
include(":neoforge")
//include(":neoforge")
include(":mod")
include(":spigot")
include(":standalone")
@ -32,7 +32,7 @@ include(":core")
// Specify project dirs
project(":bungeecord").projectDir = file("bootstrap/bungeecord")
project(":fabric").projectDir = file("bootstrap/mod/fabric")
project(":neoforge").projectDir = file("bootstrap/mod/neoforge")
//project(":neoforge").projectDir = file("bootstrap/mod/neoforge")
project(":mod").projectDir = file("bootstrap/mod")
project(":spigot").projectDir = file("bootstrap/spigot")
project(":standalone").projectDir = file("bootstrap/standalone")