use of com.bewitchment.common.entity.EntityBatSwarm in project Bewitchment by Um-Mitternacht.
the class VampireAbilityHandler method onHotbarAbilityToggled.
@SubscribeEvent
public void onHotbarAbilityToggled(HotbarActionTriggeredEvent evt) {
ITransformationData data = evt.player.getCapability(CapabilityTransformationData.CAPABILITY, null);
if (evt.action == ModAbilities.NIGHT_VISION) {
boolean newStatus = !data.isNightVisionActive();
data.setNightVision(newStatus);
if (evt.player instanceof EntityPlayerMP) {
NetworkHandler.HANDLER.sendTo(new NightVisionStatus(newStatus), (EntityPlayerMP) evt.player);
}
} else if (evt.action == ModAbilities.DRAIN_BLOOD) {
RayTraceResult rt = RayTraceHelper.rayTraceResult(evt.player, RayTraceHelper.fromLookVec(evt.player, evt.player.getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue()), true, true);
if (rt != null && rt.typeOfHit == Type.ENTITY) {
if (rt.entityHit instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase) rt.entityHit;
if (canDrainBloodFrom(evt.player, entity)) {
TransformationHelper.drainBloodFromEntity(evt.player, entity);
} else {
entity.attackEntityAsMob(evt.player);
}
}
}
} else if (evt.action == ModAbilities.BAT_SWARM) {
if (!(evt.player.getRidingEntity() instanceof EntityBatSwarm) && BewitchmentAPI.getAPI().addVampireBlood(evt.player, -150)) {
EntityBatSwarm bs = new EntityBatSwarm(evt.player.world);
float pitch = (Math.abs(evt.player.rotationPitch) < 7) ? 0 : evt.player.rotationPitch;
bs.setPositionAndRotation(evt.player.posX, evt.player.posY + evt.player.getEyeHeight(), evt.player.posZ, evt.player.rotationYaw, pitch);
evt.player.world.spawnEntity(bs);
evt.player.startRiding(bs);
}
}
}
Aggregations