Java Code Examples for net.minecraft.entity.player.EntityPlayer#getLookVec()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#getLookVec() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 6 votes |
@SubscribeEvent public void entityHurtEvent(LivingHurtEvent event) { if (!EtFuturum.enableDmgIndicator) return; int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F); if (amount <= 0) return; // If the attacker is a player spawn the hearts aligned and facing it if (event.source instanceof EntityDamageSource) { EntityDamageSource src = (EntityDamageSource) event.source; Entity attacker = src.getSourceOfDamage(); if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) { EntityPlayer player = (EntityPlayer) attacker; Vec3 look = player.getLookVec(); look.rotateAroundY((float) Math.PI / 2); for (int i = 0; i < amount; i++) { double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord; double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05; double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord; EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64)); } } } }