Reenable attribute packets, fix modded entities

This commit is contained in:
libraryaddict 2020-06-30 16:18:03 +12:00
parent f3d5f7efc3
commit e3300e7ef9
3 changed files with 18 additions and 13 deletions

View File

@ -50,8 +50,7 @@ public class PacketHandlerAttributes implements IPacketHandler {
return; return;
} }
// Skip if its 1.16, PL can't handle it atm if (disguise.isMiscDisguise()) {
if (disguise.isMiscDisguise() || NmsVersion.v1_16.isSupported()) {
return; return;
} }

View File

@ -75,7 +75,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
Disguise disguise = packets.getDisguise(); Disguise disguise = packets.getDisguise();
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) { if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
if (disguise.getWatcher() instanceof LivingWatcher && !NmsVersion.v1_16.isSupported()) { if (disguise.getWatcher() instanceof LivingWatcher) {
ArrayList<WrappedAttribute> attributes = new ArrayList<>(); ArrayList<WrappedAttribute> attributes = new ArrayList<>();
WrappedAttribute.Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth"); WrappedAttribute.Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth");

View File

@ -14,6 +14,8 @@ import io.netty.buffer.Unpooled;
import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.DecoderException;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.utilities.modded.ModdedManager; import me.libraryaddict.disguise.utilities.modded.ModdedManager;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import net.minecraft.server.v1_16_R1.PacketDataSerializer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
@ -140,21 +142,25 @@ public class PacketListenerModdedClient extends PacketAdapter {
PacketContainer packet1 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD); PacketContainer packet1 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD);
packet1.getIntegers().write(0, packetId1); packet1.getIntegers().write(0, packetId1);
packet1.getMinecraftKeys().write(0, new com.comphenix.protocol.wrappers.MinecraftKey("fml", "handshake")); packet1.getMinecraftKeys().write(0, new com.comphenix.protocol.wrappers.MinecraftKey("fml", "handshake"));
// packet1.getModifier()
// .write(2, new PacketDataSerializer(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake()))); try {
Object obj1 = ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class)
.newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake()));
packet1.getModifier().write(2, obj1);
PacketContainer packet2 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD); PacketContainer packet2 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD);
packet2.getIntegers().write(0, packetId2); packet2.getIntegers().write(0, packetId2);
packet2.getMinecraftKeys().write(0, new MinecraftKey("fml", "handshake")); packet2.getMinecraftKeys().write(0, new MinecraftKey("fml", "handshake"));
// packet2.getModifier() Object obj2 = ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class)
// .write(2, new PacketDataSerializer(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries()))); .newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries()));
packet2.getModifier().write(2, obj2);
//TODO
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet1); ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet1);
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet2); ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet2);
} }
catch (InvocationTargetException e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }