net.minecraft.entity.boss.dragon.phase.PhaseList Java Examples

The following examples show how to use net.minecraft.entity.boss.dragon.phase.PhaseList. 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: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTick(LivingEvent.LivingUpdateEvent event) {
	EntityLivingBase e = event.getEntityLiving();
	if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) {
		boolean shouldFreeze = true;
		if(e.isDead || e.getHealth() <= 0) {
			shouldFreeze = false;
		}
		if(e instanceof EntityDragon && ((EntityDragon) e).getPhaseManager().getCurrentPhase().getType() == PhaseList.DYING) {
			shouldFreeze = false;
		}
		if(shouldFreeze) {
			handleImportantEntityTicks(e);
			event.setCanceled(true);
		}
	}
}
 
Example #2
Source File: MetaTileEntityMagicEnergyAbsorber.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateConnectedCrystals() {
    this.connectedCrystalsIds.clear();
    final double maxDistance = 64 * 64;
    List<EntityEnderCrystal> enderCrystals = Arrays.stream(BiomeEndDecorator.getSpikesForWorld(getWorld()))
        .flatMap(endSpike -> getWorld().getEntitiesWithinAABB(EntityEnderCrystal.class, endSpike.getTopBoundingBox()).stream())
        .filter(crystal -> crystal.getDistanceSq(getPos()) < maxDistance)
        .collect(Collectors.toList());

    for (EntityEnderCrystal entityEnderCrystal : enderCrystals) {
        BlockPos beamTarget = entityEnderCrystal.getBeamTarget();
        if (beamTarget == null) {
            //if beam target is null, set ourselves as beam target
            entityEnderCrystal.setBeamTarget(getPos());
            this.connectedCrystalsIds.add(entityEnderCrystal.getEntityId());
        } else if (beamTarget.equals(getPos())) {
            //if beam target is ourselves, just add it to list
            this.connectedCrystalsIds.add(entityEnderCrystal.getEntityId());
        }
    }

    for (EntityDragon entityDragon : getWorld().getEntities(EntityDragon.class, EntitySelectors.IS_ALIVE)) {
        if (entityDragon.healingEnderCrystal != null && connectedCrystalsIds.contains(entityDragon.healingEnderCrystal.getEntityId())) {
            //if dragon is healing from crystal we draw energy from, reset it's healing crystal
            entityDragon.healingEnderCrystal = null;
            //if dragon is holding pattern, than deal damage and set it's phase to attack ourselves
            if (entityDragon.getPhaseManager().getCurrentPhase().getType() == PhaseList.HOLDING_PATTERN) {
                entityDragon.attackEntityFrom(DamageSource.causeExplosionDamage((EntityLivingBase) null), 10.0f);
                entityDragon.getPhaseManager().setPhase(PhaseList.CHARGING_PLAYER);
                ((PhaseChargingPlayer) entityDragon.getPhaseManager().getCurrentPhase()).setTarget(new Vec3d(getPos()));
            }
        }
    }
}
 
Example #3
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void handleImportantEntityTicks(EntityLivingBase e) {
	if (e.hurtTime > 0) {
		e.hurtTime--;
	}
	if (e.hurtResistantTime > 0) {
		e.hurtResistantTime--;
	}

	e.prevLimbSwingAmount = e.limbSwingAmount;
	e.prevRenderYawOffset = e.renderYawOffset;
	e.prevRotationPitch = e.rotationPitch;
	e.prevRotationYaw = e.rotationYaw;
	e.prevRotationYawHead = e.rotationYawHead;
	e.prevSwingProgress = e.swingProgress;
	e.prevDistanceWalkedModified = e.distanceWalkedModified;
	e.prevCameraPitch = e.cameraPitch;

	if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) {
		PotionEffect pe = e.getActivePotionEffect(ModPotions.TIME_SLOW);
		if (!pe.onUpdate(e)) {
			if (!e.world.isRemote) {
				e.removePotionEffect(ModPotions.TIME_SLOW);
			}
		}
	}

	if(e instanceof EntityDragon) {
		IPhase phase = ((EntityDragon) e).getPhaseManager().getCurrentPhase();
		if(phase.getType() != PhaseList.HOLDING_PATTERN && phase.getType() != PhaseList.DYING) {
			((EntityDragon) e).getPhaseManager().setPhase(PhaseList.HOLDING_PATTERN);
		}
	}
}
 
Example #4
Source File: CraftEnderDragon.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Phase getBukkitPhase(PhaseList phase) {
    return Phase.values()[phase.getId()];
}
 
Example #5
Source File: CraftEnderDragon.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static PhaseList getMinecraftPhase(Phase phase) {
    return PhaseList.getById(phase.ordinal());
}