Skip to content

Instantly share code, notes, and snippets.

@t81lal
Last active August 29, 2015 14:14
Show Gist options
  • Save t81lal/29434362657b3946de6e to your computer and use it in GitHub Desktop.
Save t81lal/29434362657b3946de6e to your computer and use it in GitHub Desktop.
Object and Living entity spawn packets
case 0x0E: { // PacketPS0ESpawnObject
PacketPS0ESpawnObject pso = (PacketPS0ESpawnObject) p;
DefaultMinecraftWorld world = context.getWorld();
ObjectEntity objectEntity = world.getObjectEntityFactory().create(pso.getTypeId(), world, pso.getEntityId());
objectEntity.setLocation(pso.getX(), pso.getY(), pso.getZ());
objectEntity.setPitch(pso.getPitch());
objectEntity.setYaw(pso.getYaw());
objectEntity.setMotion(pso.getMotX(), pso.getMotY(), pso.getMotZ());
world.spawnEntity(objectEntity);
bus.dispatch(new ObjectEntitySpawnEvent(objectEntity));
reak;
}
case 0x0F: { // PacketPS0FSpawnMob
PacketPS0FSpawnMob psm = (PacketPS0FSpawnMob) p;
DefaultMinecraftWorld world = context.getWorld();
LivingEntity livingEntity = world.getLivingEntityFactory().create(psm.getTypeId(), world, psm.getEntityId());
livingEntity.setLocation(psm.getX(), psm.getY(), psm.getZ());
livingEntity.setPitch(psm.getPitch());
livingEntity.setYaw(psm.getYaw());
livingEntity.setHeadYaw(psm.getHeadYaw());
livingEntity.setMotion(psm.getMotionX(), psm.getMotionY(), psm.getMotionZ());
world.spawnEntity(livingEntity);
bus.dispatch(new LivingEntitySpawnEvent(livingEntity));
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment