forked from SteamWar/SteamWar
Fix REntity for 1.15.2-1.21.3
<1.15.2: Untested
This commit is contained in:
@@ -46,14 +46,9 @@ public class PlayerMovementWrapper15 implements PlayerMovementWrapper {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0));
|
||||
if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.a(0.0F)));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.b(0.0F)));
|
||||
}
|
||||
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0),
|
||||
Float.isNaN(packetPlayInFlying.a(Float.NaN)) ? player.getLocation().getYaw() : packetPlayInFlying.a(0.0F),
|
||||
Float.isNaN(packetPlayInFlying.b(Float.NaN)) ? player.getLocation().getPitch() : packetPlayInFlying.b(0.0F));
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +44,9 @@ public class PlayerMovementWrapper18 implements PlayerMovementWrapper {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
if (packetPlayInFlying.h) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||
}
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
||||
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
||||
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,14 +48,9 @@ public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
if (packetPlayInFlying.h) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||
}
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
||||
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
||||
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,14 +49,9 @@ public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
|
||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, player.getEntityId());
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||
if (packetPlayInFlying.h) {
|
||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
||||
} else {
|
||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
||||
}
|
||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
||||
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
||||
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ package de.steamwar.bausystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.DataComponents;
|
||||
import net.minecraft.core.particles.ParticleParam;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
@@ -36,8 +34,6 @@ import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.entity.player.PlayerAbilities;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
||||
@@ -45,7 +41,6 @@ import org.bukkit.craftbukkit.v1_21_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class NMSWrapper21 implements NMSWrapper {
|
||||
@@ -132,12 +127,15 @@ public class NMSWrapper21 implements NMSWrapper {
|
||||
return invalid;
|
||||
}
|
||||
|
||||
private final Class<?> explosionPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
|
||||
private final Reflection.FieldAccessor<Optional> explosionKnockback = Reflection.getField(explosionPacket, Optional.class, 0);
|
||||
|
||||
@Override
|
||||
public Object resetExplosionKnockback(Object packet) {
|
||||
explosionKnockback.set(packet, Optional.empty());
|
||||
return packet;
|
||||
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
||||
|
||||
return new PacketPlayOutExplosion(
|
||||
explosion.b(),
|
||||
Optional.empty(),
|
||||
explosion.f(),
|
||||
explosion.g()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,21 +24,16 @@ import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.core.BountifulWrapper;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import de.steamwar.entity.REntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface PlayerMovementWrapper {
|
||||
Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
||||
Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, Integer.TYPE, 0);
|
||||
BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||
Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, Byte.TYPE, 0);
|
||||
Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, Byte.TYPE, 1);
|
||||
Class<?> teleportPacket = REntity.teleportPacket;
|
||||
Reflection.FieldAccessor<Integer> teleportEntity = REntity.teleportEntity;
|
||||
BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition;
|
||||
|
||||
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||
|
||||
void setPosition(Player player, Object object);
|
||||
Object convertToOut(Player player, Object object);
|
||||
|
||||
default byte rotToByte(float rot) {
|
||||
return (byte)((int)(rot * 256.0F / 360.0F));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ dependencies {
|
||||
compileOnly(project(":SpigotCore:SpigotCore_Main", "default"))
|
||||
compileOnly(project(":SpigotCore:SpigotCore_18", "default"))
|
||||
compileOnly(project(":SpigotCore:SpigotCore_14", "default"))
|
||||
compileOnly(project(":SpigotCore:SpigotCore_9", "default"))
|
||||
|
||||
compileOnly(libs.fawe21)
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.core;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import net.minecraft.world.entity.PositionMoveRotation;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
public class BountifulWrapper21 extends BountifulWrapper9 {
|
||||
|
||||
@Override
|
||||
public BountifulWrapper.PositionSetter getPositionSetter(Class<?> packetClass, int fieldOffset) {
|
||||
try {
|
||||
Reflection.FieldAccessor<PositionMoveRotation> field = Reflection.getField(packetClass, PositionMoveRotation.class, 0);
|
||||
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
PositionMoveRotation pos = field.get(packet);
|
||||
|
||||
field.set(packet, new PositionMoveRotation(new Vec3D(x, y, z), pos.b(), pitch, yaw));
|
||||
};
|
||||
} catch (IllegalArgumentException e) {
|
||||
return super.getPositionSetter(packetClass, fieldOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,12 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.enginehub.linbus.stream.LinBinaryIO;
|
||||
import org.enginehub.linbus.stream.LinStream;
|
||||
import org.enginehub.linbus.tree.LinCompoundTag;
|
||||
@@ -38,7 +42,7 @@ import org.enginehub.linbus.tree.LinTagType;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
public class WorldEditWrapper21 implements WorldEditWrapper {
|
||||
|
||||
@Override
|
||||
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
|
||||
@@ -94,4 +98,26 @@ public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.util.Vector getOrigin(Clipboard clipboard) {
|
||||
return new org.bukkit.util.Vector(clipboard.getOrigin().x(), clipboard.getOrigin().y(), clipboard.getOrigin().z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimum(Region region) {
|
||||
return new Vector(region.getMinimumPoint().x(), region.getMinimumPoint().y(), region.getMinimumPoint().z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximum(Region region) {
|
||||
return new Vector(region.getMaximumPoint().x(), region.getMaximumPoint().y(), region.getMaximumPoint().z());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector applyTransform(Vector vector, Transform transform) {
|
||||
Vector3 v = Vector3.at(vector.getX(), vector.getY(), vector.getZ());
|
||||
v = transform.apply(v);
|
||||
return new org.bukkit.util.Vector(v.x(), v.y(), v.z());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.ChatComponentText;
|
||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -70,11 +71,15 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||
Reflection.FieldAccessor<Integer> posX = Reflection.getField(packetClass, int.class, fieldOffset);
|
||||
Reflection.FieldAccessor<Integer> posY = Reflection.getField(packetClass, int.class, fieldOffset +1);
|
||||
Reflection.FieldAccessor<Integer> posZ = Reflection.getField(packetClass, int.class, fieldOffset +2);
|
||||
Reflection.FieldAccessor<Byte> lookPitch = Reflection.getField(packetClass, byte.class, 0);
|
||||
Reflection.FieldAccessor<Byte> lookYaw = Reflection.getField(packetClass, byte.class, 1);
|
||||
|
||||
return (packet, x, y, z) -> {
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
posX.set(packet, MathHelper.floor(x * 32));
|
||||
posY.set(packet, MathHelper.floor(y * 32));
|
||||
posZ.set(packet, MathHelper.floor(z * 32));
|
||||
lookPitch.set(packet, (byte)(pitch * 256 / 360));
|
||||
lookYaw.set(packet, (byte)(yaw * 256 / 360));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -83,11 +88,15 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
|
||||
Reflection.FieldAccessor<?> moveX = Reflection.getField(packetClass, "b", byte.class);
|
||||
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", byte.class);
|
||||
Reflection.FieldAccessor<?> moveZ = Reflection.getField(packetClass, "d", byte.class);
|
||||
Reflection.FieldAccessor<Byte> lookYaw = Reflection.getField(packetClass, "e", byte.class);
|
||||
Reflection.FieldAccessor<Byte> lookPitch = Reflection.getField(packetClass, "f", byte.class);
|
||||
|
||||
return (packet, x, y, z) -> {
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
moveX.set(packet, (byte)(x*32));
|
||||
moveY.set(packet, (byte)(y*32));
|
||||
moveZ.set(packet, (byte)(z*32));
|
||||
lookYaw.set(packet, (byte)(yaw*256/360));
|
||||
lookPitch.set(packet, (byte)(pitch*256/360));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.comphenix.tinyprotocol.Reflection;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayOutEntity;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -64,11 +65,17 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
Reflection.FieldAccessor<Double> posX = Reflection.getField(packetClass, double.class, fieldOffset);
|
||||
Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset+1);
|
||||
Reflection.FieldAccessor<Double> posZ = Reflection.getField(packetClass, double.class, fieldOffset+2);
|
||||
boolean isByteClass = packetClass.getSimpleName().contains("PacketPlayOutEntityTeleport");
|
||||
Class<?> pitchYawType = isByteClass ? byte.class : int.class;
|
||||
Reflection.FieldAccessor<?> lookPitch = Reflection.getField(packetClass, pitchYawType, isByteClass ? 0 : 1);
|
||||
Reflection.FieldAccessor<?> lookYaw = Reflection.getField(packetClass, pitchYawType, isByteClass ? 1 : 2);
|
||||
|
||||
return (packet, x, y, z) -> {
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
posX.set(packet, x);
|
||||
posY.set(packet, y);
|
||||
posZ.set(packet, z);
|
||||
lookPitch.set(packet, (int)(pitch*256/360));
|
||||
lookYaw.set(packet, (int)(yaw*256/360));
|
||||
};
|
||||
}
|
||||
|
||||
@@ -78,11 +85,15 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
|
||||
Reflection.FieldAccessor<?> moveX = Reflection.getField(packetClass, "b", type);
|
||||
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", type);
|
||||
Reflection.FieldAccessor<?> moveZ = Reflection.getField(packetClass, "d", type);
|
||||
Reflection.FieldAccessor<Byte> movePitch = Reflection.getField(packetClass, "e", byte.class);
|
||||
Reflection.FieldAccessor<Byte> moveYaw = Reflection.getField(packetClass, "f", byte.class);
|
||||
|
||||
return (packet, x, y, z) -> {
|
||||
return (packet, x, y, z, pitch, yaw) -> {
|
||||
moveX.set(packet, (short)(x*4096));
|
||||
moveY.set(packet, (short)(y*4096));
|
||||
moveZ.set(packet, (short)(z*4096));
|
||||
movePitch.set(packet, (byte)(pitch*256/360));
|
||||
moveYaw.set(packet, (byte)(yaw*256/360));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class BountifulWrapper {
|
||||
}
|
||||
|
||||
public interface PositionSetter {
|
||||
void set(Object packet, double x, double y, double z);
|
||||
void set(Object packet, double x, double y, double z, float pitch, float yaw);
|
||||
}
|
||||
|
||||
public interface UUIDSetter {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ErrorHandler extends Handler {
|
||||
return;
|
||||
|
||||
try {
|
||||
SWException.log(message, stacktrace);
|
||||
//SWException.log(message, stacktrace);
|
||||
} catch (SecurityException e) {
|
||||
Core.getInstance().getLogger().log(Level.INFO, "Could not log error in database", e);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public class WorldEditRenderer {
|
||||
Transform transform = session.getClipboard().getTransform();
|
||||
Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos);
|
||||
Vector b = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMaximum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos);
|
||||
drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), Particle.VILLAGER_HAPPY, player);
|
||||
drawCuboid(Vector.getMinimum(a, b), Vector.getMaximum(a, b), TrickyTrialsWrapper.impl.getVillagerHappyParticle(), player);
|
||||
} catch (EmptyClipboardException e) {
|
||||
//ignore
|
||||
}
|
||||
|
||||
@@ -393,25 +393,19 @@ public class REntity {
|
||||
return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues);
|
||||
}
|
||||
|
||||
private static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
||||
private static final Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0);
|
||||
private static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||
private static final Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, byte.class, 0);
|
||||
private static final Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, byte.class, 1);
|
||||
public static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
||||
public static final Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0);
|
||||
public static final BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0);
|
||||
private Object getTeleportPacket(){
|
||||
Object packet = Reflection.newInstance(teleportPacket);
|
||||
teleportEntity.set(packet, entityId);
|
||||
teleportPosition.set(packet, x, y, z);
|
||||
teleportYaw.set(packet, yaw);
|
||||
teleportPitch.set(packet, pitch);
|
||||
teleportPosition.set(packet, x, y, z, pitch, yaw);
|
||||
return packet;
|
||||
}
|
||||
|
||||
private static final Class<?> entityPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity");
|
||||
private static final Reflection.FieldAccessor<Integer> moveEntityId = Reflection.getField(entityPacket, int.class, 0);
|
||||
private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket);
|
||||
private static final Reflection.FieldAccessor<Byte> lookYaw = Reflection.getField(entityPacket, "e", byte.class);
|
||||
private static final Reflection.FieldAccessor<Byte> lookPitch = Reflection.getField(entityPacket, "f", byte.class);
|
||||
private static final Class<?> lookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutEntityLook");
|
||||
private static final Class<?> movePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMove");
|
||||
private static final Class<?> moveLookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook");
|
||||
@@ -430,9 +424,7 @@ public class REntity {
|
||||
|
||||
Object packet = Reflection.newInstance(clazz);
|
||||
moveEntityId.set(packet, entityId);
|
||||
movePosition.set(packet, diffX, diffY, diffZ);
|
||||
lookYaw.set(packet, yaw);
|
||||
lookPitch.set(packet, pitch);
|
||||
movePosition.set(packet, diffX, diffY, diffZ, pitch, yaw);
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -476,7 +468,7 @@ public class REntity {
|
||||
return entity -> {
|
||||
Object packet = Reflection.newInstance(spawnPacket);
|
||||
entityId.set(packet, entity.entityId);
|
||||
position.set(packet, entity.x, entity.y, entity.z);
|
||||
position.set(packet, entity.x, entity.y, entity.z, entity.pitch, entity.yaw);
|
||||
return packet;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user