use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeZone method renderVisualization.
@SideOnly(Side.CLIENT)
@Override
public SpellData renderVisualization(@Nonnull World world, ModuleInstanceShape instance, @Nonnull SpellData data, @Nonnull SpellRing ring, float partialTicks) {
Vec3d look = data.getData(SpellData.DefaultKeys.LOOK);
Entity caster = data.getCaster(world);
if (caster == null)
return data;
if (look == null)
return data;
Vec3d target;
double interpPosX = caster.lastTickPosX + (caster.posX - caster.lastTickPosX) * partialTicks;
double interpPosY = caster.lastTickPosY + (caster.posY - caster.lastTickPosY) * partialTicks;
double interpPosZ = caster.lastTickPosZ + (caster.posZ - caster.lastTickPosZ) * partialTicks;
RayTraceResult result = new RayTrace(world, look, new Vec3d(interpPosX, interpPosY + caster.getEyeHeight(), interpPosZ), caster instanceof EntityLivingBase ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
data.processTrace(result);
BlockPos pos = data.getTargetPos();
if (pos == null)
return data;
data.processTrace(result);
target = data.getTarget(world);
if (target == null)
return data;
double aoe = ring.getAttributeValue(world, AttributeRegistry.AREA, data);
RenderUtils.drawCircle(target, aoe, false, false);
return data;
}
use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeCone method run.
/**
* {@inheritDoc}
*/
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
float yaw = spell.getYaw();
float pitch = spell.getPitch();
Entity caster = spell.getCaster(world);
Vec3d origin = spell.getOriginHand(world);
if (origin == null)
return false;
double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
int potency = (int) (spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell));
for (int i = 0; i < potency; i++) {
if (!spellRing.taxCaster(world, spell, 1.0 / potency, true))
return false;
long seed = RandUtil.nextLong(100, 10000);
spell.addData(SEED, seed);
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
overrides.onRunCone(world, spell, spellRing);
float angle = (float) range * 2;
float newPitch = pitch + RandUtil.nextFloat(-angle, angle);
float newYaw = yaw + RandUtil.nextFloat(-angle, angle);
Vec3d target = PosUtils.vecFromRotations(newPitch, newYaw);
SpellData newSpell = spell.copy();
RayTraceResult result = new RayTrace(world, target.normalize(), origin, range).setEntityFilter(input -> input != caster).trace();
Vec3d lookFallback = spell.getData(LOOK);
if (lookFallback != null)
lookFallback.scale(range);
newSpell.processTrace(result, lookFallback);
// Is already executed via SpellRing.runSpellRing() ???
instance.sendRenderPacket(world, newSpell, spellRing);
newSpell.addData(ORIGIN, result.hitVec);
if (spellRing.getChildRing() != null) {
spellRing.getChildRing().runSpellRing(world, newSpell.copy(), true);
}
}
return true;
}
use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeBeam method renderVisualization.
@NotNull
@Override
public SpellData renderVisualization(@Nonnull World world, ModuleInstanceShape instance, @Nonnull SpellData data, @Nonnull SpellRing ring, float partialTicks) {
Vec3d look = data.getData(LOOK);
Vec3d position = data.getOrigin(world);
Entity caster = data.getCaster(world);
if (look == null || position == null || caster == null)
return data;
double range = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);
double interpPosX = caster.lastTickPosX + (caster.posX - caster.lastTickPosX) * partialTicks;
double interpPosY = caster.lastTickPosY + (caster.posY - caster.lastTickPosY) * partialTicks;
double interpPosZ = caster.lastTickPosZ + (caster.posZ - caster.lastTickPosZ) * partialTicks;
RayTraceResult result = new RayTrace(world, look, new Vec3d(interpPosX, interpPosY + caster.getEyeHeight(), interpPosZ), range).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
data.processTrace(result, look.scale(range));
Vec3d target = data.getTarget(world);
if (target == null)
return data;
RenderUtils.drawCircle(target, 0.3, true, false);
return data;
}
use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeBeam method run.
/**
* {@inheritDoc}
*/
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Vec3d look = spell.getData(LOOK);
Vec3d position = spell.getOrigin(world);
Entity caster = spell.getCaster(world);
if (look == null || position == null || caster == null)
return false;
ItemStack stack = ((EntityLivingBase) caster).getHeldItemMainhand();
if (stack.isEmpty())
return true;
beamTickMap.putIfAbsent(stack, new BeamTicker());
BeamTicker ticker = beamTickMap.get(stack);
double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
double potency = spellRing.getAttributeValue(world, AttributeRegistry.POTENCY, spell);
double beamOffset = ticker.ticks + potency;
ticker.cast = false;
if (beamOffset >= ConfigValues.beamTimer) {
beamOffset %= ConfigValues.beamTimer;
if (!spellRing.taxCaster(world, spell, true)) {
ticker.ticks = beamOffset;
return false;
}
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
overrides.onRunBeam(world, spell, spellRing);
RayTraceResult trace = new RayTrace(world, look, position, range).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
spell.processTrace(trace, look.scale(range));
if (spellRing.getChildRing() != null)
spellRing.getChildRing().runSpellRing(world, spell, true);
ticker.cast = true;
// Is already executed via SpellRing.runSpellRing() ???
instance.sendRenderPacket(world, spell, spellRing);
}
ticker.ticks = beamOffset;
return true;
}
Aggregations