use of com.teamwizardry.wizardry.common.module.shapes.IShapeOverrides in project Wizardry by TeamWizardry.
the class EntitySpellProjectile method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (isDead)
return;
SpellRing spellRing = getSpellRing();
SpellData spellData = getSpellData();
if (spellRing == null || spellData == null) {
setDead();
world.removeEntity(this);
return;
}
if (world.isRemote && doesRender()) {
ClientRunnable.run(new ClientRunnable() {
@Override
@SideOnly(Side.CLIENT)
public void runIfClient() {
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
if (overrides.onRenderProjectile(world, spellData, spellRing))
return;
ParticleBuilder glitter = new ParticleBuilder(10);
glitter.setRender(new ResourceLocation(Wizardry.MODID, NBTConstants.MISC.SPARKLE_BLURRED));
glitter.enableMotionCalculation();
glitter.setCollision(true);
glitter.setCanBounce(true);
glitter.setColorFunction(new InterpColorHSV(spellRing.getPrimaryColor(), spellRing.getSecondaryColor()));
glitter.setAcceleration(new Vec3d(0, -0.015, 0));
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector().add(new Vec3d(motionX, motionY, motionZ))), 5, 0, (aFloat, particleBuilder) -> {
particleBuilder.setScaleFunction(new InterpScale((float) RandUtil.nextDouble(0.3, 0.8), 0));
particleBuilder.setLifetime(RandUtil.nextInt(40, 60));
particleBuilder.addMotion(new Vec3d(RandUtil.nextDouble(-0.03, 0.03), RandUtil.nextDouble(-0.01, 0.05), RandUtil.nextDouble(-0.03, 0.03)));
});
glitter.disableMotionCalculation();
glitter.setMotion(Vec3d.ZERO);
ParticleSpawner.spawn(glitter, world, new StaticInterp<>(getPositionVector()), 5, 0, (aFloat, particleBuilder) -> {
particleBuilder.setScaleFunction(new InterpScale(RandUtil.nextFloat(1f, 2), 0));
particleBuilder.setLifetime(RandUtil.nextInt(5, 10));
});
}
});
return;
}
Vec3d origin = spellData.getOrigin(world);
rotationPitch = spellData.getPitch();
rotationYaw = spellData.getYaw();
Vec3d look = spellData.getData(LOOK);
if (look == null) {
setDead();
world.removeEntity(this);
return;
}
if (origin == null || getDistance() < getDistance(origin.x, origin.y, origin.z)) {
spellData.processBlock(getPosition(), EnumFacing.getFacingFromVector((float) look.x, (float) look.y, (float) look.z), getPositionVector());
goBoom(spellRing, spellData);
return;
}
if (collided) {
RayTraceResult result = new RayTrace(world, look, getPositionVector(), 5).setEntityFilter(input -> input != this && !input.isEntityEqual(spellData.getCaster(world))).trace();
spellData.processTrace(result, getPositionVector());
goBoom(spellRing, spellData);
return;
}
float speed = getSpeed();
// MOVE //
motionX += ((look.x * speed) - motionX);
motionY += ((look.y * speed) - motionY);
motionZ += ((look.z * speed) - motionZ);
// GRAVITY
// if (getDistanceSq(origin.x, origin.y, origin.z) > 4)
// motionY -= gravity;
move(MoverType.SELF, motionX, motionY, motionZ);
List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(this, getEntityBoundingBox());
if (!entities.isEmpty()) {
Entity caster = spellData.getCaster(world);
// Don't collide with other spell projectiles
for (Entity entity : entities) {
if (entity == caster)
return;
if (entity instanceof EntitySpellProjectile)
return;
spellData.processEntity(entity, false);
}
RayTraceResult result = new RayTrace(world, look, getPositionVector(), 1).setEntityFilter(input -> input != this && !input.isEntityEqual(spellData.getCaster(world))).trace();
spellData.processTrace(result, getPositionVector());
goBoom(spellRing, spellData);
}
}
Aggregations