Sneaking is Working!
Dieser Commit ist enthalten in:
Ursprung
17c0995f24
Commit
7c35ac8bea
@ -32,6 +32,7 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.metadata.EntityMetadataStore;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
@ -112,29 +113,14 @@ public abstract class REntity {
|
||||
}
|
||||
}
|
||||
|
||||
private static Method setPoseMethod = null;
|
||||
|
||||
public void sneak(boolean sneaking) {
|
||||
try {
|
||||
if(setPoseMethod == null) {
|
||||
setPoseMethod = Entity.class.getDeclaredMethod("setPose", EntityPose.class);
|
||||
setPoseMethod.setAccessible(true);
|
||||
}
|
||||
setPoseMethod.invoke(entity, sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
/*System.out.println("Let " + entity.getName() + " sneak " + sneaking+ " | " + entity.getClass());
|
||||
DataWatcher dataWatcher = entity.getDataWatcher();
|
||||
DataWatcher dataWatcher = new DataWatcher(null);
|
||||
|
||||
dataWatcher.set(new DataWatcherObject<>(6, DataWatcherRegistry.s), sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
|
||||
//dataWatcher.set(new DataWatcherObject<>(0, DataWatcherRegistry.a), Byte.valueOf((byte) (sneaking?2:0)));*/
|
||||
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
|
||||
dataWatcher.register(dataWatcherObject, sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), entity.getDataWatcher(), false);
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
|
||||
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren