Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Start support for entity type id tracking
Dieser Commit ist enthalten in:
Ursprung
03cc48c991
Commit
73b8a2fc9a
@ -3,10 +3,13 @@ package us.myles.ViaVersion.protocols.protocolsnapshotto1_10;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocolsnapshotto1_10.storage.EntityTracker;
|
||||
|
||||
public class ProtocolSnapshotTo1_10 extends Protocol {
|
||||
@Override
|
||||
@ -18,7 +21,24 @@ public class ProtocolSnapshotTo1_10 extends Protocol {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.UUID); // 1 - Entity UUID
|
||||
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // 2 - Entity Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
map(Type.BYTE); // 8 - Head Pitch
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
map(Types1_9.METADATA_LIST); // 12 - Metadata
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Register Type ID
|
||||
wrapper.user().get(EntityTracker.class).getClientEntityTypes().put(wrapper.get(Type.VAR_INT, 0), wrapper.get(Type.VAR_INT, 1));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -37,10 +57,35 @@ public class ProtocolSnapshotTo1_10 extends Protocol {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Metadata packet
|
||||
registerOutgoing(State.PLAY, 0x39, 0x39, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_9.METADATA_LIST); // 1 - Metadata list
|
||||
}
|
||||
});
|
||||
|
||||
// Destroy entities
|
||||
registerOutgoing(State.PLAY, 0x30, 0x30, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||
wrapper.user().get(EntityTracker.class).removeEntity(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
|
||||
userConnection.put(new EntityTracker(userConnection));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package us.myles.ViaVersion.protocols.protocolsnapshotto1_10.storage;
|
||||
|
||||
import lombok.Getter;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Getter
|
||||
public class EntityTracker extends StoredObject{
|
||||
private final Map<Integer, Integer> clientEntityTypes = new ConcurrentHashMap<>();
|
||||
|
||||
public EntityTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void removeEntity(Integer entityID) {
|
||||
clientEntityTypes.remove(entityID);
|
||||
}
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren