Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-10-08 19:00:13 +02:00
Set entity dimensions for goat long jumping
Dieser Commit ist enthalten in:
Ursprung
c2be67bc3d
Commit
249f04441d
@ -303,31 +303,7 @@ public class Entity {
|
|||||||
metadata.getFlags().setFlag(EntityFlag.SLEEPING, pose.equals(Pose.SLEEPING));
|
metadata.getFlags().setFlag(EntityFlag.SLEEPING, pose.equals(Pose.SLEEPING));
|
||||||
// Triggered when crawling
|
// Triggered when crawling
|
||||||
metadata.getFlags().setFlag(EntityFlag.SWIMMING, pose.equals(Pose.SWIMMING));
|
metadata.getFlags().setFlag(EntityFlag.SWIMMING, pose.equals(Pose.SWIMMING));
|
||||||
float width = entityType.getWidth();
|
setDimensions(pose);
|
||||||
float height = entityType.getHeight();
|
|
||||||
switch (pose) {
|
|
||||||
case SLEEPING:
|
|
||||||
if (this instanceof LivingEntity) {
|
|
||||||
width = 0.2f;
|
|
||||||
height = 0.2f;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SNEAKING:
|
|
||||||
if (entityType == EntityType.PLAYER) {
|
|
||||||
height = 1.5f;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FALL_FLYING:
|
|
||||||
case SPIN_ATTACK:
|
|
||||||
case SWIMMING:
|
|
||||||
if (entityType == EntityType.PLAYER) {
|
|
||||||
// Seems like this is only cared about for players; nothing else
|
|
||||||
height = 0.6f;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_WIDTH, width);
|
|
||||||
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, height);
|
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
//TODO check
|
//TODO check
|
||||||
@ -349,6 +325,15 @@ public class Entity {
|
|||||||
session.sendUpstreamPacket(entityDataPacket);
|
session.sendUpstreamPacket(entityDataPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the height and width of the entity's bounding box
|
||||||
|
*/
|
||||||
|
protected void setDimensions(Pose pose) {
|
||||||
|
// No flexibility options for basic entities
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth());
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, entityType.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* x = Pitch, y = HeadYaw, z = Yaw
|
* x = Pitch, y = HeadYaw, z = Yaw
|
||||||
*
|
*
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package org.geysermc.connector.entity;
|
package org.geysermc.connector.entity;
|
||||||
|
|
||||||
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.Pose;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
@ -111,6 +112,16 @@ public class LivingEntity extends Entity {
|
|||||||
super.updateBedrockMetadata(entityMetadata, session);
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setDimensions(Pose pose) {
|
||||||
|
if (pose == Pose.SLEEPING) {
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, 0.2f);
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, 0.2f);
|
||||||
|
} else {
|
||||||
|
super.setDimensions(pose);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateAllEquipment(GeyserSession session) {
|
public void updateAllEquipment(GeyserSession session) {
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
|
@ -26,11 +26,16 @@
|
|||||||
package org.geysermc.connector.entity.living.animal;
|
package org.geysermc.connector.entity.living.animal;
|
||||||
|
|
||||||
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.Pose;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
|
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||||
import org.geysermc.connector.entity.type.EntityType;
|
import org.geysermc.connector.entity.type.EntityType;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
|
||||||
public class GoatEntity extends AnimalEntity {
|
public class GoatEntity extends AnimalEntity {
|
||||||
|
private static final float LONG_JUMPING_HEIGHT = 1.3f * 0.7f;
|
||||||
|
private static final float LONG_JUMPING_WIDTH = 0.9f * 0.7f;
|
||||||
|
|
||||||
public GoatEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
public GoatEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||||
}
|
}
|
||||||
@ -39,6 +44,15 @@ public class GoatEntity extends AnimalEntity {
|
|||||||
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
||||||
super.updateBedrockMetadata(entityMetadata, session);
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setDimensions(Pose pose) {
|
||||||
|
if (pose == Pose.LONG_JUMPING) {
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, LONG_JUMPING_WIDTH);
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, LONG_JUMPING_HEIGHT);
|
||||||
|
} else {
|
||||||
|
super.setDimensions(pose);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ package org.geysermc.connector.entity.player;
|
|||||||
|
|
||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
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.Pose;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.nukkitx.math.vector.Vector3i;
|
import com.nukkitx.math.vector.Vector3i;
|
||||||
@ -334,6 +335,26 @@ public class PlayerEntity extends LivingEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setDimensions(Pose pose) {
|
||||||
|
float height;
|
||||||
|
switch (pose) {
|
||||||
|
case SNEAKING:
|
||||||
|
height = 1.5f;
|
||||||
|
break;
|
||||||
|
case FALL_FLYING:
|
||||||
|
case SPIN_ATTACK:
|
||||||
|
case SWIMMING:
|
||||||
|
height = 0.6f;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
super.setDimensions(pose);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_WIDTH, entityType.getWidth());
|
||||||
|
metadata.put(EntityData.BOUNDING_BOX_HEIGHT, height);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateBedrockAttributes(GeyserSession session) { // TODO: Don't use duplicated code
|
public void updateBedrockAttributes(GeyserSession session) { // TODO: Don't use duplicated code
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren