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