Skip to content

Commit

Permalink
add initial camel support
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Jan 25, 2024
1 parent 60cc4d7 commit 6d134a6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ac.grim.grimac.utils.data.packetentity;

import ac.grim.grimac.player.GrimPlayer;
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;

public class PacketEntityCamel extends PacketEntityHorse {

public boolean dashing = false; //TODO: handle camel dashing

public PacketEntityCamel(GrimPlayer player, EntityType type, double x, double y, double z, float xRot) {
super(player, type, x, y, z, xRot);

jumpStrength = 0.42F;
movementSpeedAttribute = 0.09f;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ public void addEntity(int entityID, EntityType entityType, Vector3d position, fl

PacketEntity packetEntity;

if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.ABSTRACT_HORSE)) {
if (EntityTypes.CAMEL.equals(entityType)) {
packetEntity = new PacketEntityCamel(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (EntityTypes.isTypeInstanceOf(entityType, EntityTypes.ABSTRACT_HORSE)) {
packetEntity = new PacketEntityHorse(player, entityType, position.getX(), position.getY(), position.getZ(), xRot);
} else if (entityType == EntityTypes.SLIME || entityType == EntityTypes.MAGMA_CUBE || entityType == EntityTypes.PHANTOM) {
packetEntity = new PacketEntitySizeable(player, entityType, position.getX(), position.getY(), position.getZ());
Expand Down Expand Up @@ -388,6 +390,18 @@ public void updateEntityMetadata(int entityID, List<EntityData> watchableObjects
((PacketEntityHorse) entity).hasSaddle = (info & 0x04) != 0;
((PacketEntityHorse) entity).isRearing = (info & 0x20) != 0;
}

// track camel dashing
if (PacketEvents.getAPI().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_20)) {
if (entity instanceof PacketEntityCamel) {
PacketEntityCamel camel = (PacketEntityCamel) entity;
EntityData entityData = WatchableIndexUtil.getIndex(watchableObjects, 18);
if (entityData != null) {
camel.dashing = (boolean) entityData.getValue();
}
}
}

} else {
EntityData horseByte = WatchableIndexUtil.getIndex(watchableObjects, 16);
if (horseByte != null) {
Expand Down

0 comments on commit 6d134a6

Please sign in to comment.