2021-03-22 23:06:40 +01:00
|
|
|
/*
|
|
|
|
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
2023-01-12 12:45:53 +01:00
|
|
|
* Copyright (C) 2016-2023 ViaVersion and contributors
|
2021-03-22 23:06:40 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-04-26 20:52:34 +02:00
|
|
|
package com.viaversion.viaversion.protocols.protocol1_9to1_8.packets;
|
2016-03-12 00:07:13 +01:00
|
|
|
|
2021-04-26 20:52:34 +02:00
|
|
|
import com.viaversion.viaversion.api.Via;
|
2022-01-03 18:41:07 +01:00
|
|
|
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
2021-04-26 21:16:10 +02:00
|
|
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types;
|
2021-06-04 12:15:14 +02:00
|
|
|
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
2021-04-26 20:52:34 +02:00
|
|
|
import com.viaversion.viaversion.api.minecraft.item.Item;
|
|
|
|
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
|
|
|
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9;
|
2021-04-27 13:41:39 +02:00
|
|
|
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
2021-04-26 21:16:10 +02:00
|
|
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
2023-02-12 10:54:47 +01:00
|
|
|
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
2021-04-26 21:16:10 +02:00
|
|
|
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
2021-04-26 20:52:34 +02:00
|
|
|
import com.viaversion.viaversion.api.type.Type;
|
|
|
|
import com.viaversion.viaversion.api.type.types.version.Types1_8;
|
|
|
|
import com.viaversion.viaversion.api.type.types.version.Types1_9;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
2021-07-31 12:43:07 +02:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
2021-04-26 20:52:34 +02:00
|
|
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetadataRewriter1_9To1_8;
|
|
|
|
import com.viaversion.viaversion.protocols.protocol1_9to1_8.storage.EntityTracker1_9;
|
2016-03-12 00:07:13 +01:00
|
|
|
|
2016-04-02 15:46:30 +02:00
|
|
|
import java.util.ArrayList;
|
2016-03-15 01:34:20 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2016-03-12 00:07:13 +01:00
|
|
|
public class SpawnPackets {
|
2016-09-27 18:31:10 +02:00
|
|
|
public static final ValueTransformer<Integer, Double> toNewDouble = new ValueTransformer<Integer, Double>(Type.DOUBLE) {
|
2016-03-12 23:33:43 +01:00
|
|
|
@Override
|
|
|
|
public Double transform(PacketWrapper wrapper, Integer inputValue) {
|
|
|
|
return inputValue / 32D;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-06-05 20:30:09 +02:00
|
|
|
public static void register(Protocol1_9To1_8 protocol) {
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_ENTITY, new PacketHandlers() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.VAR_INT); // 0 - Entity ID
|
2016-03-13 14:40:53 +01:00
|
|
|
|
2021-06-02 22:00:20 +02:00
|
|
|
handler(new PacketHandler() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2021-06-02 22:00:20 +02:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-12 00:07:13 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2016-03-13 14:40:53 +01:00
|
|
|
wrapper.write(Type.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
map(Type.BYTE); // 2 - Type
|
|
|
|
|
2016-03-13 14:40:53 +01:00
|
|
|
// Parse this info
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
2016-03-22 20:37:15 +01:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-13 14:40:53 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
|
|
|
int typeID = wrapper.get(Type.BYTE, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-05-08 12:14:41 +02:00
|
|
|
tracker.addEntity(entityID, Entity1_10Types.getTypeFromId(typeID, true));
|
2016-05-27 02:00:01 +02:00
|
|
|
tracker.sendMetadataBuffer(entityID);
|
2016-03-13 14:40:53 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-12 23:33:43 +01:00
|
|
|
map(Type.INT, toNewDouble); // 3 - X - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divide by 32
|
2016-03-12 00:07:13 +01:00
|
|
|
|
|
|
|
map(Type.BYTE); // 6 - Pitch
|
|
|
|
map(Type.BYTE); // 7 - Yaw
|
|
|
|
|
|
|
|
map(Type.INT); // 8 - Data
|
|
|
|
|
|
|
|
// Create last 3 shorts
|
2021-06-02 22:00:20 +02:00
|
|
|
handler(new PacketHandler() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2021-06-02 22:00:20 +02:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-15 01:34:20 +01:00
|
|
|
int data = wrapper.get(Type.INT, 0); // Data (1st Integer)
|
2016-03-12 00:07:13 +01:00
|
|
|
|
|
|
|
short vX = 0, vY = 0, vZ = 0;
|
|
|
|
if (data > 0) {
|
|
|
|
vX = wrapper.read(Type.SHORT);
|
|
|
|
vY = wrapper.read(Type.SHORT);
|
|
|
|
vZ = wrapper.read(Type.SHORT);
|
|
|
|
}
|
|
|
|
|
|
|
|
wrapper.write(Type.SHORT, vX);
|
|
|
|
wrapper.write(Type.SHORT, vY);
|
|
|
|
wrapper.write(Type.SHORT, vZ);
|
|
|
|
}
|
2016-04-02 15:46:30 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Handle potions
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
|
|
|
final int entityID = wrapper.get(Type.VAR_INT, 0);
|
|
|
|
final int data = wrapper.get(Type.INT, 0); // Data
|
|
|
|
|
|
|
|
int typeID = wrapper.get(Type.BYTE, 0);
|
2016-09-30 20:08:39 +02:00
|
|
|
if (Entity1_10Types.getTypeFromId(typeID, true) == Entity1_10Types.EntityType.SPLASH_POTION) {
|
2016-04-02 15:46:30 +02:00
|
|
|
// Convert this to meta data, woo!
|
2021-12-08 12:49:13 +01:00
|
|
|
PacketWrapper metaPacket = wrapper.create(ClientboundPackets1_9.ENTITY_METADATA, new PacketHandler() {
|
2016-04-02 15:46:30 +02:00
|
|
|
@Override
|
2021-06-02 22:00:20 +02:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-04-02 15:46:30 +02:00
|
|
|
wrapper.write(Type.VAR_INT, entityID);
|
|
|
|
List<Metadata> meta = new ArrayList<>();
|
2021-06-04 12:15:14 +02:00
|
|
|
Item item = new DataItem(373, (byte) 1, (short) data, null); // Potion
|
2016-04-02 15:46:30 +02:00
|
|
|
ItemRewriter.toClient(item); // Rewrite so that it gets the right nbt
|
2016-06-08 20:02:11 +02:00
|
|
|
// TEMP FIX FOR POTIONS UNTIL WE FIGURE OUT HOW TO TRANSFORM SENT PACKETS
|
2016-09-26 14:36:10 +02:00
|
|
|
Metadata potion = new Metadata(5, MetaType1_9.Slot, item);
|
2016-04-02 15:46:30 +02:00
|
|
|
meta.add(potion);
|
2016-07-11 15:52:06 +02:00
|
|
|
wrapper.write(Types1_9.METADATA_LIST, meta);
|
2016-04-02 15:46:30 +02:00
|
|
|
}
|
|
|
|
});
|
2021-12-08 12:49:13 +01:00
|
|
|
// Fix packet order
|
|
|
|
wrapper.send(Protocol1_9To1_8.class);
|
|
|
|
metaPacket.send(Protocol1_9To1_8.class);
|
|
|
|
wrapper.cancel();
|
2016-04-02 15:46:30 +02:00
|
|
|
}
|
|
|
|
}
|
2016-03-12 00:07:13 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_EXPERIENCE_ORB, new PacketHandlers() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.VAR_INT); // 0 - Entity ID
|
|
|
|
|
2016-03-13 14:40:53 +01:00
|
|
|
// Parse this info
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
2016-03-22 20:37:15 +01:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-13 14:40:53 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-05-08 12:14:41 +02:00
|
|
|
tracker.addEntity(entityID, Entity1_10Types.EntityType.EXPERIENCE_ORB);
|
2016-05-27 02:00:01 +02:00
|
|
|
tracker.sendMetadataBuffer(entityID);
|
2016-03-13 14:40:53 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-12 23:33:43 +01:00
|
|
|
map(Type.INT, toNewDouble); // 1 - X - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 2 - Y - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 3 - Z - Needs to be divide by 32
|
2016-03-12 00:07:13 +01:00
|
|
|
|
2016-03-22 20:28:37 +01:00
|
|
|
map(Type.SHORT); // 4 - Amount to spawn
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_GLOBAL_ENTITY, new PacketHandlers() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.VAR_INT); // 0 - Entity ID
|
|
|
|
map(Type.BYTE); // 1 - Type
|
2016-03-13 14:40:53 +01:00
|
|
|
// Parse this info
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
2016-03-22 20:37:15 +01:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-13 14:40:53 +01:00
|
|
|
// Currently only lightning uses this
|
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-05-08 12:14:41 +02:00
|
|
|
tracker.addEntity(entityID, Entity1_10Types.EntityType.LIGHTNING);
|
2016-05-27 02:00:01 +02:00
|
|
|
tracker.sendMetadataBuffer(entityID);
|
2016-03-13 14:40:53 +01:00
|
|
|
}
|
|
|
|
});
|
2016-03-12 00:07:13 +01:00
|
|
|
|
2016-03-12 23:33:43 +01:00
|
|
|
map(Type.INT, toNewDouble); // 2 - X - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 3 - Y - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 4 - Z - Needs to be divide by 32
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_MOB, new PacketHandlers() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.VAR_INT); // 0 - Entity ID
|
2016-03-13 14:40:53 +01:00
|
|
|
|
2021-06-02 22:00:20 +02:00
|
|
|
handler(new PacketHandler() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2021-06-02 22:00:20 +02:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-12 00:07:13 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2016-03-13 14:40:53 +01:00
|
|
|
wrapper.write(Type.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
map(Type.UNSIGNED_BYTE); // 2 - Type
|
|
|
|
|
2016-03-13 14:40:53 +01:00
|
|
|
// Parse this info
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
2016-03-22 20:37:15 +01:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-13 14:40:53 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
|
|
|
int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-05-08 12:14:41 +02:00
|
|
|
tracker.addEntity(entityID, Entity1_10Types.getTypeFromId(typeID, false));
|
2016-05-27 02:00:01 +02:00
|
|
|
tracker.sendMetadataBuffer(entityID);
|
2016-03-13 14:40:53 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-12 23:33:43 +01:00
|
|
|
map(Type.INT, toNewDouble); // 3 - X - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divide by 32
|
2016-03-12 00:07:13 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-07-11 15:52:06 +02:00
|
|
|
map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST);
|
2016-03-15 01:34:20 +01:00
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-07-11 15:52:06 +02:00
|
|
|
List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
|
2019-05-09 14:43:48 +02:00
|
|
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-09-27 20:25:18 +02:00
|
|
|
if (tracker.hasEntity(entityId)) {
|
|
|
|
protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user());
|
2016-03-18 22:18:48 +01:00
|
|
|
} else {
|
2019-05-09 14:43:48 +02:00
|
|
|
Via.getPlatform().getLogger().warning("Unable to find entity for metadata, entity ID: " + entityId);
|
2016-03-23 18:56:02 +01:00
|
|
|
metadataList.clear();
|
2016-03-15 01:34:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-03-16 22:52:00 +01:00
|
|
|
// Handler for meta data
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-07-11 15:52:06 +02:00
|
|
|
List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
|
2016-03-16 22:52:00 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2016-03-16 22:52:00 +01:00
|
|
|
tracker.handleMetadata(entityID, metadataList);
|
|
|
|
}
|
|
|
|
});
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PAINTING, new PacketHandlers() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.VAR_INT); // 0 - Entity ID
|
2016-03-13 14:40:53 +01:00
|
|
|
|
|
|
|
// Parse this info
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
2016-03-22 20:37:15 +01:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-13 14:40:53 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-05-08 12:14:41 +02:00
|
|
|
tracker.addEntity(entityID, Entity1_10Types.EntityType.PAINTING);
|
2016-05-27 02:00:01 +02:00
|
|
|
tracker.sendMetadataBuffer(entityID);
|
2016-03-13 14:40:53 +01:00
|
|
|
}
|
|
|
|
});
|
2021-06-02 22:00:20 +02:00
|
|
|
handler(new PacketHandler() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2021-06-02 22:00:20 +02:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-03-12 00:07:13 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2016-03-13 14:40:53 +01:00
|
|
|
wrapper.write(Type.UUID, tracker.getEntityUUID(entityID)); // 1 - UUID
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
2016-03-13 14:40:53 +01:00
|
|
|
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.STRING); // 2 - Title
|
|
|
|
map(Type.POSITION); // 3 - Position
|
|
|
|
map(Type.BYTE); // 4 - Direction
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.SPAWN_PLAYER, new PacketHandlers() {
|
2016-03-12 00:07:13 +01:00
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2016-03-12 00:07:13 +01:00
|
|
|
map(Type.VAR_INT); // 0 - Entity ID
|
|
|
|
map(Type.UUID); // 1 - Player UUID
|
|
|
|
|
2016-03-23 18:56:02 +01:00
|
|
|
// Parse this info
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-05-08 12:14:41 +02:00
|
|
|
tracker.addEntity(entityID, Entity1_10Types.EntityType.PLAYER);
|
2016-05-27 02:00:01 +02:00
|
|
|
tracker.sendMetadataBuffer(entityID);
|
2016-03-23 18:56:02 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-03-12 23:33:43 +01:00
|
|
|
map(Type.INT, toNewDouble); // 2 - X - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 3 - Y - Needs to be divide by 32
|
|
|
|
map(Type.INT, toNewDouble); // 4 - Z - Needs to be divide by 32
|
2016-03-12 00:07:13 +01:00
|
|
|
|
|
|
|
map(Type.BYTE); // 5 - Yaw
|
|
|
|
map(Type.BYTE); // 6 - Pitch
|
|
|
|
|
2016-03-31 16:28:56 +02:00
|
|
|
handler(new PacketHandler() { //Handle discontinued player hand item
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
|
|
|
short item = wrapper.read(Type.SHORT);
|
|
|
|
if (item != 0) {
|
2021-07-31 12:43:07 +02:00
|
|
|
PacketWrapper packet = PacketWrapper.create(ClientboundPackets1_9.ENTITY_EQUIPMENT, null, wrapper.user());
|
2016-03-31 16:28:56 +02:00
|
|
|
packet.write(Type.VAR_INT, wrapper.get(Type.VAR_INT, 0));
|
2016-04-19 17:32:03 +02:00
|
|
|
packet.write(Type.VAR_INT, 0);
|
2021-06-04 12:15:14 +02:00
|
|
|
packet.write(Type.ITEM, new DataItem(item, (byte) 1, (short) 0, null));
|
2016-03-31 16:28:56 +02:00
|
|
|
try {
|
2021-05-31 22:58:47 +02:00
|
|
|
packet.send(Protocol1_9To1_8.class);
|
2016-03-31 16:28:56 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-03-12 00:07:13 +01:00
|
|
|
|
2016-07-11 15:52:06 +02:00
|
|
|
map(Types1_8.METADATA_LIST, Types1_9.METADATA_LIST);
|
2016-03-15 01:34:20 +01:00
|
|
|
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-07-11 15:52:06 +02:00
|
|
|
List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
|
2019-05-09 14:43:48 +02:00
|
|
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-09-27 20:25:18 +02:00
|
|
|
if (tracker.hasEntity(entityId)) {
|
|
|
|
protocol.get(MetadataRewriter1_9To1_8.class).handleMetadata(entityId, metadataList, wrapper.user());
|
2016-03-18 22:18:48 +01:00
|
|
|
} else {
|
2019-05-09 14:43:48 +02:00
|
|
|
Via.getPlatform().getLogger().warning("Unable to find entity for metadata, entity ID: " + entityId);
|
2016-03-23 18:56:02 +01:00
|
|
|
metadataList.clear();
|
2016-03-15 01:34:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-03-16 22:52:00 +01:00
|
|
|
|
|
|
|
// Handler for meta data
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2016-07-11 15:52:06 +02:00
|
|
|
List<Metadata> metadataList = wrapper.get(Types1_9.METADATA_LIST, 0);
|
2016-03-16 22:52:00 +01:00
|
|
|
int entityID = wrapper.get(Type.VAR_INT, 0);
|
Refactor entity tracking and meta handling
This essentially merges the two approaches to the metadata handling from ViaVersion and ViaBackwards and improves on both designs.
ViaVersion did not track every single entity, but only those needed (at least in theory) and can work with untracked entities' metadata. It had a very simple method overridden by metadata rewriter implementations, directly operating on the full metadata list and manually handling meta index changes as well as item/block/particle id changes.
ViaBackwards on the other hand had to track *every single* entity and threw warnings otherwise - while less prone to errors due to giving obvious warnings in the console, it unnecessarily tracks a lot of entities, and those warnings also annoys users when encountering virtual entity plugins (operating asynchronously and sending update packets while already untracked or not yet tracked). Dedicated MetaHandlers made id changes and filtering a lot easier to read and write. However, the actual metadata list handling and its distribution to handlers was not very well implemented and required a lot of list copying and creation as well as exception throws to cancel individual metadata entries.
This version has MetaFilters built with a Builder containing multiple helper functions, and the entity tracking is properly given its own map, hashed by a Protocol's class, to be easily and generically accessible from anywhere with only a Protocol class from the UserConnection, along with more optimized metadata list iteration. The entity tracking is largely unchanged, keeping ViaVersion's approach to not having to track *all* entities (and being able to handle null types in meta handlers).
All of this is by no means absolutely perfect, but is much less prone to errors than both previous systems and takes a lot less effort to actually write. A last possible change would be to use a primitive int to object map that is built to be concurrency save for the EntityTracker, tho that would have to be chosen carefully.
2021-05-24 23:24:50 +02:00
|
|
|
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2016-03-16 22:52:00 +01:00
|
|
|
tracker.handleMetadata(entityID, metadataList);
|
|
|
|
}
|
|
|
|
});
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
});
|
2016-03-13 18:01:36 +01:00
|
|
|
|
2023-02-12 10:54:47 +01:00
|
|
|
protocol.registerClientbound(ClientboundPackets1_8.DESTROY_ENTITIES, new PacketHandlers() {
|
2016-03-13 18:01:36 +01:00
|
|
|
|
|
|
|
@Override
|
2023-02-12 10:54:47 +01:00
|
|
|
public void register() {
|
2019-11-02 14:00:27 +01:00
|
|
|
map(Type.VAR_INT_ARRAY_PRIMITIVE); // 0 - Entities to destroy
|
2016-03-13 18:01:36 +01:00
|
|
|
|
|
|
|
handler(new PacketHandler() {
|
|
|
|
@Override
|
2016-03-22 20:37:15 +01:00
|
|
|
public void handle(PacketWrapper wrapper) throws Exception {
|
2019-11-02 14:00:27 +01:00
|
|
|
int[] entities = wrapper.get(Type.VAR_INT_ARRAY_PRIMITIVE, 0);
|
2022-01-03 18:41:07 +01:00
|
|
|
EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
2019-11-02 14:00:27 +01:00
|
|
|
for (int entity : entities) {
|
2016-03-13 18:01:36 +01:00
|
|
|
// EntityTracker
|
2022-01-03 18:41:07 +01:00
|
|
|
tracker.removeEntity(entity);
|
2016-03-13 18:01:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-03-12 00:07:13 +01:00
|
|
|
}
|
|
|
|
}
|