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);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0));
|
teleportPosition.set(packet, packetPlayInFlying.a(0.0), packetPlayInFlying.b(0.0), packetPlayInFlying.c(0.0),
|
||||||
if (Float.isNaN(packetPlayInFlying.a(Float.NaN))) {
|
Float.isNaN(packetPlayInFlying.a(Float.NaN)) ? player.getLocation().getYaw() : packetPlayInFlying.a(0.0F),
|
||||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
Float.isNaN(packetPlayInFlying.b(Float.NaN)) ? player.getLocation().getPitch() : packetPlayInFlying.b(0.0F));
|
||||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
|
||||||
} else {
|
|
||||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.a(0.0F)));
|
|
||||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.b(0.0F)));
|
|
||||||
}
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,14 +44,9 @@ public class PlayerMovementWrapper18 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
||||||
if (packetPlayInFlying.h) {
|
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
||||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
||||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
|
||||||
} else {
|
|
||||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
|
||||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
|
||||||
}
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,14 +48,9 @@ public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
||||||
if (packetPlayInFlying.h) {
|
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
||||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
||||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
|
||||||
} else {
|
|
||||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
|
||||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
|
||||||
}
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,14 +49,9 @@ public class PlayerMovementWrapper20 implements PlayerMovementWrapper {
|
|||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, player.getEntityId());
|
teleportEntity.set(packet, player.getEntityId());
|
||||||
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
teleportPosition.set(packet, packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c,
|
||||||
if (packetPlayInFlying.h) {
|
packetPlayInFlying.h ? player.getLocation().getYaw() : packetPlayInFlying.d,
|
||||||
teleportYaw.set(packet, rotToByte(player.getLocation().getYaw()));
|
packetPlayInFlying.h ? player.getLocation().getPitch() : packetPlayInFlying.e);
|
||||||
teleportPitch.set(packet, rotToByte(player.getLocation().getPitch()));
|
|
||||||
} else {
|
|
||||||
teleportYaw.set(packet, rotToByte(packetPlayInFlying.d));
|
|
||||||
teleportPitch.set(packet, rotToByte(packetPlayInFlying.e));
|
|
||||||
}
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,7 @@ package de.steamwar.bausystem.utils;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import de.steamwar.bausystem.features.util.NoClipCommand;
|
import de.steamwar.bausystem.features.util.NoClipCommand;
|
||||||
import net.minecraft.core.Holder;
|
|
||||||
import net.minecraft.core.component.DataComponents;
|
import net.minecraft.core.component.DataComponents;
|
||||||
import net.minecraft.core.particles.ParticleParam;
|
|
||||||
import net.minecraft.nbt.NBTBase;
|
import net.minecraft.nbt.NBTBase;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
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.entity.player.PlayerAbilities;
|
||||||
import net.minecraft.world.item.component.CustomData;
|
import net.minecraft.world.item.component.CustomData;
|
||||||
import net.minecraft.world.level.EnumGamemode;
|
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.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_21_R2.entity.CraftPlayer;
|
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.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class NMSWrapper21 implements NMSWrapper {
|
public class NMSWrapper21 implements NMSWrapper {
|
||||||
@@ -132,12 +127,15 @@ public class NMSWrapper21 implements NMSWrapper {
|
|||||||
return invalid;
|
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
|
@Override
|
||||||
public Object resetExplosionKnockback(Object packet) {
|
public Object resetExplosionKnockback(Object packet) {
|
||||||
explosionKnockback.set(packet, Optional.empty());
|
PacketPlayOutExplosion explosion = (PacketPlayOutExplosion) packet;
|
||||||
return 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.BountifulWrapper;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.core.VersionDependent;
|
import de.steamwar.core.VersionDependent;
|
||||||
|
import de.steamwar.entity.REntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface PlayerMovementWrapper {
|
public interface PlayerMovementWrapper {
|
||||||
Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
Class<?> teleportPacket = REntity.teleportPacket;
|
||||||
Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, Integer.TYPE, 0);
|
Reflection.FieldAccessor<Integer> teleportEntity = REntity.teleportEntity;
|
||||||
BountifulWrapper.PositionSetter teleportPosition = BountifulWrapper.impl.getPositionSetter(teleportPacket, Core.getVersion() == 8 ? 1 : 0);
|
BountifulWrapper.PositionSetter teleportPosition = REntity.teleportPosition;
|
||||||
Reflection.FieldAccessor<Byte> teleportYaw = Reflection.getField(teleportPacket, Byte.TYPE, 0);
|
|
||||||
Reflection.FieldAccessor<Byte> teleportPitch = Reflection.getField(teleportPacket, Byte.TYPE, 1);
|
|
||||||
|
|
||||||
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||||
|
|
||||||
void setPosition(Player player, Object object);
|
void setPosition(Player player, Object object);
|
||||||
Object convertToOut(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_Main", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_18", "default"))
|
compileOnly(project(":SpigotCore:SpigotCore_18", "default"))
|
||||||
compileOnly(project(":SpigotCore:SpigotCore_14", "default"))
|
compileOnly(project(":SpigotCore:SpigotCore_14", "default"))
|
||||||
|
compileOnly(project(":SpigotCore:SpigotCore_9", "default"))
|
||||||
|
|
||||||
compileOnly(libs.fawe21)
|
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.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV1Reader;
|
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 com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
import org.enginehub.linbus.stream.LinBinaryIO;
|
import org.enginehub.linbus.stream.LinBinaryIO;
|
||||||
import org.enginehub.linbus.stream.LinStream;
|
import org.enginehub.linbus.stream.LinStream;
|
||||||
import org.enginehub.linbus.tree.LinCompoundTag;
|
import org.enginehub.linbus.tree.LinCompoundTag;
|
||||||
@@ -38,7 +42,7 @@ import org.enginehub.linbus.tree.LinTagType;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class WorldEditWrapper21 implements WorldEditWrapper.IWorldEditWrapper {
|
public class WorldEditWrapper21 implements WorldEditWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getPlayerClipboard(Player player, boolean schemFormat) {
|
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.ChatComponentText;
|
||||||
import net.minecraft.server.v1_8_R3.MathHelper;
|
import net.minecraft.server.v1_8_R3.MathHelper;
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||||
|
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
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> posX = Reflection.getField(packetClass, int.class, fieldOffset);
|
||||||
Reflection.FieldAccessor<Integer> posY = Reflection.getField(packetClass, int.class, fieldOffset +1);
|
Reflection.FieldAccessor<Integer> posY = Reflection.getField(packetClass, int.class, fieldOffset +1);
|
||||||
Reflection.FieldAccessor<Integer> posZ = Reflection.getField(packetClass, int.class, fieldOffset +2);
|
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));
|
posX.set(packet, MathHelper.floor(x * 32));
|
||||||
posY.set(packet, MathHelper.floor(y * 32));
|
posY.set(packet, MathHelper.floor(y * 32));
|
||||||
posZ.set(packet, MathHelper.floor(z * 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<?> moveX = Reflection.getField(packetClass, "b", byte.class);
|
||||||
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", byte.class);
|
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", byte.class);
|
||||||
Reflection.FieldAccessor<?> moveZ = Reflection.getField(packetClass, "d", 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));
|
moveX.set(packet, (byte)(x*32));
|
||||||
moveY.set(packet, (byte)(y*32));
|
moveY.set(packet, (byte)(y*32));
|
||||||
moveZ.set(packet, (byte)(z*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 com.viaversion.viaversion.api.Via;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.minecraft.server.v1_9_R2.PacketPlayOutEntity;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
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> posX = Reflection.getField(packetClass, double.class, fieldOffset);
|
||||||
Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset+1);
|
Reflection.FieldAccessor<Double> posY = Reflection.getField(packetClass, double.class, fieldOffset+1);
|
||||||
Reflection.FieldAccessor<Double> posZ = Reflection.getField(packetClass, double.class, fieldOffset+2);
|
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);
|
posX.set(packet, x);
|
||||||
posY.set(packet, y);
|
posY.set(packet, y);
|
||||||
posZ.set(packet, z);
|
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<?> moveX = Reflection.getField(packetClass, "b", type);
|
||||||
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", type);
|
Reflection.FieldAccessor<?> moveY = Reflection.getField(packetClass, "c", type);
|
||||||
Reflection.FieldAccessor<?> moveZ = Reflection.getField(packetClass, "d", 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));
|
moveX.set(packet, (short)(x*4096));
|
||||||
moveY.set(packet, (short)(y*4096));
|
moveY.set(packet, (short)(y*4096));
|
||||||
moveZ.set(packet, (short)(z*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 {
|
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 {
|
public interface UUIDSetter {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class ErrorHandler extends Handler {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SWException.log(message, stacktrace);
|
//SWException.log(message, stacktrace);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
Core.getInstance().getLogger().log(Level.INFO, "Could not log error in database", 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();
|
Transform transform = session.getClipboard().getTransform();
|
||||||
Vector a = WorldEditWrapper.impl.applyTransform(WorldEditWrapper.impl.getMinimum(region).subtract(WorldEditWrapper.impl.getOrigin(clipboard)), transform).add(pos);
|
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);
|
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) {
|
} catch (EmptyClipboardException e) {
|
||||||
//ignore
|
//ignore
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -393,25 +393,19 @@ public class REntity {
|
|||||||
return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues);
|
return ChatWrapper.impl.getDataWatcherPacket(entityId, dataWatcherKeyValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
public static final Class<?> teleportPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntityTeleport");
|
||||||
private static final Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 0);
|
public 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);
|
public 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);
|
|
||||||
private Object getTeleportPacket(){
|
private Object getTeleportPacket(){
|
||||||
Object packet = Reflection.newInstance(teleportPacket);
|
Object packet = Reflection.newInstance(teleportPacket);
|
||||||
teleportEntity.set(packet, entityId);
|
teleportEntity.set(packet, entityId);
|
||||||
teleportPosition.set(packet, x, y, z);
|
teleportPosition.set(packet, x, y, z, pitch, yaw);
|
||||||
teleportYaw.set(packet, yaw);
|
|
||||||
teleportPitch.set(packet, pitch);
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> entityPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity");
|
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 Reflection.FieldAccessor<Integer> moveEntityId = Reflection.getField(entityPacket, int.class, 0);
|
||||||
private static final BountifulWrapper.PositionSetter movePosition = BountifulWrapper.impl.getRelMoveSetter(entityPacket);
|
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<?> 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<?> movePacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMove");
|
||||||
private static final Class<?> moveLookPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutEntity$PacketPlayOutRelEntityMoveLook");
|
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);
|
Object packet = Reflection.newInstance(clazz);
|
||||||
moveEntityId.set(packet, entityId);
|
moveEntityId.set(packet, entityId);
|
||||||
movePosition.set(packet, diffX, diffY, diffZ);
|
movePosition.set(packet, diffX, diffY, diffZ, pitch, yaw);
|
||||||
lookYaw.set(packet, yaw);
|
|
||||||
lookPitch.set(packet, pitch);
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +468,7 @@ public class REntity {
|
|||||||
return entity -> {
|
return entity -> {
|
||||||
Object packet = Reflection.newInstance(spawnPacket);
|
Object packet = Reflection.newInstance(spawnPacket);
|
||||||
entityId.set(packet, entity.entityId);
|
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;
|
return packet;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user