Dieser Commit ist enthalten in:
Ursprung
d890451602
Commit
34d841324c
@ -21,10 +21,7 @@ package de.steamwar.entity;
|
|||||||
|
|
||||||
import com.comphenix.tinyprotocol.Reflection;
|
import com.comphenix.tinyprotocol.Reflection;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import de.steamwar.core.BountifulWrapper;
|
import de.steamwar.core.*;
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.core.FlatteningWrapper;
|
|
||||||
import de.steamwar.core.ProtocolWrapper;
|
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
import it.unimi.dsi.fastutil.ints.IntList;
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -181,11 +178,9 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> chatComponentText = Reflection.getClass("{nms}.ChatComponentText"); //TODO multiversioning
|
|
||||||
private static final Reflection.ConstructorInvoker chatComponentTextConstructor = Reflection.getConstructor(chatComponentText, String.class); //TODO multiversioning
|
|
||||||
public void setDisplayName(String displayName) {
|
public void setDisplayName(String displayName) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
server.updateEntity(this, getDataWatcherPacket(nameWatcher, displayName != null ? Optional.of(chatComponentTextConstructor.invoke(displayName)) : Optional.empty()));
|
server.updateEntity(this, getDataWatcherPacket(nameWatcher, displayName != null ? Optional.of(ChatWrapper.impl.stringToChatComponent(displayName)) : Optional.empty()));
|
||||||
server.updateEntity(this, getDataWatcherPacket(nameVisibleWatcher, displayName != null));
|
server.updateEntity(this, getDataWatcherPacket(nameVisibleWatcher, displayName != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +256,7 @@ public class REntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(displayName != null) {
|
if(displayName != null) {
|
||||||
packetSink.accept(getDataWatcherPacket(nameWatcher, Optional.of(chatComponentTextConstructor.invoke(displayName))));
|
packetSink.accept(getDataWatcherPacket(nameWatcher, Optional.of(ChatWrapper.impl.stringToChatComponent(displayName))));
|
||||||
packetSink.accept(getDataWatcherPacket(nameVisibleWatcher, true));
|
packetSink.accept(getDataWatcherPacket(nameVisibleWatcher, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,7 +344,7 @@ public class REntity {
|
|||||||
private Object getEquipmentPacket(Object slot, ItemStack stack){
|
private Object getEquipmentPacket(Object slot, ItemStack stack){
|
||||||
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
|
Object packet = Reflection.newInstance(ProtocolWrapper.equipmentPacket);
|
||||||
equipmentEntity.set(packet, entityId);
|
equipmentEntity.set(packet, entityId);
|
||||||
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack)); //TODO grouped send (1.8 incompatible)
|
ProtocolWrapper.impl.setEquipmentPacketStack(packet, slot, asNMSCopy.invoke(null, stack));
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,14 +375,14 @@ public class REntity {
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> spawnLivingPacket = Reflection.getClass("{nms}.PacketPlayOutSpawnEntityLiving"); //TODO multiversioning
|
private static final Class<?> spawnLivingPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutSpawnEntityLiving"); //TODO not existing in 1.19
|
||||||
private static final Reflection.ConstructorInvoker spawnLivingPacketConstructor = Reflection.getConstructor(spawnLivingPacket); //TODO multiversioning
|
private static final Reflection.ConstructorInvoker spawnLivingPacketConstructor = Reflection.getConstructor(spawnLivingPacket); //TODO multiversioning
|
||||||
private static final Reflection.FieldAccessor<Integer> spawnLivingEntityId = Reflection.getField(spawnLivingPacket, int.class, 0); //TODO multiversioning
|
private static final Reflection.FieldAccessor<Integer> spawnLivingEntityId = Reflection.getField(spawnLivingPacket, int.class, 0); //TODO multiversioning
|
||||||
private static final Reflection.FieldAccessor<UUID> spawnLivingUUID = Reflection.getField(spawnLivingPacket, UUID.class, 0); //TODO multiversioning
|
private static final Reflection.FieldAccessor<UUID> spawnLivingUUID = Reflection.getField(spawnLivingPacket, UUID.class, 0); //TODO not existing in 1.8
|
||||||
private static final Reflection.FieldAccessor<Integer> spawnLivingEntityType = Reflection.getField(spawnLivingPacket, int.class, 1); //TODO multiversioning
|
private static final Reflection.FieldAccessor<Integer> spawnLivingEntityType = Reflection.getField(spawnLivingPacket, int.class, 1); //TODO multiversioning
|
||||||
private static final Reflection.FieldAccessor<Double> spawnLivingEntityX = Reflection.getField(spawnLivingPacket, double.class, 0); //TODO multiversioning
|
private static final Reflection.FieldAccessor<Double> spawnLivingEntityX = Reflection.getField(spawnLivingPacket, double.class, 0); //TODO int in 1.8
|
||||||
private static final Reflection.FieldAccessor<Double> spawnLivingEntityY = Reflection.getField(spawnLivingPacket, double.class, 1); //TODO multiversioning
|
private static final Reflection.FieldAccessor<Double> spawnLivingEntityY = Reflection.getField(spawnLivingPacket, double.class, 1); //TODO int in 1.8
|
||||||
private static final Reflection.FieldAccessor<Double> spawnLivingEntityZ = Reflection.getField(spawnLivingPacket, double.class, 2); //TODO multiversioning
|
private static final Reflection.FieldAccessor<Double> spawnLivingEntityZ = Reflection.getField(spawnLivingPacket, double.class, 2); //TODO int in 1.8
|
||||||
private Object getSpawnLivingEntityPacket() {
|
private Object getSpawnLivingEntityPacket() {
|
||||||
Object packet = spawnLivingPacketConstructor.invoke();
|
Object packet = spawnLivingPacketConstructor.invoke();
|
||||||
spawnLivingEntityId.set(packet, entityId);
|
spawnLivingEntityId.set(packet, entityId);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren