mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 12:05:41 +01:00
Move EntityNBT to different file and fix the issue to do with respawn chunks unloading. #287
This commit is contained in:
parent
d72b7fc4df
commit
1b99e2cf57
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -157,7 +158,7 @@ public class EntityPackets {
|
||||
Item stack = wrapper.get(Type.ITEM, 0);
|
||||
|
||||
if (stack != null) {
|
||||
if(Material.getMaterial(stack.getId()) != null) {
|
||||
if (Material.getMaterial(stack.getId()) != null) {
|
||||
if (Material.getMaterial(stack.getId()).name().endsWith("SWORD")) {
|
||||
entityTracker.getValidBlocking().add(entityID);
|
||||
return;
|
||||
@ -225,6 +226,24 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Update Entity NBT
|
||||
protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// int id = wrapper.read(Type.VAR_INT);
|
||||
// CompoundTag tag = wrapper.read(Type.NBT);
|
||||
// System.out.println(id + " - " + tag);
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* Packets which do not have any field remapping or handlers */
|
||||
|
||||
protocol.registerOutgoing(State.PLAY, 0x20, 0x4B); // Entity Properties Packet
|
||||
|
@ -15,6 +15,7 @@ import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.PlayerMovementMapper;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.ClientChunks;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
|
||||
|
||||
public class PlayerPackets {
|
||||
@ -145,7 +146,7 @@ public class PlayerPackets {
|
||||
// Parse this info
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception{
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityID = wrapper.get(Type.INT, 0);
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.getClientEntityTypes().put(entityID, EntityType.PLAYER);
|
||||
@ -254,19 +255,6 @@ public class PlayerPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Update Entity NBT
|
||||
protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Set Compression
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x46, new PacketRemapper() {
|
||||
@Override
|
||||
@ -415,6 +403,12 @@ public class PlayerPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int action = wrapper.get(Type.VAR_INT, 0);
|
||||
if (action == 0) {
|
||||
// Client unloads chunks on respawn, take note
|
||||
ClientChunks cc = wrapper.user().get(ClientChunks.class);
|
||||
cc.getBulkChunks().clear();
|
||||
cc.getLoadedChunks().clear();
|
||||
}
|
||||
if (action == 2) {
|
||||
// cancel any blocking >.>
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
|
Loading…
Reference in New Issue
Block a user