use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class StateChangeMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(StateChangeMessage packet) {
if (packet.reason == StateChangeMessage.Reason.GAMEMODE.ordinal()) {
if (this.getSession().getPlayer() == null) {
return null;
}
StartGamePacket pkStartGame = new StartGamePacket();
pkStartGame.eid = this.getSession().getPlayer().getEntityId();
pkStartGame.gamemode = ((int) packet.value) & 0x1;
pkStartGame.seed = 0;
pkStartGame.generator = 1;
pkStartGame.spawnX = this.getSession().getPlayer().getWorld().getSpawnLocation().getBlockX();
pkStartGame.spawnY = this.getSession().getPlayer().getWorld().getSpawnLocation().getBlockY();
pkStartGame.spawnZ = this.getSession().getPlayer().getWorld().getSpawnLocation().getBlockZ();
pkStartGame.x = (float) this.getSession().getPlayer().getLocation().getX();
pkStartGame.y = (float) this.getSession().getPlayer().getLocation().getY();
pkStartGame.z = (float) this.getSession().getPlayer().getLocation().getZ();
return new PEPacket[] { pkStartGame };
}
return null;
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class CloseWindowMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(CloseWindowMessage packet) {
if (packet.id != 0) {
this.getTranslator().cachedWindowType[packet.id & 0xFF] = -1;
}
WindowClosePacket pkCloseWindow = new WindowClosePacket();
pkCloseWindow.windowID = (byte) (packet.id & 0xFF);
getSession().getOpenedWindows().remove(packet.id);
return new PEPacket[] { pkCloseWindow };
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class CollectItemMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(CollectItemMessage packet) {
PickUpItemPacket pkPickUp = new PickUpItemPacket();
pkPickUp.target = packet.collector;
pkPickUp.eid = packet.id;
return new PEPacket[] { pkPickUp };
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class DestroyEntitiesMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(DestroyEntitiesMessage packet) {
//Remove from the list
this.getTranslator().cachedEntityIDs.removeAll(packet.ids);
int[] ids = ArrayUtils.toPrimitive(packet.ids.toArray(new Integer[0]));
ArrayList<PEPacket> pkRemoveEntity = new ArrayList<>();
for (int i = 0; i < ids.length; i++) {
if (!this.getTranslator().cachedPlayerEntities.contains(ids[i])) {
PEPacket tmp = new RemoveEntityPacket();
((RemoveEntityPacket) tmp).eid = ids[i];
pkRemoveEntity.add(tmp);
} else {
GlowPlayer glow = ((GlowPlayer) this.getSession().getPlayer().getWorld().getEntityManager().getEntity(ids[i]));
PEPacket tmp = new RemovePlayerPacket();
((RemovePlayerPacket) tmp).uuid = glow.getUniqueId();
((RemovePlayerPacket) tmp).eid = ids[i];
this.getTranslator().cachedPlayerEntities.remove(new Integer(ids[i]));
PlayerListPacket pl = new PlayerListPacket(new PlayerListPacket.PlayerInfo(glow.getUniqueId(), -1, null, true, true, null));
pl.isAdding = false;
pkRemoveEntity.add(tmp);
pkRemoveEntity.add(pl);
}
}
return pkRemoveEntity.toArray(new PEPacket[0]);
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class EntityEffectMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(EntityEffectMessage packet) {
MobEffectPacket pk = new MobEffectPacket();
pk.eid = packet.id;
pk.action = MobEffectPacket.EffectAction.ADD;
PocketPotionEffect effect = PocketPotionEffect.getByID(packet.effect);
effect.setAmpilifier(packet.amplifier);
effect.setParticles(!packet.hideParticles);
effect.setDuration(packet.duration);
pk.effect = effect;
return new PEPacket[] { pk };
}
Aggregations