Search in sources :

Example 96 with Vec3d

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

the class ModuleEffectLight method run.

@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    BlockPos targetPos = spell.getTargetPos();
    Vec3d hit = spell.getTarget();
    Entity targetEntity = spell.getVictim();
    EnumFacing facing = spell.getData(FACE_HIT);
    Entity caster = spell.getCaster();
    if (targetPos == null && hit != null)
        targetPos = new BlockPos(hit);
    if (targetPos == null)
        return false;
    BlockPos finalPos = null;
    if (world.isAirBlock(targetPos))
        finalPos = targetPos;
    else if (facing != null && world.isAirBlock(targetPos.offset(facing)))
        finalPos = targetPos.offset(facing);
    if (finalPos == null)
        return false;
    if (!spellRing.taxCaster(spell))
        return false;
    BlockUtils.placeBlock(world, finalPos, ModBlocks.LIGHT.getDefaultState(), caster instanceof EntityPlayerMP ? (EntityPlayerMP) caster : null);
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 97 with Vec3d

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

the class ModuleEffectLight 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.EXPLODE(world, position, getPrimaryColor(), getSecondaryColor(), 0.2, 0.3, 20, 40, 10, true);
}
Also used : World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 98 with Vec3d

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

the class ModuleEffectLightning method run.

@Override
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Vec3d target = spell.getTarget();
    Entity caster = spell.getCaster();
    float yaw = spell.getData(YAW, 0F);
    float pitch = spell.getData(PITCH, 0F);
    if (target == null)
        return false;
    Vec3d origin = target;
    if (caster != null) {
        float offX = 0.5f * (float) Math.sin(Math.toRadians(-90.0f - yaw));
        float offZ = 0.5f * (float) Math.cos(Math.toRadians(-90.0f - yaw));
        origin = new Vec3d(offX, caster.getEyeHeight(), offZ).add(target);
    }
    double range = spellRing.getAttributeValue(AttributeRegistry.RANGE, spell);
    double strength = spellRing.getAttributeValue(AttributeRegistry.POTENCY, spell) / 2.0;
    if (!spellRing.taxCaster(spell))
        return false;
    RayTraceResult traceResult = new RayTrace(world, PosUtils.vecFromRotations(pitch, yaw), target, range).setSkipBlocks(true).setSkipEntities(true).trace();
    long seed = RandUtil.nextLong(100, 100000);
    spell.addData(SEED, seed);
    LightningGenerator generator = new LightningGenerator(origin, traceResult.hitVec, new RandUtilSeed(seed));
    ArrayList<Vec3d> points = generator.generate();
    spell.world.playSound(null, new BlockPos(traceResult.hitVec), ModSounds.LIGHTNING, SoundCategory.NEUTRAL, 0.5f, RandUtil.nextFloat(1, 1.5f));
    for (Vec3d point : points) {
        List<Entity> entityList = world.getEntitiesWithinAABBExcludingEntity(caster, new AxisAlignedBB(new BlockPos(point)).contract(0.2, 0.2, 0.2));
        if (!entityList.isEmpty()) {
            for (Entity entity : entityList) {
                LightningTracker.INSTANCE.addEntity(origin, entity, caster, (int) strength);
            }
        }
    }
    return true;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) RayTraceResult(net.minecraft.util.math.RayTraceResult) World(net.minecraft.world.World) RandUtilSeed(com.teamwizardry.wizardry.api.util.RandUtilSeed) Vec3d(net.minecraft.util.math.Vec3d) RayTrace(com.teamwizardry.wizardry.api.util.RayTrace) BlockPos(net.minecraft.util.math.BlockPos) LightningGenerator(com.teamwizardry.wizardry.api.LightningGenerator)

Example 99 with Vec3d

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

the class ModuleEffectBackup method run.

@Override
@SuppressWarnings("unused")
public boolean run(@Nonnull SpellData spell, @Nonnull SpellRing spellRing) {
    World world = spell.world;
    Entity targetEntity = spell.getVictim();
    Vec3d targetPos = spell.getTarget();
    EnumFacing facing = spell.getData(FACE_HIT);
    Entity caster = spell.getCaster();
    double range = spellRing.getAttributeValue(AttributeRegistry.AREA, spell) / 2.0;
    double time = spellRing.getAttributeValue(AttributeRegistry.DURATION, spell);
    if (!spellRing.taxCaster(spell))
        return false;
    if (targetPos == null)
        return true;
    if (!(caster instanceof EntityLivingBase))
        return true;
    if (facing != null && !world.isAirBlock(new BlockPos(targetPos))) {
        targetPos = new Vec3d(new BlockPos(targetPos).offset(facing)).addVector(0.5, 0.5, 0.5);
    }
    EntityBackupZombie zombie = new EntityBackupZombie(world, (EntityLivingBase) caster, (int) time);
    zombie.setPosition(targetPos.x, targetPos.y, targetPos.z);
    zombie.forceSpawn = true;
    world.spawnEntity(zombie);
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EnumFacing(net.minecraft.util.EnumFacing) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) EntityBackupZombie(com.teamwizardry.wizardry.common.entity.EntityBackupZombie) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 100 with Vec3d

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

the class ModuleEffectBreak 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.EXPLODE(world, position, getPrimaryColor(), getSecondaryColor(), 0.2, 0.3, 20, 40, 10, true);
}
Also used : World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

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