Base changes for Java 1.19.4 support

This commit is contained in:
Camotoy 2023-03-10 20:51:51 -05:00
parent 2f23e5cb9c
commit b3f1c64249
10 changed files with 32 additions and 59 deletions

View file

@ -31,10 +31,6 @@ dependencies {
exclude("com.github.GeyserMC", "mcauthlib") exclude("com.github.GeyserMC", "mcauthlib")
} }
api(libs.packetlib) {
exclude("io.netty", "netty-all")
}
implementation(libs.raknet) { implementation(libs.raknet) {
exclude("io.netty", "*"); exclude("io.netty", "*");
} }

View file

@ -486,7 +486,7 @@ public final class EntityDefinitions {
ENDERMAN = EntityDefinition.inherited(EndermanEntity::new, mobEntityBase) ENDERMAN = EntityDefinition.inherited(EndermanEntity::new, mobEntityBase)
.type(EntityType.ENDERMAN) .type(EntityType.ENDERMAN)
.height(2.9f).width(0.6f) .height(2.9f).width(0.6f)
.addTranslator(MetadataType.BLOCK_STATE, EndermanEntity::setCarriedBlock) .addTranslator(MetadataType.OPTIONAL_BLOCK_STATE, EndermanEntity::setCarriedBlock)
.addTranslator(MetadataType.BOOLEAN, EndermanEntity::setScreaming) .addTranslator(MetadataType.BOOLEAN, EndermanEntity::setScreaming)
.addTranslator(MetadataType.BOOLEAN, EndermanEntity::setAngry) .addTranslator(MetadataType.BOOLEAN, EndermanEntity::setAngry)
.build(); .build();

View file

@ -28,6 +28,7 @@ package org.geysermc.geyser.entity.type.living.monster;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.OptionalIntMetadataType; import com.github.steveice10.mc.protocol.data.game.entity.metadata.OptionalIntMetadataType;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.SoundEvent; import com.nukkitx.protocol.bedrock.data.SoundEvent;
import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityData;
@ -45,13 +46,8 @@ public class EndermanEntity extends MonsterEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
} }
public void setCarriedBlock(EntityMetadata<OptionalInt, OptionalIntMetadataType> entityMetadata) { public void setCarriedBlock(IntEntityMetadata entityMetadata) {
int bedrockBlockId; int bedrockBlockId = session.getBlockMappings().getBedrockBlockId(entityMetadata.getPrimitiveValue());;
if (entityMetadata.getValue().isPresent()) {
bedrockBlockId = session.getBlockMappings().getBedrockBlockId(entityMetadata.getValue().getAsInt());
} else {
bedrockBlockId = session.getBlockMappings().getBedrockAirId();
}
dirtyMetadata.put(EntityData.CARRIED_BLOCK, bedrockBlockId); dirtyMetadata.put(EntityData.CARRIED_BLOCK, bedrockBlockId);
} }

View file

@ -25,19 +25,18 @@
package org.geysermc.geyser.level.physics; package org.geysermc.geyser.level.physics;
import com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValue;
import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3i;
import lombok.Getter; import lombok.Getter;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
public enum Direction { public enum Direction {
DOWN(1, Vector3i.from(0, -1, 0), Axis.Y, PistonValue.DOWN), DOWN(1, Vector3i.from(0, -1, 0), Axis.Y, com.github.steveice10.mc.protocol.data.game.entity.object.Direction.DOWN),
UP(0, Vector3i.UNIT_Y, Axis.Y, PistonValue.UP), UP(0, Vector3i.UNIT_Y, Axis.Y, com.github.steveice10.mc.protocol.data.game.entity.object.Direction.UP),
NORTH(3, Vector3i.from(0, 0, -1), Axis.Z, PistonValue.NORTH), NORTH(3, Vector3i.from(0, 0, -1), Axis.Z, com.github.steveice10.mc.protocol.data.game.entity.object.Direction.NORTH),
SOUTH(2, Vector3i.UNIT_Z, Axis.Z, PistonValue.SOUTH), SOUTH(2, Vector3i.UNIT_Z, Axis.Z, com.github.steveice10.mc.protocol.data.game.entity.object.Direction.SOUTH),
WEST(5, Vector3i.from(-1, 0, 0), Axis.X, PistonValue.WEST), WEST(5, Vector3i.from(-1, 0, 0), Axis.X, com.github.steveice10.mc.protocol.data.game.entity.object.Direction.WEST),
EAST(4, Vector3i.UNIT_X, Axis.X, PistonValue.EAST); EAST(4, Vector3i.UNIT_X, Axis.X, com.github.steveice10.mc.protocol.data.game.entity.object.Direction.EAST);
public static final Direction[] VALUES = values(); public static final Direction[] VALUES = values();
@ -46,10 +45,9 @@ public enum Direction {
private final Vector3i unitVector; private final Vector3i unitVector;
@Getter @Getter
private final Axis axis; private final Axis axis;
@Getter private final com.github.steveice10.mc.protocol.data.game.entity.object.Direction pistonValue;
private final PistonValue pistonValue;
Direction(int reversedId, Vector3i unitVector, Axis axis, PistonValue pistonValue) { Direction(int reversedId, Vector3i unitVector, Axis axis, com.github.steveice10.mc.protocol.data.game.entity.object.Direction pistonValue) {
this.reversedId = reversedId; this.reversedId = reversedId;
this.unitVector = unitVector; this.unitVector = unitVector;
this.axis = axis; this.axis = axis;
@ -69,7 +67,7 @@ public enum Direction {
} }
@Nonnull @Nonnull
public static Direction fromPistonValue(PistonValue pistonValue) { public static Direction fromPistonValue(com.github.steveice10.mc.protocol.data.game.entity.object.Direction pistonValue) {
for (Direction direction : VALUES) { for (Direction direction : VALUES) {
if (direction.pistonValue == pistonValue) { if (direction.pistonValue == pistonValue) {
return direction; return direction;

View file

@ -29,9 +29,9 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient; import com.github.steveice10.mc.protocol.data.game.recipe.Ingredient;
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe; import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType; import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
import com.github.steveice10.mc.protocol.data.game.recipe.data.LegacyUpgradeRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.SmithingRecipeData;
import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData; import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket; import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket;
import com.nukkitx.protocol.bedrock.data.inventory.CraftingData; import com.nukkitx.protocol.bedrock.data.inventory.CraftingData;
@ -137,7 +137,7 @@ public class JavaUpdateRecipesTranslator extends PacketTranslator<ClientboundUpd
} }
case SMITHING -> { case SMITHING -> {
// Required to translate these as of 1.18.10, or else they cannot be crafted // Required to translate these as of 1.18.10, or else they cannot be crafted
SmithingRecipeData recipeData = (SmithingRecipeData) recipe.getData(); LegacyUpgradeRecipeData recipeData = (LegacyUpgradeRecipeData) recipe.getData();
ItemData output = ItemTranslator.translateToBedrock(session, recipeData.getResult()); ItemData output = ItemTranslator.translateToBedrock(session, recipeData.getResult());
for (ItemStack base : recipeData.getBase().getOptions()) { for (ItemStack base : recipeData.getBase().getOptions()) {
ItemDescriptorWithCount bedrockBase = ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, base)); ItemDescriptorWithCount bedrockBase = ItemDescriptorWithCount.fromItem(ItemTranslator.translateToBedrock(session, base));

View file

@ -91,6 +91,16 @@ public class JavaSetPassengersTranslator extends PacketTranslator<ClientboundSet
EntityUtils.updateMountOffset(passenger, entity, false, false, (packet.getPassengerIds().length > 1)); EntityUtils.updateMountOffset(passenger, entity, false, false, (packet.getPassengerIds().length > 1));
// Force an update to the passenger metadata // Force an update to the passenger metadata
passenger.updateBedrockMetadata(); passenger.updateBedrockMetadata();
if (passenger == session.getPlayerEntity()) {
//TODO test
if (session.getMountVehicleScheduledFuture() != null) {
// Cancel this task as it is now unnecessary.
// Note that this isn't present in JavaSetPassengersTranslator as that code is not called for players
// as of Java 1.19.3, but the scheduled future checks for the vehicle being null anyway.
session.getMountVehicleScheduledFuture().cancel(false);
}
}
} }
} }

View file

@ -30,20 +30,16 @@ import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket; import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityLinkData;
import com.nukkitx.protocol.bedrock.packet.ChunkRadiusUpdatedPacket; import com.nukkitx.protocol.bedrock.packet.ChunkRadiusUpdatedPacket;
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket; import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
import com.nukkitx.protocol.bedrock.packet.RespawnPacket; import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
import com.nukkitx.protocol.bedrock.packet.SetEntityLinkPacket;
import org.geysermc.geyser.entity.EntityDefinitions; import org.geysermc.geyser.entity.EntityDefinitions;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.player.SessionPlayerEntity; import org.geysermc.geyser.entity.type.player.SessionPlayerEntity;
import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.session.cache.TeleportCache; import org.geysermc.geyser.session.cache.TeleportCache;
import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.PacketTranslator;
import org.geysermc.geyser.translator.protocol.Translator; import org.geysermc.geyser.translator.protocol.Translator;
import org.geysermc.geyser.util.ChunkUtils; import org.geysermc.geyser.util.ChunkUtils;
import org.geysermc.geyser.util.EntityUtils;
@Translator(packet = ClientboundPlayerPositionPacket.class) @Translator(packet = ClientboundPlayerPositionPacket.class)
public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPlayerPositionPacket> { public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPlayerPositionPacket> {
@ -101,27 +97,6 @@ public class JavaPlayerPositionTranslator extends PacketTranslator<ClientboundPl
return; return;
} }
Entity vehicle;
if (packet.isDismountVehicle() && (vehicle = session.getPlayerEntity().getVehicle()) != null) {
SetEntityLinkPacket linkPacket = new SetEntityLinkPacket();
linkPacket.setEntityLink(new EntityLinkData(vehicle.getGeyserId(), entity.getGeyserId(), EntityLinkData.Type.REMOVE, false, false));
session.sendUpstreamPacket(linkPacket);
vehicle.getPassengers().remove(entity);
session.getPlayerEntity().setVehicle(null);
EntityUtils.updateRiderRotationLock(entity, null, false);
EntityUtils.updateMountOffset(entity, null, false, false, entity.getPassengers().size() > 1);
entity.updateBedrockMetadata();
if (session.getMountVehicleScheduledFuture() != null) {
// Cancel this task as it is now unnecessary.
// Note that this isn't present in JavaSetPassengersTranslator as that code is not called for players
// as of Java 1.19.3, but the scheduled future checks for the vehicle being null anyway.
session.getMountVehicleScheduledFuture().cancel(false);
}
}
// If coordinates are relative, then add to the existing coordinate // If coordinates are relative, then add to the existing coordinate
double newX = packet.getX() + double newX = packet.getX() +
(packet.getRelative().contains(PositionElement.X) ? entity.getPosition().getX() : 0); (packet.getRelative().contains(PositionElement.X) ? entity.getPosition().getX() : 0);

View file

@ -57,13 +57,13 @@ public class JavaBlockEventTranslator extends PacketTranslator<ClientboundBlockE
} else if (packet.getValue() instanceof EndGatewayValue) { } else if (packet.getValue() instanceof EndGatewayValue) {
blockEventPacket.setEventType(1); blockEventPacket.setEventType(1);
session.sendUpstreamPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
} else if (packet.getValue() instanceof NoteBlockValue) { // } else if (packet.getValue() instanceof NoteBlockValue) {
int blockState = session.getGeyser().getWorldManager().getBlockAt(session, position); // int blockState = session.getGeyser().getWorldManager().getBlockAt(session, position);
blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState)); // blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState));
session.sendUpstreamPacket(blockEventPacket); // session.sendUpstreamPacket(blockEventPacket);
} else if (packet.getValue() instanceof PistonValue pistonValue) { } else if (packet.getValue() instanceof PistonValue pistonValue) {
PistonValueType action = (PistonValueType) packet.getType(); PistonValueType action = (PistonValueType) packet.getType();
Direction direction = Direction.fromPistonValue(pistonValue); Direction direction = Direction.fromPistonValue(pistonValue.getDirection());
PistonCache pistonCache = session.getPistonCache(); PistonCache pistonCache = session.getPistonCache();
if (session.getGeyser().getPlatformType() == PlatformType.SPIGOT) { if (session.getGeyser().getPlatformType() == PlatformType.SPIGOT) {

View file

@ -157,7 +157,7 @@ public class JavaLevelEventTranslator extends PacketTranslator<ClientboundLevelE
SmokeEventData smokeEventData = (SmokeEventData) packet.getData(); SmokeEventData smokeEventData = (SmokeEventData) packet.getData();
int data = 0; int data = 0;
switch (smokeEventData) { switch (smokeEventData.getDirection()) {
case DOWN -> { case DOWN -> {
data = 4; data = 4;
pos = pos.add(0, -0.9f, 0); pos = pos.add(0, -0.9f, 0);

View file

@ -11,8 +11,7 @@ websocket = "1.5.1"
protocol = "2.9.17-20230217.002312-1" protocol = "2.9.17-20230217.002312-1"
raknet = "1.6.28-20220125.214016-6" raknet = "1.6.28-20220125.214016-6"
mcauthlib = "d9d773e" mcauthlib = "d9d773e"
mcprotocollib = "1.19.3-20230107.194116-10" mcprotocollib = "1.19.4-SNAPSHOT"
packetlib = "3.0.1"
adventure = "4.12.0-20220629.025215-9" adventure = "4.12.0-20220629.025215-9"
adventure-platform = "4.1.2" adventure-platform = "4.1.2"
junit = "5.9.2" junit = "5.9.2"
@ -84,7 +83,6 @@ gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" } junit = { group = "org.junit.jupiter", name = "junit-jupiter", version.ref = "junit" }
mcauthlib = { group = "com.github.GeyserMC", name = "MCAuthLib", version.ref = "mcauthlib" } mcauthlib = { group = "com.github.GeyserMC", name = "MCAuthLib", version.ref = "mcauthlib" }
mcprotocollib = { group = "com.github.steveice10", name = "mcprotocollib", version.ref = "mcprotocollib" } mcprotocollib = { group = "com.github.steveice10", name = "mcprotocollib", version.ref = "mcprotocollib" }
packetlib = { group = "com.github.steveice10", name = "packetlib", version.ref = "packetlib" }
protocol = { group = "com.nukkitx.protocol", name = "bedrock-v567", version.ref = "protocol" } protocol = { group = "com.nukkitx.protocol", name = "bedrock-v567", version.ref = "protocol" }
raknet = { group = "com.nukkitx.network", name = "raknet", version.ref = "raknet" } raknet = { group = "com.nukkitx.network", name = "raknet", version.ref = "raknet" }
sponge-api = { group = "org.spongepowered", name = "spongeapi", version.ref = "sponge" } sponge-api = { group = "org.spongepowered", name = "spongeapi", version.ref = "sponge" }