Search in sources :

Example 21 with Vector3

use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.

the class ItemCrystalQuartz method onEntityItemUpdate.

@Override
public boolean onEntityItemUpdate(EntityItem entity) {
    if (!entity.world.isRemote) {
        entity = makeQuantum(entity);
        if (itemRand.nextFloat() < 0.1F) {
            Vector3 from = new Vector3.WrappedVec3d(entity.getPositionVector()).asImmutable();
            Vector3 to = Vector3.rotateRandom().multiply(2).add(from);
            if (isValidSpawn(entity.world, to)) {
                entity.setPositionAndUpdate(to.x(), to.y(), to.z());
                entity.playSound(SoundEvents.ENTITY_SHULKER_TELEPORT, 0.25F, 0.5F);
            }
        }
    } else {
        Vector3 pos = new Vector3(entity).add(0D, entity.height * 1.75D, 0D);
        Vector3 speedVec = Vector3.rotateRandom().multiply(0.01D);
        FXUtil.spawnLight(entity.world, pos, speedVec, 45, 3F, 0x1BE564, Light.GLOW);
    }
    return false;
}
Also used : Vector3(net.katsstuff.mirror.data.Vector3)

Example 22 with Vector3

use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.

the class ParticleVolt method calculateBolts.

private void calculateBolts() {
    // TODO: Maybe use textures instead of raw gl lines?
    ProfilerHelper.begin("[Particle Bolt] Calculating Bolts");
    List<VoltSegment> branched = Lists.newArrayList();
    for (int i = 0; i < generations; i++) {
        List<VoltSegment> temp = Lists.newArrayList();
        for (VoltSegment segment : segments) {
            Vector3 from = segment.from;
            Vector3 to = segment.to;
            MutableVector3 mid = average(from, to).asMutable();
            Vector3 midOffset = to.subtract(from);
            mid = mid.add(midOffset.normalize().cross(Vector3.One()).multiply(Vector3.rotateRandom().multiply(offset)));
            if (branch && rand.nextDouble() > 0.6D) {
                MutableVector3 direction = mid.subtract(from);
                float xAngle = (25.0F + 12.5F * rand.nextFloat()) * (rand.nextBoolean() ? 1 : -1);
                float zAngle = (25.0F + 12.5F * rand.nextFloat()) * (rand.nextBoolean() ? 1 : -1);
                Quat x = Quat.fromAxisAngle(Vector3.Forward(), xAngle);
                Quat z = Quat.fromAxisAngle(Vector3.Right(), zAngle);
                Vector3 splitEnd = direction.rotate(x.multiply(z)).multiply(0.7D).add(mid).asImmutable();
                VoltSegment sub = new VoltSegment(mid.asImmutable(), splitEnd);
                sub.alpha = segment.alpha;
                temp.add(sub);
            }
            VoltSegment one = new VoltSegment(from, mid.asImmutable());
            VoltSegment two = new VoltSegment(mid.asImmutable(), to);
            if (fade) {
                one.alpha = segment.alpha * 0.5F;
                two.alpha = segment.alpha;
            }
            temp.add(one);
            temp.add(two);
            if (branched.isEmpty() || branched.contains(segment)) {
                branched.add(two);
            }
        }
        segments = temp;
        offset /= 2;
    }
    ProfilerHelper.end();
}
Also used : MutableVector3(net.katsstuff.mirror.data.MutableVector3) Quat(net.katsstuff.mirror.data.Quat) Vector3(net.katsstuff.mirror.data.Vector3) MutableVector3(net.katsstuff.mirror.data.MutableVector3)

Example 23 with Vector3

use of net.katsstuff.mirror.data.Vector3 in project Solar by ArekkuusuJerii.

the class Events method renderGhostAngstrom.

@SubscribeEvent
public static void renderGhostAngstrom(RenderWorldLastEvent event) {
    EntityPlayerSP player = Minecraft.getMinecraft().player;
    ItemStack stack = player.getHeldItemMainhand();
    if (stack.isEmpty() || stack.getItem() != ModItems.ANGSTROM) {
        stack = player.getHeldItemOffhand();
    }
    if (!stack.isEmpty() && stack.getItem() == ModItems.ANGSTROM) {
        RayTraceResult result = RayTraceHelper.tracePlayerHighlight(player);
        if (result.typeOfHit != RayTraceResult.Type.BLOCK) {
            Vector3 vec = Vector3.apply(player.posX, player.posY + player.getEyeHeight(), player.posZ).add(new Vector3(player.getLookVec()).multiply(2.5D));
            BlockPos pos = new BlockPos(vec.toVec3d());
            IBlockState replaced = player.world.getBlockState(pos);
            if (player.world.isAirBlock(pos) || replaced.getBlock().isReplaceable(player.world, pos)) {
                RenderHelper.renderGhostBlock(pos, ModBlocks.ANGSTROM.getDefaultState());
            }
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vector3(net.katsstuff.mirror.data.Vector3) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

Vector3 (net.katsstuff.mirror.data.Vector3)23 Quat (net.katsstuff.mirror.data.Quat)8 EnumFacing (net.minecraft.util.EnumFacing)8 BlockPos (net.minecraft.util.math.BlockPos)7 IBlockState (net.minecraft.block.state.IBlockState)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 ItemStack (net.minecraft.item.ItemStack)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 Rotation (net.minecraft.util.Rotation)2 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 PlacementSettings (net.minecraft.world.gen.structure.template.PlacementSettings)2 Template (net.minecraft.world.gen.structure.template.Template)2 ILumen (arekkuusu.solar.api.entanglement.energy.data.ILumen)1 Capacity (arekkuusu.solar.common.block.tile.TileNeutronBattery.Capacity)1 TileQelaion (arekkuusu.solar.common.block.tile.TileQelaion)1 EntityLumen (arekkuusu.solar.common.entity.EntityLumen)1 EntityTemporalItem (arekkuusu.solar.common.entity.EntityTemporalItem)1 MutableVector3 (net.katsstuff.mirror.data.MutableVector3)1 SoundType (net.minecraft.block.SoundType)1 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)1