mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
* Fixed entity bugs introduced by 6642f1e
* Fixed fishing line not displaying
* Clean extra line and added todo
This commit is contained in:
parent
20bbbee3eb
commit
96a7770c22
6 changed files with 31 additions and 14 deletions
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue