SteamWar/FightSystem
Archiviert
13
1

Full TinyProtocol implementation (untested)
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-28 13:08:10 +02:00
Ursprung bc82b18fc6
Commit 0e91cbdb06
9 geänderte Dateien mit 268 neuen und 120 gelöschten Zeilen

Datei anzeigen

@ -19,12 +19,15 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.record.REntity;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.EntityType;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockDataMeta;
@ -108,4 +111,29 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.MOVING_PISTON;
}
@Override
public void setNamedSpawnPacketDataWatcher(Object packet) {
// field not present
}
private static final Class<?> entityTypes = Reflection.getClass("{nms}.EntityTypes");
private static final Reflection.FieldAccessor<?> spawnType = Reflection.getField(REntity.spawnPacket, entityTypes, 0);
private static final Object tnt = Reflection.getField(entityTypes, "TNT", entityTypes).get(null);
private static final Object arrow = Reflection.getField(entityTypes, "ARROW", entityTypes).get(null);
private static final Object fireball = Reflection.getField(entityTypes, "FIREBALL", entityTypes).get(null);
@Override
public void setSpawnPacketType(Object packet, EntityType type) {
switch(type) {
case PRIMED_TNT:
spawnType.set(packet, tnt);
break;
case ARROW:
spawnType.set(packet, arrow);
break;
case FIREBALL:
spawnType.set(packet, fireball);
break;
}
}
}

Datei anzeigen

@ -54,6 +54,6 @@ public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper {
@Override
public Object getPose(boolean sneaking) {
return null;
return sneaking ? (byte) 2 : (byte) 0;
}
}

Datei anzeigen

@ -19,11 +19,14 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.REntity;
import net.md_5.bungee.api.chat.BaseComponent;
import net.minecraft.server.v1_8_R3.ChatComponentText;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import net.royawesome.jlibnoise.MathHelper;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -33,6 +36,10 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scoreboard.Team;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
@Override
@ -91,4 +98,64 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
public void spawnParticle(World world, String particleName, double x, double y, double z) {
world.playEffect(new Location(world, x, y, z), Effect.valueOf(particleName), 1);
}
@Override
public Object getDataWatcherObject(int index, Class<?> type) {
return index;
}
private static final Class<?> watchableObject = Reflection.getClass("{nms}.DataWatcher.WatchableObject");
private static final Reflection.ConstructorInvoker watchableObjectConstructor = Reflection.getConstructor(watchableObject, int.class, int.class, Object.class);
private static final Map<Class<?>, Integer> watchableDatatypes = new HashMap<>();
static {
watchableDatatypes.put(byte.class, 0);
watchableDatatypes.put(short.class, 1);
watchableDatatypes.put(int.class, 2);
watchableDatatypes.put(float.class, 3);
watchableDatatypes.put(String.class, 4);
watchableDatatypes.put(String.class, 5); //TODO: ItemStack required
}
@Override
public Object getDataWatcherItem(Object dwo, Object value) {
return watchableObjectConstructor.invoke(watchableDatatypes.get(value.getClass()), dwo, value);
}
private static final Reflection.FieldAccessor<Integer> teleportX = Reflection.getField(REntity.teleportPacket, int.class, 1);
private static final Reflection.FieldAccessor<Integer> teleportY = Reflection.getField(REntity.teleportPacket, int.class, 2);
private static final Reflection.FieldAccessor<Integer> teleportZ = Reflection.getField(REntity.teleportPacket, int.class, 3);
@Override
public void setTeleportPacketPosition(Object packet, double x, double y, double z) {
teleportX.set(packet, MathHelper.floor(x * 32));
teleportY.set(packet, MathHelper.floor(y * 32));
teleportZ.set(packet, MathHelper.floor(z * 32));
}
@Override
public void setSpawnPacketUUID(Object packet, UUID uuid) {
// field not present
}
private static final Reflection.FieldAccessor<Integer> equipmentSlot = Reflection.getField(REntity.equipmentPacket, int.class, 1);
@Override
public void setEquipmentPacketSlot(Object packet, String slot) {
switch(slot){
case "HEAD":
equipmentSlot.set(packet, 4);
break;
case "CHEST":
equipmentSlot.set(packet, 3);
break;
case "LEGS":
equipmentSlot.set(packet, 2);
break;
case "FEET":
equipmentSlot.set(packet, 1);
break;
case "MAINHAND":
case "OFFHAND":
default:
equipmentSlot.set(packet, 0);
}
}
}

Datei anzeigen

@ -19,10 +19,14 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.record.REntity;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -86,4 +90,29 @@ public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper
public boolean checkPistonMoving(Block block) {
return block.getType() == Material.PISTON_MOVING_PIECE;
}
private static final Class<?> dataWatcher = Reflection.getClass("{nms}.DataWatcher");
private static final Reflection.FieldAccessor<?> namedSpawnDataWatcher = Reflection.getField(REntity.namedSpawnPacket, dataWatcher, 0);
private static final Class<?> entity = Reflection.getClass("{nms}.Entity");
private static final Reflection.ConstructorInvoker dataWatcherConstructor = Reflection.getConstructor(dataWatcher, entity);
@Override
public void setNamedSpawnPacketDataWatcher(Object packet) {
namedSpawnDataWatcher.set(packet, dataWatcherConstructor.invoke((Object) null));
}
private static final Reflection.FieldAccessor<Integer> spawnType = Reflection.getField(REntity.spawnPacket, int.class, Core.getVersion() > 8 ? 6 : 9);
@Override
public void setSpawnPacketType(Object packet, EntityType type) {
switch(type) {
case PRIMED_TNT:
spawnType.set(packet, 50);
break;
case ARROW:
spawnType.set(packet, 60);
break;
case FIREBALL:
spawnType.set(packet, 63);
break;
}
}
}

Datei anzeigen

@ -19,19 +19,13 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import de.steamwar.fightsystem.FightSystem;
import java.util.function.BiFunction;
public class TechHider8 extends PacketAdapter {
public TechHider8() {
super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK);
}
public class TechHider8 implements BiFunction<byte[], Integer, byte[]> {
@Override
public void onPacketSending(PacketEvent e) {
// no implementation availible
public byte[] apply(byte[] data, Integer primaryBitMask) {
// No implementation availible
return data;
}
}

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.REntity;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Material;
@ -37,6 +38,10 @@ import org.bukkit.event.player.PlayerPickupArrowEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.scoreboard.Team;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.UUID;
public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
private static final Class<?> enumHand = Reflection.getClass("{nms}.EnumHand");
@ -119,4 +124,73 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
public void spawnParticle(World world, String particleName, double x, double y, double z) {
world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1);
}
private static final Class<?> dataWatcherObject = Reflection.getClass("{nms}.DataWatcherObject");
private static final Class<?> dataWatcherRegistry = Reflection.getClass("{nms}.DataWatcherRegistry");
private static final Class<?> dataWatcherSerializer = Reflection.getClass("{nms}.DataWatcherSerializer");
private static final Reflection.ConstructorInvoker dataWatcherObjectConstructor = Reflection.getConstructor(dataWatcherObject, int.class, dataWatcherSerializer);
@Override
public Object getDataWatcherObject(int index, Class<?> type) {
for(Field field : dataWatcherSerializer.getFields()) {
if(type.isAssignableFrom(field.getType()) && type.equals(((ParameterizedType) field.getType().getGenericSuperclass()).getActualTypeArguments()[0])) {
try {
return dataWatcherObjectConstructor.invoke(index, field.get(null));
} catch (IllegalAccessException e) {
throw new SecurityException("Could not get field", e);
}
}
}
throw new SecurityException("Could not find Serializer for " + type.getName());
}
private static final Class<?> item = Reflection.getClass("{nms}.DataWatcher.Item");
private static final Reflection.ConstructorInvoker itemConstructor = Reflection.getConstructor(item, dataWatcherObject, Object.class);
@Override
public Object getDataWatcherItem(Object dwo, Object value) {
return itemConstructor.invoke(dwo, value);
}
private static final Reflection.FieldAccessor<Double> teleportX = Reflection.getField(REntity.teleportPacket, double.class, 0);
private static final Reflection.FieldAccessor<Double> teleportY = Reflection.getField(REntity.teleportPacket, double.class, 1);
private static final Reflection.FieldAccessor<Double> teleportZ = Reflection.getField(REntity.teleportPacket, double.class, 2);
@Override
public void setTeleportPacketPosition(Object packet, double x, double y, double z) {
teleportX.set(packet, x);
teleportY.set(packet, y);
teleportZ.set(packet, z);
}
private static final Reflection.FieldAccessor<UUID> spawnUUID = Reflection.getField(REntity.spawnPacket, UUID.class, 0);
@Override
public void setSpawnPacketUUID(Object packet, UUID uuid) {
spawnUUID.set(packet, uuid);
}
private static final Class<?> enumItemSlot = Reflection.getClass("{nms}.EnumItemSlot");
private static final Reflection.FieldAccessor<?> equipmentSlot = Reflection.getField(REntity.equipmentPacket, enumItemSlot, 1);
private static final Object[] itemSlots = enumItemSlot.getEnumConstants();
@Override
public void setEquipmentPacketSlot(Object packet, String slot) {
switch(slot){
case "HEAD":
equipmentSlot.set(packet, itemSlots[5]);
break;
case "CHEST":
equipmentSlot.set(packet, itemSlots[4]);
break;
case "LEGS":
equipmentSlot.set(packet, itemSlots[3]);
break;
case "FEET":
equipmentSlot.set(packet, itemSlots[2]);
break;
case "OFFHAND":
equipmentSlot.set(packet, itemSlots[1]);
break;
case "MAINHAND":
default:
equipmentSlot.set(packet, itemSlots[0]);
}
}
}

Datei anzeigen

@ -25,9 +25,10 @@ import de.steamwar.core.Core;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.utils.BlockIdWrapper;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.ProtocolAPI;
import de.steamwar.sql.SteamwarUser;
import net.royawesome.jlibnoise.MathHelper;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
@ -46,17 +47,19 @@ public class REntity {
return entities.get(internalId);
}
private static final Object entityStatusWatcher = BountifulWrapper.impl.getDataWatcherObject(0, byte.class);
public static void tickFire() {
entities.forEach((integer, entity) -> {
if(entity.fireTick > 0) {
entity.fireTick--;
if(entity.fireTick == 0) {
ProtocolAPI.broadcastPacket(entity.getDataWatcherPacket(0, (byte)0));
ProtocolAPI.broadcastPacket(entity.getDataWatcherPacket(entityStatusWatcher, (byte)0));
}
}
});
}
private static final Object sneakingDataWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 6 : 0, BlockIdWrapper.impl.getPose(true).getClass());
public static void playerJoins(Player player) {
for(REntity entity : entities.values()){
if(entity.entityType == EntityType.PLAYER){
@ -68,16 +71,14 @@ public class REntity {
}else{
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getSpawnEntityPacket());
}
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getTeleportPacket());
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getHeadRotationPacket());
if(entity.fireTick != 0) {
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(0, (byte) 1));
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(entityStatusWatcher, (byte) 1));
}
if(entity.sneaks) {
if(Core.getVersion() > 12){
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(6, BlockIdWrapper.impl.getPose(true)));
}else{
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(0, (byte) 2));
}
ProtocolAPI.tinyProtocol.sendPacket(player, entity.getDataWatcherPacket(sneakingDataWatcher, BlockIdWrapper.impl.getPose(true)));
}
}
}
@ -196,12 +197,7 @@ public class REntity {
public void sneak(boolean sneaking) {
sneaks = sneaking;
if(Core.getVersion() > 12){
ProtocolAPI.broadcastPacket(getDataWatcherPacket(6, BlockIdWrapper.impl.getPose(sneaking)));
}else{
ProtocolAPI.broadcastPacket(getDataWatcherPacket(0, sneaking ? (byte) 2 : (byte) 0));
}
ProtocolAPI.broadcastPacket(getDataWatcherPacket(sneakingDataWatcher, BlockIdWrapper.impl.getPose(sneaking)));
}
public void setOnFire(boolean perma) {
@ -211,14 +207,15 @@ public class REntity {
fireTick = -1;
}
ProtocolAPI.broadcastPacket(getDataWatcherPacket(0, (byte) 1));
ProtocolAPI.broadcastPacket(getDataWatcherPacket(entityStatusWatcher, (byte) 1));
}
private static final Object bowDrawnWatcher = BountifulWrapper.impl.getDataWatcherObject(Core.getVersion() > 12 ? 7 : 6, byte.class);
public void setBowDrawn(boolean drawn, boolean offHand) {
if(Core.getVersion() > 8){
ProtocolAPI.broadcastPacket(getDataWatcherPacket(Core.getVersion() > 12 ? 7 : 6, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
ProtocolAPI.broadcastPacket(getDataWatcherPacket(bowDrawnWatcher, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0))));
}else{
ProtocolAPI.broadcastPacket(getDataWatcherPacket(0, (byte)0x10));
ProtocolAPI.broadcastPacket(getDataWatcherPacket(entityStatusWatcher, (byte)0x10));
}
}
@ -254,48 +251,31 @@ public class REntity {
return (int)(Math.max(-3.9, Math.min(value, 3.9)) * 8000);
}
private static final Class<?> metadataPacket = Reflection.getClass("{nms}.PacketPlayOutEntityMetadata");
private static final Reflection.ConstructorInvoker metadataConstructor = Reflection.getConstructor(metadataPacket);
private static final Reflection.FieldAccessor<Integer> metadataEntity = Reflection.getField(metadataPacket, int.class, 0);
private static final Reflection.FieldAccessor<List> metadataMetadata = Reflection.getField(metadataPacket, List.class, 0);
private Object getDataWatcherPacket(int index, Object value) {
private Object getDataWatcherPacket(Object dataWatcherObject, Object value) {
Object packet = metadataConstructor.invoke();
metadataEntity.set(packet, entityId);
//TODO 1.9 change
WrappedWatchableObject watchable = new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(index, WrappedDataWatcher.Registry.get(value.getClass())), value);
watchable.setDirtyState(true);
metadataMetadata.set(packet, Collections.singletonList(watchable));
metadataMetadata.set(packet, Collections.singletonList(BountifulWrapper.impl.getDataWatcherItem(dataWatcherObject, value)));
return packet;
}
public static final Class<?> teleportPacket = Reflection.getClass("{nms}.PacketPlayOutEntityTeleport");
private static final Reflection.ConstructorInvoker teleportConstructor = Reflection.getConstructor(teleportPacket);
private static final Reflection.FieldAccessor<Integer> teleportEntity = Reflection.getField(teleportPacket, int.class, 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(){
Object packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_TELEPORT);
fillPositioningPacket(packet, packet.getIntegers());
fillByteRotation(packet);
Object packet = teleportConstructor.invoke();
teleportEntity.set(packet, entityId);
BountifulWrapper.impl.setTeleportPacketPosition(packet, locX, locY, locZ);
teleportYaw.set(packet, yaw);
teleportPitch.set(packet, pitch);
return packet;
}
private void fillPositioningPacket(Object packet, StructureModifier<Integer> ints){
ints.write(0, entityId);
if(Core.getVersion() > 8){
StructureModifier<Double> doubles = packet.getDoubles();
doubles.write(0, locX);
doubles.write(1, locY);
doubles.write(2, locZ);
}else{
ints.write(1, MathHelper.floor(locX * 32));
ints.write(2, MathHelper.floor(locY * 32));
ints.write(3, MathHelper.floor(locZ * 32));
}
}
private void fillByteRotation(Object packet){
StructureModifier<Byte> bytes = packet.getBytes();
bytes.write(0, yaw);
bytes.write(1, pitch);
}
private static final Class<?> headRotationPacket = Reflection.getClass("{nms}.PacketPlayOutEntityHeadRotation");
private static final Reflection.ConstructorInvoker headRotationConstructor = Reflection.getConstructor(headRotationPacket);
private static final Reflection.FieldAccessor<Integer> headRotationEntity = Reflection.getField(headRotationPacket, int.class, 0);
@ -307,65 +287,29 @@ public class REntity {
return packet;
}
public static final Class<?> spawnPacket = Reflection.getClass("{nms}.PacketPlayOutSpawnEntity");
private static final Reflection.ConstructorInvoker spawnConstructor = Reflection.getConstructor(spawnPacket);
private static final Reflection.FieldAccessor<Integer> spawnEntity = Reflection.getField(spawnPacket, int.class, 0);
private Object getSpawnEntityPacket(){
Object packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
StructureModifier<Integer> ints = packet.getIntegers();
fillPositioningPacket(packet, ints);
packet.getUUIDs().write(0, uuid);
if(Core.getVersion() > 8){
packet.getUUIDs().write(0, uuid);
ints.write(1, 0); // dX
ints.write(2, 0); // dY
ints.write(3, 0); // dZ
}
ints.write(4, (int)pitch);
ints.write(5, (int)yaw);
if(Core.getVersion() > 12){
packet.getEntityTypeModifier().write(0, entityType);
}else{
switch(entityType){
case PRIMED_TNT:
ints.write(6, 50);
break;
case ARROW:
ints.write(6, 60);
break;
case FIREBALL:
ints.write(6, 63);
break;
}
}
Object packet = spawnConstructor.invoke();
spawnEntity.set(packet, entityId);
BountifulWrapper.impl.setSpawnPacketUUID(packet, uuid);
FlatteningWrapper.impl.setSpawnPacketType(packet, entityType);
return packet;
}
public static final Class<?> equipmentPacket = Reflection.getClass("{nms}.PacketPlayOutEntityEquipment");
private static final Reflection.ConstructorInvoker equipmentConstructor = Reflection.getConstructor(equipmentPacket);
private static final Reflection.FieldAccessor<Integer> equipmentEntity = Reflection.getField(equipmentPacket, int.class, 0);
private static final Class<?> itemStack = Reflection.getClass("{nms}.ItemStack");
private static final Reflection.FieldAccessor<?> equipmentStack = Reflection.getField(equipmentPacket, itemStack, 0);
private static final Class<?> craftItemStack = Reflection.getClass("{obc}.CraftItemStack");
private static final Reflection.MethodInvoker asNMSCopy = Reflection.getTypedMethod(craftItemStack, "asNMSCopy", itemStack, craftItemStack);
private Object getEquipmentPacket(String slot, ItemStack stack){
Object packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Integer> ints = packet.getIntegers();
ints.write(0, entityId);
if(Core.getVersion() == 8){
switch(slot){
case "MAINHAND":
case "OFFHAND":
ints.write(1, 0);
break;
case "HEAD":
ints.write(1, 4);
break;
case "CHEST":
ints.write(1, 3);
break;
case "LEGS":
ints.write(1, 2);
break;
case "FEET":
default:
ints.write(1, 1);
}
}else{
packet.getItemSlots().write(0, EnumWrappers.ItemSlot.valueOf(slot));
}
packet.getItemModifier().write(0, stack);
Object packet = equipmentConstructor.invoke();
equipmentEntity.set(0, entityId);
BountifulWrapper.impl.setEquipmentPacketSlot(packet, slot);
equipmentStack.set(packet, asNMSCopy.invoke(null, stack));
return packet;
}
@ -373,15 +317,15 @@ public class REntity {
return Fight.playerInfoPacket(Fight.addPlayer, playerInfoData);
}
public static final Class<?> namedSpawnPacket = Reflection.getClass("{nms}.PacketPlayOutNamedEntitySpawn");
private static final Reflection.ConstructorInvoker namedSpawnConstructor = Reflection.getConstructor(namedSpawnPacket);
private static final Reflection.FieldAccessor<Integer> namedSpawnEntity = Reflection.getField(namedSpawnPacket, int.class, 0);
private static final Reflection.FieldAccessor<UUID> namedSpawnUUID = Reflection.getField(namedSpawnPacket, UUID.class, 0);
private Object getNamedSpawnPacket(){
Object packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
StructureModifier<Integer> ints = packet.getIntegers();
fillPositioningPacket(packet, ints);
packet.getUUIDs().write(0, uuid);
fillByteRotation(packet);
if(Core.getVersion() < 13){
packet.getDataWatcherModifier().write(0, new WrappedDataWatcher());
}
Object packet = namedSpawnConstructor.invoke();
namedSpawnEntity.set(packet, entityId);
namedSpawnUUID.set(packet, uuid);
FlatteningWrapper.impl.setNamedSpawnPacketDataWatcher(packet);
return packet;
}
}

Datei anzeigen

@ -26,6 +26,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.scoreboard.Team;
import java.util.UUID;
public class BountifulWrapper {
private BountifulWrapper() {}
@ -49,5 +51,11 @@ public class BountifulWrapper {
Listener newHandSwapRecorder();
void spawnParticle(World world, String particleName, double x, double y, double z);
Object getDataWatcherObject(int index, Class<?> type);
Object getDataWatcherItem(Object dataWatcherObject, Object value);
void setTeleportPacketPosition(Object packet, double x, double y, double z);
void setSpawnPacketUUID(Object packet, UUID uuid);
void setEquipmentPacketSlot(Object packet, String slot);
}
}

Datei anzeigen

@ -24,6 +24,7 @@ import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -49,5 +50,8 @@ public class FlatteningWrapper {
void forceLoadChunk(World world, int cX, int cZ);
boolean checkPistonMoving(Block block);
void setNamedSpawnPacketDataWatcher(Object packet);
void setSpawnPacketType(Object packet, EntityType type);
}
}