3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Fixed entity bugs introduced by 6642f1e and added fishing lines (#483)

* Fixed entity bugs introduced by 6642f1e

* Fixed fishing line not displaying

* Clean extra line and added todo
Dieser Commit ist enthalten in:
rtm516 2020-05-05 16:48:01 +01:00 committet von GitHub
Ursprung 20bbbee3eb
Commit 96a7770c22
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 31 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -31,7 +31,6 @@ import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.math.vector.Vector3i; import com.nukkitx.math.vector.Vector3i;
import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityData;
import com.nukkitx.protocol.bedrock.data.EntityFlag; import com.nukkitx.protocol.bedrock.data.EntityFlag;
import com.nukkitx.protocol.bedrock.packet.AddEntityPacket;
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;

Datei anzeigen

@ -27,13 +27,9 @@ package org.geysermc.connector.entity;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityData;
import com.nukkitx.protocol.bedrock.packet.SetEntityMotionPacket;
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;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public class ExpOrbEntity extends Entity { public class ExpOrbEntity extends Entity {
private int amount; private int amount;

Datei anzeigen

@ -25,13 +25,23 @@
package org.geysermc.connector.entity; package org.geysermc.connector.entity;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ProjectileData;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.AddEntityPacket; import com.nukkitx.protocol.bedrock.data.EntityData;
import org.geysermc.connector.GeyserConnector;
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 FishingHookEntity extends Entity { public class FishingHookEntity extends Entity {
public FishingHookEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { public FishingHookEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation, ProjectileData data) {
super(entityId, geyserId, entityType, position, motion, rotation); super(entityId, geyserId, entityType, position, motion, rotation);
// TODO: Find a better way to do this
for (GeyserSession session : GeyserConnector.getInstance().getPlayers().values()) {
if (session.getPlayerEntity().getEntityId() == data.getOwnerId()) {
this.metadata.put(EntityData.OWNER_EID, session.getPlayerEntity().getGeyserId());
return;
}
}
} }
} }

Datei anzeigen

@ -28,7 +28,6 @@ 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.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData; import com.nukkitx.protocol.bedrock.data.EntityData;
import com.nukkitx.protocol.bedrock.packet.AddEntityPacket;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import org.geysermc.connector.entity.living.AbstractFishEntity; import org.geysermc.connector.entity.living.AbstractFishEntity;

Datei anzeigen

@ -26,11 +26,19 @@
package org.geysermc.connector.entity.living.animal.horse; package org.geysermc.connector.entity.living.animal.horse;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.EntityData;
import org.geysermc.connector.entity.type.EntityType; import org.geysermc.connector.entity.type.EntityType;
import org.geysermc.connector.network.session.GeyserSession;
public class TraderLlamaEntity extends LlamaEntity { public class TraderLlamaEntity extends LlamaEntity {
public TraderLlamaEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) { public TraderLlamaEntity(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);
} }
@Override
public void spawnEntity(GeyserSession session) {
this.metadata.put(EntityData.MARK_VARIANT, 1);
super.spawnEntity(session);
}
} }

Datei anzeigen

@ -25,13 +25,15 @@
package org.geysermc.connector.network.translators.java.entity.spawn; package org.geysermc.connector.network.translators.java.entity.spawn;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.FallingBlockData; import com.github.steveice10.mc.protocol.data.game.entity.type.object.FallingBlockData;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection; import com.github.steveice10.mc.protocol.data.game.entity.type.object.HangingDirection;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ProjectileData;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket;
import com.nukkitx.math.vector.Vector3f;
import org.geysermc.connector.entity.Entity; import org.geysermc.connector.entity.Entity;
import org.geysermc.connector.entity.FallingBlockEntity; import org.geysermc.connector.entity.FallingBlockEntity;
import org.geysermc.connector.entity.FishingHookEntity;
import org.geysermc.connector.entity.ItemFrameEntity; import org.geysermc.connector.entity.ItemFrameEntity;
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;
@ -39,9 +41,8 @@ import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator; import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.utils.EntityUtils; import org.geysermc.connector.utils.EntityUtils;
import com.github.steveice10.mc.protocol.data.game.entity.type.object.ObjectType; import java.lang.reflect.Constructor;
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket; import java.lang.reflect.InvocationTargetException;
import com.nukkitx.math.vector.Vector3f;
@Translator(packet = ServerSpawnObjectPacket.class) @Translator(packet = ServerSpawnObjectPacket.class)
public class JavaSpawnObjectTranslator extends PacketTranslator<ServerSpawnObjectPacket> { public class JavaSpawnObjectTranslator extends PacketTranslator<ServerSpawnObjectPacket> {
@ -69,6 +70,10 @@ public class JavaSpawnObjectTranslator extends PacketTranslator<ServerSpawnObjec
// Item frames need the hanging direction // Item frames need the hanging direction
entity = new ItemFrameEntity(packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(), entity = new ItemFrameEntity(packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
type, position, motion, rotation, (HangingDirection) packet.getData()); type, position, motion, rotation, (HangingDirection) packet.getData());
} else if (packet.getType() == ObjectType.FISHING_BOBBER) {
// Fishing bobbers need the owner for the line
entity = new FishingHookEntity(packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
type, position, motion, rotation, (ProjectileData) packet.getData());
} else { } else {
Constructor<? extends Entity> entityConstructor = entityClass.getConstructor(long.class, long.class, EntityType.class, Constructor<? extends Entity> entityConstructor = entityClass.getConstructor(long.class, long.class, EntityType.class,
Vector3f.class, Vector3f.class, Vector3f.class); Vector3f.class, Vector3f.class, Vector3f.class);