Reordering a lot of Stuff
Dieser Commit ist enthalten in:
Ursprung
2aad8cba58
Commit
aacff6b895
@ -418,6 +418,7 @@ class PacketProcessor {
|
||||
break;
|
||||
case (byte) 0xFF:
|
||||
//Tick
|
||||
execSync(() -> REntity.tickFire());
|
||||
if(!source.async())
|
||||
tickFinished = true;
|
||||
break;
|
||||
|
@ -31,12 +31,32 @@ import java.util.Map;
|
||||
|
||||
public abstract class REntity {
|
||||
|
||||
public static void tickFire() {
|
||||
getEntities().forEach((integer, entity) -> {
|
||||
if(entity.fireTick > 0)
|
||||
entity.fireTick--;
|
||||
if(entity.fireTick == 0) {
|
||||
DataWatcher dataWatcher = new DataWatcher(null);
|
||||
|
||||
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
|
||||
dataWatcher.register(dataWatcherObject, (byte) 0);
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
entity.sendDataWatcher(dataWatcher);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected static final WorldServer world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||
|
||||
private static final Map<Integer, REntity> entities = new HashMap<>();
|
||||
|
||||
private static Map<Integer, REntity> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
private final int internalId;
|
||||
protected final Entity entity;
|
||||
private int fireTick;
|
||||
|
||||
protected REntity(int internalId, Entity entity){
|
||||
this.internalId = internalId;
|
||||
@ -55,6 +75,27 @@ public abstract class REntity {
|
||||
for(REntity entity : entities.values()){
|
||||
entity.sendToPlayer(player);
|
||||
entity.sendLocation(player);
|
||||
if(entity.fireTick != 0) {
|
||||
DataWatcher dataWatcher = new DataWatcher(null);
|
||||
|
||||
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
|
||||
dataWatcher.register(dataWatcherObject, (byte) 1);
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.entity.getId(), dataWatcher, false);
|
||||
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
if(entity.entity.isSneaking()) {
|
||||
DataWatcher dataWatcher = new DataWatcher(null);
|
||||
|
||||
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
|
||||
dataWatcher.register(dataWatcherObject, EntityPose.CROUCHING);
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.entity.getId(), dataWatcher, false);
|
||||
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,16 +153,15 @@ public abstract class REntity {
|
||||
dataWatcher.register(dataWatcherObject, sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
|
||||
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
sendDataWatcher(dataWatcher);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean perma) {
|
||||
if(!perma)
|
||||
entity.setOnFire(21, false);
|
||||
if(!perma) {
|
||||
fireTick = 21;
|
||||
} else {
|
||||
fireTick = -1;
|
||||
}
|
||||
|
||||
DataWatcher dataWatcher = new DataWatcher(null);
|
||||
|
||||
@ -129,11 +169,7 @@ public abstract class REntity {
|
||||
dataWatcher.register(dataWatcherObject, (byte) 1);
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
|
||||
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
sendDataWatcher(dataWatcher);
|
||||
}
|
||||
|
||||
public void setBowDrawn(boolean drawn, int hand) {
|
||||
@ -143,11 +179,7 @@ public abstract class REntity {
|
||||
dataWatcher.register(dataWatcherObject, (byte) ((drawn?1:0) + (hand * 2)));
|
||||
dataWatcher.markDirty(dataWatcherObject);
|
||||
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
|
||||
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
sendDataWatcher(dataWatcher);
|
||||
}
|
||||
|
||||
public void damage() {
|
||||
@ -186,4 +218,12 @@ public abstract class REntity {
|
||||
protected void spawnEntity(PlayerConnection connection){
|
||||
connection.sendPacket(new PacketPlayOutSpawnEntity(entity));
|
||||
}
|
||||
|
||||
private void sendDataWatcher(DataWatcher dataWatcher) {
|
||||
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
|
||||
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ public class RPlayer extends REntity {
|
||||
|
||||
public RPlayer(UUID uuid, String name, int internalId){
|
||||
super(internalId, createPlayer(uuid, name));
|
||||
//TODO Damage
|
||||
team.addEntry(entity.getName());
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren