use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeBeam method renderSpell.
@Override
@SideOnly(Side.CLIENT)
public void renderSpell(World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
if (overrides.onRenderBeam(world, spell, spellRing))
return;
Vec3d look = spell.getData(LOOK);
Vec3d position = spell.getOrigin(world);
Entity caster = spell.getCaster(world);
if (look == null || position == null || caster == null)
return;
ItemStack stack = ((EntityLivingBase) caster).getHeldItemMainhand();
if (stack.isEmpty())
return;
double range = spellRing.getAttributeValue(world, AttributeRegistry.RANGE, spell);
RayTraceResult trace = new RayTrace(world, look, position, range).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
Vec3d target = trace.hitVec;
if (target == null)
return;
LibParticles.SHAPE_BEAM(world, target, spell.getOriginHand(world), RandUtil.nextBoolean() ? spellRing.getPrimaryColor() : spellRing.getSecondaryColor());
}
use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeProjectile method renderVisualization.
/**
* {@inheritDoc}
*/
@NotNull
@Override
public SpellData renderVisualization(@Nonnull World world, ModuleInstanceShape instance, @Nonnull SpellData data, @Nonnull SpellRing ring, float partialTicks) {
Vec3d look = data.getData(LOOK);
Entity caster = data.getCaster(world);
Vec3d origin = data.getOrigin(world);
Vec3d target;
if (look == null)
return data;
if (caster == null)
return data;
if (origin == null)
return data;
double dist = 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), dist).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
data.processTrace(result);
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 ModuleShapeTouch method run.
@Override
public boolean run(@NotNull World world, ModuleInstanceShape instance, @Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
Wizardry.LOGGER.warn("TOUCH: " + world.isRemote);
Vec3d look = spell.getData(LOOK);
Entity caster = spell.getCaster(world);
Vec3d origin = spell.getOrigin(world);
if (look == null)
return false;
if (caster == null)
return false;
if (origin == null)
return false;
if (!spellRing.taxCaster(world, spell, true))
return false;
IShapeOverrides overrides = spellRing.getOverrideHandler().getConsumerInterface(IShapeOverrides.class);
overrides.onRunTouch(world, spell, spellRing);
RayTraceResult result = new RayTrace(world, look, origin, caster instanceof EntityLivingBase && ((EntityLivingBase) caster).getAttributeMap().getAllAttributes().contains(EntityPlayer.REACH_DISTANCE) ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(false).trace();
spell.processTrace(result);
return true;
}
use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeTouch 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);
Entity caster = data.getCaster(world);
Vec3d origin = data.getOrigin(world);
if (look == null)
return data;
if (caster == null)
return data;
if (origin == null)
return 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), caster instanceof EntityLivingBase ? ((EntityLivingBase) caster).getEntityAttribute(EntityPlayer.REACH_DISTANCE).getAttributeValue() : 5).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(false).trace();
data.processTrace(result);
BlockPos pos = data.getTargetPos();
EnumFacing facing = data.getFaceHit();
Vec3d target = data.getTarget(world);
if (pos == null)
return data;
if (facing != null && !world.isAirBlock(pos))
RenderUtils.drawFaceOutline(pos, facing);
else if (target != null) {
RenderUtils.drawCircle(target, 0.3, true, false);
}
data.processTrace(result);
return data;
}
use of com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape in project Wizardry by TeamWizardry.
the class ModuleShapeCone method renderVisualization.
/**
* {@inheritDoc}
*/
@NotNull
@Override
public SpellData renderVisualization(@Nonnull World world, ModuleInstanceShape instance, @Nonnull SpellData data, @Nonnull SpellRing ring, float partialTicks) {
Vec3d look = data.getData(LOOK);
Entity caster = data.getCaster(world);
Vec3d origin = data.getOrigin(world);
Vec3d target;
if (look == null)
return data;
if (caster == null)
return data;
if (origin == null)
return 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;
double dist = ring.getAttributeValue(world, AttributeRegistry.RANGE, data);
RayTraceResult result = new RayTrace(world, look, new Vec3d(interpPosX, interpPosY + caster.getEyeHeight(), interpPosZ), dist).setEntityFilter(input -> input != caster).setReturnLastUncollidableBlock(true).setIgnoreBlocksWithoutBoundingBoxes(true).trace();
data.processTrace(result);
target = data.getTarget(world);
if (target == null)
return data;
RenderUtils.drawCircle(target, dist / 4.0, true, true);
return data;
}
Aggregations