use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class SpawnPlayerMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(SpawnPlayerMessage packet) {
if (!this.getTranslator().cachedEntityIDs.contains(packet.id)) {
//Add to the spawned entity list
this.getTranslator().cachedEntityIDs.add(packet.id);
}
//Register this id as a player
this.getTranslator().cachedPlayerEntities.add(packet.id);
AddPlayerPacket pkAddPlayer = new AddPlayerPacket();
pkAddPlayer.uuid = packet.getUuid();
pkAddPlayer.eid = packet.getId();
pkAddPlayer.username = this.getSession().getServer().getPlayer(packet.getUuid()).getDisplayName();
pkAddPlayer.x = (float) packet.getX() / 32;
pkAddPlayer.y = (float) packet.getY() / 32;
pkAddPlayer.z = (float) packet.getZ() / 32;
//return (int) (((loc.getYaw() % 360) / 360) * 256);
pkAddPlayer.speedX = 0.0f;
pkAddPlayer.speedY = 0.0f;
pkAddPlayer.speedZ = 0.0f;
pkAddPlayer.yaw = ((float) packet.getRotation() / 256) * 360;
pkAddPlayer.pitch = ((float) packet.getPitch() / 256) * 360;
//pkAddPlayer.metadata = EntityMetaData.getMetaDataFromPlayer((GlowPlayer) this.getSession().getPlayer().getWorld().getEntityManager().getEntity(packet.getId())); TODO Fix the metadata, this one of the reasons why skins weren't working properly!
PlayerListPacket lst = new PlayerListPacket(new PlayerListPacket.PlayerInfo(packet.getUuid(), packet.getId(), pkAddPlayer.username, true, false, DefaultSkin.getDefaultSkin()));
return new PEPacket[] { pkAddPlayer, lst };
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class EntityMetadataMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(EntityMetadataMessage packet) {
if (!this.getTranslator().cachedEntityIDs.contains(packet.id)) {
//Not spawned yet, let's create them
if (this.getTranslator().cachedSpawnObjects.containsKey(packet.id)) {
//Spawn it :)
SpawnObjectMessage msgObj = this.getTranslator().cachedSpawnObjects.get(packet.id);
switch(msgObj.type) {
case //Dropped Item
2:
AddItemEntityPacket pkAddItemEntity = new AddItemEntityPacket();
pkAddItemEntity.eid = msgObj.id;
pkAddItemEntity.item = new PEInventorySlot((short) (((ItemStack) packet.entries.get(0).value).getTypeId() & 0xFFFF), (byte) (((ItemStack) packet.entries.get(0).value).getAmount() & 0xFF), (short) (((ItemStack) packet.entries.get(0).value).getDurability() & 0xFFFF));
pkAddItemEntity.x = (float) msgObj.velX / 32;
pkAddItemEntity.y = (float) msgObj.velY / 32;
pkAddItemEntity.z = (float) msgObj.velZ / 32;
return new PEPacket[] { pkAddItemEntity };
}
//Remove it
this.getTranslator().cachedSpawnObjects.remove(packet.id);
} else {
return null;
}
}
return null;
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class EntityVelocityMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(EntityVelocityMessage packet) {
SetEntityMotionPacket pkMotion = new SetEntityMotionPacket();
SetEntityMotionPacket.EntityMotionData data = new SetEntityMotionPacket.EntityMotionData();
data.eid = packet.id;
data.motionX = (float) packet.velocityX / 32;
data.motionY = (float) packet.velocityY / 32;
data.motionZ = (float) packet.velocityZ / 32;
pkMotion.motions = new SetEntityMotionPacket.EntityMotionData[] { data };
return new PEPacket[] { pkMotion };
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class HealthMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(HealthMessage packet) {
int h = (int) packet.health;
if (h <= 0) {
//DEAD
SetHealthPacket pk1 = new SetHealthPacket(h);
RespawnPacket pk2 = new RespawnPacket();
pk2.x = (float) getTranslator().getSession().getServer().getWorlds().get(0).getSpawnLocation().getX();
pk2.y = (float) getTranslator().getSession().getServer().getWorlds().get(0).getSpawnLocation().getY();
pk2.z = (float) getTranslator().getSession().getServer().getWorlds().get(0).getSpawnLocation().getZ();
return new PEPacket[] { pk1, pk2 };
} else {
SetHealthPacket pk = new SetHealthPacket(h);
return new PEPacket[] { pk };
}
}
use of org.dragonet.net.packet.minecraft.PEPacket in project Dragonet-Legacy by DragonetMC.
the class MultiBlockChangeMessageTranslator method handleSpecific.
@Override
public PEPacket[] handleSpecific(MultiBlockChangeMessage packet) {
UpdateBlockPacket pkBC = new UpdateBlockPacket();
pkBC.records = new UpdateBlockPacket.UpdateBlockRecord[packet.records.size()];
//PEPacket[] packets = new PEPacket[msgMBC.records.size()];
int i = 0;
for (BlockChangeMessage msgBC : packet.records) {
//packets[i] = this.translateToPE(msgBC)[0];
pkBC.records[i] = new UpdateBlockPacket.UpdateBlockRecord();
pkBC.records[i].x = msgBC.x;
pkBC.records[i].z = msgBC.z;
pkBC.records[i].y = (byte) (msgBC.y & 0xFF);
pkBC.records[i].block = (byte) (this.getTranslator().getItemTranslator().translateToPE(msgBC.type >> 4) & 0xFF);
pkBC.records[i].meta = UpdateBlockPacket.FLAG_ALL_PRIORITY;
i++;
}
return new PEPacket[] { pkBC };
}
Aggregations