Add Sneaking
Add HeadYaw Add Animation
Dieser Commit ist enthalten in:
Ursprung
ff4332e064
Commit
1a1bd8fb54
@ -22,6 +22,11 @@ public class FightserverConnection implements PacketSource {
|
|||||||
return inputStream.readByte();
|
return inputStream.readByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rBoolean() throws IOException {
|
||||||
|
return inputStream.readBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short rShort() throws IOException {
|
public short rShort() throws IOException {
|
||||||
return inputStream.readShort();
|
return inputStream.readShort();
|
||||||
|
@ -31,7 +31,6 @@ class PacketProcessor {
|
|||||||
if(user == null)
|
if(user == null)
|
||||||
throw new IOException("Unknown user " + userId);
|
throw new IOException("Unknown user " + userId);
|
||||||
|
|
||||||
System.out.println("Player " + user.getUserName() + " spawned!");
|
|
||||||
new RPlayer(user.getUUID(), user.getUserName(), entityId);
|
new RPlayer(user.getUUID(), user.getUserName(), entityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,8 +41,9 @@ class PacketProcessor {
|
|||||||
double locZ = source.rDouble();
|
double locZ = source.rDouble();
|
||||||
float pitch = source.rFloat();
|
float pitch = source.rFloat();
|
||||||
float yaw = source.rFloat();
|
float yaw = source.rFloat();
|
||||||
|
byte headYaw = source.rByte();
|
||||||
|
|
||||||
REntity.getEntity(entityId).move(locX, locY, locZ, yaw, pitch);
|
REntity.getEntity(entityId).move(locX, locY, locZ, yaw, pitch, headYaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void entityDespawns() throws IOException{
|
private void entityDespawns() throws IOException{
|
||||||
@ -52,6 +52,20 @@ class PacketProcessor {
|
|||||||
REntity.getEntity(entityId).remove();
|
REntity.getEntity(entityId).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void entitySneak() throws IOException {
|
||||||
|
int entityId = source.rInt();
|
||||||
|
boolean sneaking = source.rBoolean();
|
||||||
|
|
||||||
|
REntity.getEntity(entityId).sneak(sneaking);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void entityAnimation() throws IOException {
|
||||||
|
int entityId = source.rInt();
|
||||||
|
byte animation = source.rByte();
|
||||||
|
|
||||||
|
REntity.getEntity(entityId).animation(animation);
|
||||||
|
}
|
||||||
|
|
||||||
private void send(ChatMessageType type) throws IOException {
|
private void send(ChatMessageType type) throws IOException {
|
||||||
String message = source.rString();
|
String message = source.rString();
|
||||||
|
|
||||||
@ -91,6 +105,12 @@ class PacketProcessor {
|
|||||||
case 0x02:
|
case 0x02:
|
||||||
entityDespawns();
|
entityDespawns();
|
||||||
break;
|
break;
|
||||||
|
case 0x03:
|
||||||
|
entitySneak();
|
||||||
|
break;
|
||||||
|
case 0x04:
|
||||||
|
entityAnimation();
|
||||||
|
break;
|
||||||
case 0x30:
|
case 0x30:
|
||||||
block();
|
block();
|
||||||
break;
|
break;
|
||||||
@ -109,7 +129,7 @@ class PacketProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (EOFException e) {
|
} catch (EOFException e) {
|
||||||
Bukkit.getLogger().log(Level.INFO, "End of file", e);
|
Bukkit.getLogger().log(Level.INFO, "The FightServer is offline");
|
||||||
source.close();
|
source.close();
|
||||||
} catch(IOException e){
|
} catch(IOException e){
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not recieve packet", e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not recieve packet", e);
|
||||||
|
@ -5,6 +5,7 @@ import java.io.IOException;
|
|||||||
public interface PacketSource {
|
public interface PacketSource {
|
||||||
|
|
||||||
byte rByte() throws IOException;
|
byte rByte() throws IOException;
|
||||||
|
boolean rBoolean() throws IOException;
|
||||||
short rShort() throws IOException;
|
short rShort() throws IOException;
|
||||||
int rInt() throws IOException;
|
int rInt() throws IOException;
|
||||||
long rLong() throws IOException;
|
long rLong() throws IOException;
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package de.steamwar.spectatesystem.elements;
|
package de.steamwar.spectatesystem.elements;
|
||||||
|
|
||||||
import net.minecraft.server.v1_15_R1.Entity;
|
import net.minecraft.server.v1_15_R1.*;
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityDestroy;
|
|
||||||
import net.minecraft.server.v1_15_R1.PacketPlayOutEntityTeleport;
|
|
||||||
import net.minecraft.server.v1_15_R1.PlayerConnection;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -39,12 +36,15 @@ public abstract class REntity {
|
|||||||
return entities.get(internalId);
|
return entities.get(internalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(double x, double y, double z, float yaw, float pitch){
|
public void move(double x, double y, double z, float yaw, float pitch, byte headYaw){
|
||||||
entity.setLocation(x, y, z, yaw, pitch);
|
entity.setLocation(x, y, z, yaw, pitch);
|
||||||
|
entity.setHeadRotation(headYaw);
|
||||||
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(entity);
|
PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(entity);
|
||||||
|
PacketPlayOutEntityHeadRotation packetHeadRotation = new PacketPlayOutEntityHeadRotation(entity, headYaw);
|
||||||
for(Player player : Bukkit.getOnlinePlayers()){
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
||||||
connection.sendPacket(packet);
|
connection.sendPacket(packet);
|
||||||
|
connection.sendPacket(packetHeadRotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +57,23 @@ public abstract class REntity {
|
|||||||
entities.remove(internalId);
|
entities.remove(internalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sneak(boolean sneaking) {
|
||||||
|
entity.setSneaking(sneaking);
|
||||||
|
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(0, entity.getDataWatcher(), sneaking);
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
|
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
||||||
|
connection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void animation(byte animation) {
|
||||||
|
PacketPlayOutAnimation packet = new PacketPlayOutAnimation(entity, animation);
|
||||||
|
for(Player player : Bukkit.getOnlinePlayers()){
|
||||||
|
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
|
||||||
|
connection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void sendToPlayer(Player player){
|
private void sendToPlayer(Player player){
|
||||||
spawnEntity(((CraftPlayer)player).getHandle().playerConnection);
|
spawnEntity(((CraftPlayer)player).getHandle().playerConnection);
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren