Search in sources :

Example 91 with Vec3d

use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.

the class ModuleShapeTouch method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    Entity targetEntity = spell.getVictim();
    if (targetEntity == null)
        return;
    ParticleBuilder glitter = new ParticleBuilder(1);
    glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED));
    ParticleSpawner.spawn(glitter, spell.world, new InterpCircle(targetEntity.getPositionVector().addVector(0, targetEntity.height / 2.0, 0), new Vec3d(0, 1, 0), 1, 10), 50, RandUtil.nextInt(10, 15), (aFloat, particleBuilder) -> {
        if (RandUtil.nextBoolean()) {
            glitter.setColor(getPrimaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(0.01, 0.1), 0));
        } else {
            glitter.setColor(getSecondaryColor());
            glitter.setMotion(new Vec3d(0, RandUtil.nextDouble(-0.1, -0.01), 0));
        }
        glitter.setLifetime(RandUtil.nextInt(20, 30));
        glitter.setScale((float) RandUtil.nextDouble(0.3, 1));
        glitter.setAlphaFunction(new InterpFadeInOut(0.3f, (float) RandUtil.nextDouble(0.6, 1)));
        glitter.setLifetime(RandUtil.nextInt(10, 20));
        glitter.setScaleFunction(new InterpScale(1, 0));
    });
}
Also used : Entity(net.minecraft.entity.Entity) InterpCircle(com.teamwizardry.librarianlib.features.math.interpolate.position.InterpCircle) InterpScale(com.teamwizardry.wizardry.api.util.interp.InterpScale) ResourceLocation(net.minecraft.util.ResourceLocation) InterpFadeInOut(com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut) ParticleBuilder(com.teamwizardry.librarianlib.features.particle.ParticleBuilder) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 92 with Vec3d

use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.

the class ItemStaff method onItemUse.

@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float par8, float par9, float par10) {
    ItemStack stack = player.getHeldItem(hand);
    if (player.isSneaking()) {
        for (SpellRing spellRing : SpellUtils.getSpellChains(stack)) {
            if (spellRing.getModule() instanceof IBlockSelectable) {
                player.getEntityData().setTag("selected", NBTUtil.writeBlockState(new NBTTagCompound(), world.getBlockState(pos)));
                player.swingArm(hand);
                return EnumActionResult.PASS;
            }
        }
    }
    if (isCoolingDown(stack))
        return EnumActionResult.PASS;
    if (BaublesSupport.getItem(player, ModItems.CREATIVE_HALO, ModItems.FAKE_HALO, ModItems.REAL_HALO).isEmpty())
        return EnumActionResult.PASS;
    boolean isOnTouch = false;
    for (SpellRing spellRing : SpellUtils.getSpellChains(stack)) if (spellRing.getModule() instanceof ModuleShapeTouch) {
        isOnTouch = true;
        break;
    }
    if (!isOnTouch)
        return EnumActionResult.PASS;
    SpellData spell = new SpellData(world);
    spell.processEntity(player, true);
    spell.processBlock(pos, side, new Vec3d(pos).addVector(0.5, 0.5, 0.5));
    SpellUtils.runSpell(stack, spell);
    setCooldown(world, player, hand, stack, spell);
    return EnumActionResult.PASS;
}
Also used : ModuleShapeTouch(com.teamwizardry.wizardry.common.module.shapes.ModuleShapeTouch) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) Vec3d(net.minecraft.util.math.Vec3d) Nonnull(javax.annotation.Nonnull)

Example 93 with Vec3d

use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.

the class ModuleShapeZone method run.

