Search in sources :

Example 1 with ModuleInstanceShape

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());
}
Also used : RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) HashMap(java.util.HashMap) ModuleOverrideSuper(com.teamwizardry.wizardry.api.spell.module.ModuleOverrideSuper) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) Mod(net.minecraftforge.fml.common.Mod) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) ConfigValues(com.teamwizardry.wizardry.api.ConfigValues) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) ContextSuper(com.teamwizardry.wizardry.api.spell.annotation.ContextSuper) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) IContinuousModule(com.teamwizardry.wizardry.api.spell.IContinuousModule) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) EntityLivingBase(net.minecraft.entity.EntityLivingBase) LibParticles(com.teamwizardry.wizardry.client.fx.LibParticles) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) TickEvent(net.minecraftforge.fml.common.gameevent.TickEvent) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EntityLivingBase(net.minecraft.entity.EntityLivingBase) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 2 with ModuleInstanceShape

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;
}
Also used : Entity(net.minecraft.entity.Entity) RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) BlockPos(net.minecraft.util.math.BlockPos) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntitySpellProjectile(com.teamwizardry.wizardry.common.entity.projectile.EntitySpellProjectile) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) ModSounds(com.teamwizardry.wizardry.init.ModSounds) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) NotNull(org.jetbrains.annotations.NotNull) SoundCategory(net.minecraft.util.SoundCategory) Nonnull(javax.annotation.Nonnull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 3 with ModuleInstanceShape

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;
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Vec3d(net.minecraft.util.math.Vec3d) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 4 with ModuleInstanceShape

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;
}
Also used : InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) LOOK(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Example 5 with ModuleInstanceShape

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;
}
Also used : RenderUtils(com.teamwizardry.wizardry.api.util.RenderUtils) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ParticleSpawner(com.teamwizardry.librarianlib.features.particle.ParticleSpawner) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride) PosUtils(com.teamwizardry.wizardry.api.util.PosUtils) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) SpellRing(com.teamwizardry.wizardry.api.spell.SpellRing) RayTraceResult(net.minecraft.util.math.RayTraceResult) InterpLine(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpLine) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) InterpFloatInOut(com.teamwizardry.librarianlib.features.math.interpolate.numeric.InterpFloatInOut) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Entity(net.minecraft.entity.Entity) World(net.minecraft.world.World) Wizardry(com.teamwizardry.wizardry.Wizardry) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) InterpColorHSV(com.teamwizardry.librarianlib.features.particle.functions.InterpColorHSV) ModuleInstanceShape(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape) AttributeRegistry(com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry) ResourceLocation(net.minecraft.util.ResourceLocation) RegisterModule(com.teamwizardry.wizardry.api.spell.annotation.RegisterModule) RandUtil(com.teamwizardry.wizardry.api.util.RandUtil) NBTConstants(com.teamwizardry.wizardry.api.NBTConstants) NotNull(org.jetbrains.annotations.NotNull) IModuleShape(com.teamwizardry.wizardry.api.spell.module.IModuleShape) DefaultKeys(com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys) Entity(net.minecraft.entity.Entity) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vec3d(net.minecraft.util.math.Vec3d) NotNull(org.jetbrains.annotations.NotNull) ModuleOverride(com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)

Aggregations

SpellData (com.teamwizardry.wizardry.api.spell.SpellData)9 SpellRing (com.teamwizardry.wizardry.api.spell.SpellRing)9 ModuleOverride (com.teamwizardry.wizardry.api.spell.annotation.ModuleOverride)9 RegisterModule (com.teamwizardry.wizardry.api.spell.annotation.RegisterModule)9 IModuleShape (com.teamwizardry.wizardry.api.spell.module.IModuleShape)9 ModuleInstanceShape (com.teamwizardry.wizardry.api.spell.module.ModuleInstanceShape)9 RandUtil (com.teamwizardry.wizardry.api.util.RandUtil)9 RayTrace (com.teamwizardry.wizardry.api.util.RayTrace)9 RenderUtils (com.teamwizardry.wizardry.api.util.RenderUtils)9 Nonnull (javax.annotation.Nonnull)9 Entity (net.minecraft.entity.Entity)9 RayTraceResult (net.minecraft.util.math.RayTraceResult)9 Vec3d (net.minecraft.util.math.Vec3d)9 World (net.minecraft.world.World)9 Side (net.minecraftforge.fml.relauncher.Side)9 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)9 NotNull (org.jetbrains.annotations.NotNull)9 Wizardry (com.teamwizardry.wizardry.Wizardry)8 AttributeRegistry (com.teamwizardry.wizardry.api.spell.attribute.AttributeRegistry)7 LOOK (com.teamwizardry.wizardry.api.spell.SpellData.DefaultKeys.LOOK)6