Search in sources :

Example 16 with Vector3

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

the class TileVacuumConveyor method impulseEntityItem.

private void impulseEntityItem(Vector3 pos, EntityTemporalItem item) {
    Vector3 fuzzy = pos.add(Vector3.rotateRandom().multiply(0.1D));
    item.setPositionAndUpdate(fuzzy.x(), fuzzy.y(), fuzzy.z());
    item.setMotion(0, 0, 0);
}
Also used : Vector3(net.katsstuff.mirror.data.Vector3)

Example 17 with Vector3

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

the class TileVacuumConveyor method dropItems.

private void dropItems() {
    if (cooldown <= 0) {
        IItemHandler handler = from.getKey();
        ISidedInventory sidedInv = from.getValue();
        for (int slot = 0; slot < handler.getSlots(); slot++) {
            ItemStack inSlot = handler.getStackInSlot(slot);
            if (!inSlot.isEmpty() && (lookup.isEmpty() || ItemHandlerHelper.canItemStacksStack(lookup, inSlot)) && (sidedInv == null || sidedInv.canExtractItem(slot, inSlot, getFacingLazy()))) {
                BlockPos offset = pos.offset(getFacingLazy());
                Vector3 spawn = Vector3.apply(offset.getX(), offset.getY(), offset.getZ()).add(0.5D);
                ItemStack out = handler.extractItem(slot, Integer.MAX_VALUE, false);
                EntityTemporalItem entity = new EntityTemporalItem(world, spawn.x(), spawn.y(), spawn.z(), out);
                impulseEntityItem(spawn, entity);
                world.spawnEntity(entity);
                break;
            }
        }
        cooldown = 5;
    } else
        cooldown--;
    applyGravity(repulse, -1.25D);
}
Also used : ISidedInventory(net.minecraft.inventory.ISidedInventory) IItemHandler(net.minecraftforge.items.IItemHandler) BlockPos(net.minecraft.util.math.BlockPos) Vector3(net.katsstuff.mirror.data.Vector3) EntityTemporalItem(arekkuusu.solar.common.entity.EntityTemporalItem) ItemStack(net.minecraft.item.ItemStack)

Example 18 with Vector3

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

the class EntityLumen method onUpdate.

@Override
public void onUpdate() {
    super.onUpdate();
    if (world.isRemote) {
        int lumen = MathHelper.clamp(handler.get(), 0, 4);
        Vector3 pos = Vector3.apply(posX, posY, posZ);
        for (int i = 0; i < lumen; i++) {
            Quat x = Quat.fromAxisAngle(Vector3.Forward(), (world.rand.nextFloat() * 2F - 1F) * 25F);
            Quat z = Quat.fromAxisAngle(Vector3.Right(), (world.rand.nextFloat() * 2F - 1F) * 25F);
            Vector3 vec = Vector3.apply(motionX, motionY, motionZ).rotate(x.multiply(z)).multiply(0.1D);
            FXUtil.spawnTunneling(world, pos, vec, 30 + world.rand.nextInt(40), 2F, 0xFFE077, GlowTexture.GLINT);
        }
    } else {
        double rest = 1D * (1 - (double) handler.get() / 1000D);
        motionX *= rest;
        motionY *= rest;
        motionZ *= rest;
        if (tick++ % 80 == 0 && tick > 1) {
            handler.set((int) ((float) handler.get() * 0.75F));
        }
        if (handler.get() <= 0)
            setDead();
    }
    move(MoverType.SELF, motionX, motionY, motionZ);
}
Also used : Quat(net.katsstuff.mirror.data.Quat) Vector3(net.katsstuff.mirror.data.Vector3)

Example 19 with Vector3

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

the class ObeliskDecorator method gen.

@Override
void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) {
    random.setSeed(world.getSeed());
    long good = random.nextLong();
    long succ = random.nextLong();
    good *= x >> 3;
    succ *= z >> 3;
    random.setSeed(good * succ * world.getSeed());
    // Generate
    if (GEN_CONFIG.monolith.decorator.rarity > 0D && GEN_CONFIG.monolith.decorator.rarity / 100D > random.nextDouble()) {
        List<AxisAlignedBB> occupied = Lists.newArrayList();
        for (int i = 0; i < GEN_CONFIG.monolith.decorator.size; i++) {
            BlockPos top = world.getTopSolidOrLiquidBlock(randomVector().add(x, 0, z).toBlockPos());
            int below = random.nextInt(7);
            if (top.getY() > below) {
                top = top.add(0, -below, 0);
            }
            Template obelisk = obelisks.next().load(world);
            Rotation rotation = Rotation.values()[random.nextInt(4)];
            Vector3 vec = rotate(new Vector3.WrappedVec3i(obelisk.getSize()).asImmutable(), rotation);
            vec = vec.offset(rotate(Vector3.apply(-1, -1, -1), rotation), 1);
            AxisAlignedBB obeliskBB = new AxisAlignedBB(top, top.add(vec.toBlockPos())).grow(1);
            if (occupied.stream().noneMatch(bb -> bb.intersects(obeliskBB))) {
                PlacementSettings settings = new PlacementSettings();
                settings.setRotation(rotation);
                settings.setRandom(random);
                obelisk.addBlocksToWorld(world, top, settings);
                BlockPos.getAllInBox(top, top.add(vec.toBlockPos())).forEach(p -> {
                    if (random.nextFloat() < 0.05) {
                        IBlockState glyph = ModBlocks.MONOLITHIC_GLYPH.getDefaultState().withProperty(BlockMonolithicGlyph.GLYPH, random.nextInt(16));
                        world.setBlockState(p, glyph);
                    }
                });
                occupied.add(obeliskBB);
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) Vector3(net.katsstuff.mirror.data.Vector3) PlacementSettings(net.minecraft.world.gen.structure.template.PlacementSettings) Rotation(net.minecraft.util.Rotation) Template(net.minecraft.world.gen.structure.template.Template)

Example 20 with Vector3

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

the class ItemAngstrom method onItemRightClick.

@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
    ItemStack stack = player.getHeldItem(hand);
    RayTraceResult result = RayTraceHelper.tracePlayerHighlight(player);
    if (result.typeOfHit != RayTraceResult.Type.BLOCK) {
        if (!world.isRemote) {
            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 = world.getBlockState(pos);
            if (world.isAirBlock(pos) || replaced.getBlock().isReplaceable(world, pos)) {
                IBlockState state = ModBlocks.ANGSTROM.getDefaultState();
                SoundType type = ModBlocks.ANGSTROM.getSoundType(state, world, pos, player);
                world.setBlockState(pos, state);
                world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), type.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
            }
            if (!player.capabilities.isCreativeMode) {
                stack.shrink(1);
            }
        }
        return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
    }
    return ActionResult.newResult(EnumActionResult.PASS, stack);
}
Also used : SoundType(net.minecraft.block.SoundType) IBlockState(net.minecraft.block.state.IBlockState) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vector3(net.katsstuff.mirror.data.Vector3) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

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