@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Vec3d position = spell.getData(ORIGIN);
    Entity caster = spell.getCaster();
    Vec3d targetPos = spell.getTarget();
    if (targetPos == null)
        return false;
    double aoe = spellRing.getAttributeValue(AttributeRegistry.AREA, spell);
    double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell);
    double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
    spellRing.multiplyMultiplierForAll((float) (aoe / 7.0 * strength / 15.0 * range / 15.0));
    List<Entity> entities = world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(new BlockPos(targetPos)).grow(aoe, 1, aoe));
    if (RandUtil.nextInt((int) ((70 - strength))) == 0) {
        if (!spellRing.taxCaster(spell))
            return false;
        for (Entity entity : entities) {
            if (entity.getDistance(targetPos.x, targetPos.y, targetPos.z) <= aoe) {
                Vec3d vec = targetPos.addVector(RandUtil.nextDouble(-strength, strength), RandUtil.nextDouble(range), RandUtil.nextDouble(-strength, strength));
                SpellData copy = spell.copy();
                copy.processEntity(entity, false);
                copy.addData(YAW, entity.rotationYaw);
                copy.addData(PITCH, entity.rotationPitch);
                copy.addData(ORIGIN, vec);
                if (spellRing.getChildRing() != null) {
                    spellRing.getChildRing().runSpellRing(spell);
                }
            }
        }
    }
    if (RandUtil.nextInt((int) ((40 - strength))) != 0)
        return false;
    ArrayList<Vec3d> blocks = new ArrayList<>();
    for (double i = -aoe; i < aoe; i++) for (double j = 0; j < range; j++) for (double k = -aoe; k < aoe; k++) {
        Vec3d pos = targetPos.addVector(i, j, k);
        if (pos.distanceTo(targetPos) <= aoe) {
            // BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(new BlockPos(pos));
            blocks.add(pos);
        }
    }
    if (blocks.isEmpty())
        return false;
    if (!spellRing.taxCaster(spell))
        return false;
    Vec3d pos = blocks.get(RandUtil.nextInt(blocks.size() - 1));
    SpellData copy = spell.copy();
    copy.addData(ORIGIN, pos);
    copy.processBlock(new BlockPos(pos), EnumFacing.UP, pos);
    copy.addData(YAW, RandUtil.nextFloat(-180, 180));
    copy.addData(PITCH, RandUtil.nextFloat(-50, 50));
    if (spellRing.getChildRing() != null) {
        spellRing.getChildRing().runSpellRing(copy);
    }
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) SpellData(com.teamwizardry.wizardry.api.spell.SpellData) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 94 with Vec3d

use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.

the class ModuleEffectDisarm method render.

@Override
@SideOnly(Side.CLIENT)
public void render(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Vec3d position = spell.getTarget();
    if (position == null)
        return;
    LibParticles.EFFECT_REGENERATE(world, position, getPrimaryColor());
}
Also used : World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 95 with Vec3d

use of net.minecraft.util.math.Vec3d in project Wizardry by TeamWizardry.

the class ModuleEffectLeech method run.

@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity targetEntity = spell.getVictim();
    BlockPos targetPos = spell.getTargetPos();
    Entity caster = spell.getCaster();
    EnumFacing facing = spell.getData(FACE_HIT);
    double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2;
    if (!spellRing.taxCaster(spell))
        return false;
    if (targetEntity instanceof EntityLivingBase) {
        if (targetEntity instanceof EntityPlayer) {
            double targetMana = new CapManager(targetEntity).getMana();
            targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
            if (targetEntity.isDead) {
                targetMana /= 2;
                targetMana = MathHelper.clamp(targetMana, targetMana, spellRing.getManaDrain() * 2);
                new CapManager(caster).addMana(targetMana);
            }
        } else if (targetEntity instanceof EntityWitch) {
            double targetMana = spellRing.getManaDrain() * 2;
            targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
            if (targetEntity.isDead) {
                new CapManager(caster).addMana(targetMana);
            }
        } else {
            if (caster instanceof EntityLivingBase)
                ((EntityLivingBase) caster).setLastAttackedEntity(targetEntity);
            if (caster != null)
                targetEntity.attackEntityFrom(new EntityDamageSource("magic", caster).setDamageBypassesArmor().setMagicDamage(), (float) strength);
            else
                targetEntity.attackEntityFrom(DamageSource.MAGIC, (float) strength);
        }
    }
    Vec3d target = spell.getTargetWithFallback();
    if (target != null)
        world.playSound(null, new BlockPos(target), ModSounds.CHAINY_ZAP, SoundCategory.NEUTRAL, RandUtil.nextFloat(0.35f, 0.75f), RandUtil.nextFloat(0.35f, 1.5f));
    return true;
}
Also used : CapManager(com.teamwizardry.wizardry.api.capability.CapManager) Entity(net.minecraft.entity.Entity) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityWitch(net.minecraft.entity.monster.EntityWitch) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

Vec3d (net.minecraft.util.math.Vec3d)789 BlockPos (net.minecraft.util.math.BlockPos)204 Entity (net.minecraft.entity.Entity)118 EnumFacing (net.minecraft.util.EnumFacing)108 ItemStack (net.minecraft.item.ItemStack)100 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)97 RayTraceResult (net.minecraft.util.math.RayTraceResult)90 World (net.minecraft.world.World)90 EntityPlayer (net.minecraft.entity.player.EntityPlayer)88 IBlockState (net.minecraft.block.state.IBlockState)76 EntityLivingBase (net.minecraft.entity.EntityLivingBase)74 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)72 ResourceLocation (net.minecraft.util.ResourceLocation)68 ParticleBuilder (com.teamwizardry.librarianlib.features.particle.ParticleBuilder)59 InterpFadeInOut (com.teamwizardry.librarianlib.features.particle.functions.InterpFadeInOut)59 TileEntity (net.minecraft.tileentity.TileEntity)42 Block (net.minecraft.block.Block)41 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)30 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)27 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)27