Search in sources :

Example 1 with ILumen

use of arekkuusu.solar.api.entanglement.energy.data.ILumen in project Solar by ArekkuusuJerii.

the class TilePholarizer method spit.

private void spit() {
    EnumFacing facing = getFacingLazy();
    BlockPos pos = getPos().offset(facing);
    IBlockState state = world.getBlockState(pos);
    facing = facing.getOpposite();
    TileEntity tile;
    if (state.getBlock().hasTileEntity(state) && (tile = world.getTileEntity(pos)).hasCapability(ModCapability.LUMEN_CAPABILITY, facing)) {
        ILumen wrapper = tile.getCapability(ModCapability.LUMEN_CAPABILITY, facing);
        if (wrapper.get() > 0) {
            EntityLumen lumen = EntityLumen.spawn(world, new Vector3.WrappedVec3i(getPos()).asImmutable().add(0.5D), wrapper.drain(64));
            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 = new Vector3.WrappedVec3i(getFacingLazy().getOpposite().getDirectionVec()).asImmutable().rotate(x.multiply(z)).multiply(0.1D);
            lumen.motionX = vec.x();
            lumen.motionY = vec.y();
            lumen.motionZ = vec.z();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Quat(net.katsstuff.mirror.data.Quat) IBlockState(net.minecraft.block.state.IBlockState) ILumen(arekkuusu.solar.api.entanglement.energy.data.ILumen) EnumFacing(net.minecraft.util.EnumFacing) EntityLumen(arekkuusu.solar.common.entity.EntityLumen) BlockPos(net.minecraft.util.math.BlockPos) Vector3(net.katsstuff.mirror.data.Vector3)

Example 2 with ILumen

use of arekkuusu.solar.api.entanglement.energy.data.ILumen in project Solar by ArekkuusuJerii.

the class BlockNeutronBattery method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if (!world.isRemote) {
        getTile(TileNeutronBattery.class, world, pos).ifPresent(neutron -> {
            IEntangledStack entangled = (IEntangledStack) stack.getItem();
            if (!entangled.getKey(stack).isPresent()) {
                entangled.setKey(stack, UUID.randomUUID());
            }
            entangled.getKey(stack).ifPresent(neutron::setKey);
            if (placer instanceof EntityPlayer && ((EntityPlayer) placer).capabilities.isCreativeMode) {
                ILumen lumen = neutron.getCapability(ModCapability.LUMEN_CAPABILITY, EnumFacing.UP);
                if (lumen != null) {
                    // CHEATER!!
                    lumen.set(neutron.getCapacityLazy().max);
                }
            }
        });
    }
}
Also used : IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) ILumen(arekkuusu.solar.api.entanglement.energy.data.ILumen) TileNeutronBattery(arekkuusu.solar.common.block.tile.TileNeutronBattery) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 3 with ILumen

use of arekkuusu.solar.api.entanglement.energy.data.ILumen in project Solar by ArekkuusuJerii.

the class TilePholarizer method succ.

private void succ() {
    EnumFacing facing = getFacingLazy();
    BlockPos pos = getPos().offset(facing);
    IBlockState state = world.getBlockState(pos);
    facing = facing.getOpposite();
    TileEntity tile;
    if (state.getBlock().hasTileEntity(state) && (tile = world.getTileEntity(pos)).hasCapability(ModCapability.LUMEN_CAPABILITY, facing)) {
        ILumen wrapper = tile.getCapability(ModCapability.LUMEN_CAPABILITY, facing);
        if (wrapper.get() < wrapper.getMax()) {
            world.getEntitiesWithinAABB(EntityLumen.class, new AxisAlignedBB(pos).grow(10D)).stream().filter(e -> !e.isDead && e.hasCapability(ModCapability.LUMEN_CAPABILITY, null)).forEach(e -> {
                double x = getPos().getX() + 0.5D - e.posX;
                double y = getPos().getY() + 0.5D - e.posY;
                double z = getPos().getZ() + 0.5D - e.posZ;
                double sqrt = Math.sqrt(x * x + y * y + z * z);
                double effect = sqrt / 10D;
                double strength = (1 - effect) * (1 - effect);
                double power = 0.025D;
                e.motionX += (x / sqrt) * strength * power;
                e.motionY += (y / sqrt) * strength * power;
                e.motionZ += (z / sqrt) * strength * power;
            });
            world.getEntitiesWithinAABB(EntityLumen.class, new AxisAlignedBB(pos).grow(0.5D)).stream().filter(e -> !e.isDead && e.hasCapability(ModCapability.LUMEN_CAPABILITY, null)).forEach(e -> {
                ILumen lumen = e.getCapability(ModCapability.LUMEN_CAPABILITY, null);
                lumen.set(wrapper.fill(lumen.get()));
                if (lumen.get() <= 0)
                    e.setDead();
            });
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPholarizer(arekkuusu.solar.common.block.BlockPholarizer) ILumen(arekkuusu.solar.api.entanglement.energy.data.ILumen) ModCapability(arekkuusu.solar.common.handler.data.ModCapability) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vector3(net.katsstuff.mirror.data.Vector3) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Polarization(arekkuusu.solar.common.block.BlockPholarizer.Polarization) EntityLumen(arekkuusu.solar.common.entity.EntityLumen) Quat(net.katsstuff.mirror.data.Quat) IBlockState(net.minecraft.block.state.IBlockState) BlockDirectional(net.minecraft.block.BlockDirectional) ITickable(net.minecraft.util.ITickable) TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) ILumen(arekkuusu.solar.api.entanglement.energy.data.ILumen) EnumFacing(net.minecraft.util.EnumFacing) EntityLumen(arekkuusu.solar.common.entity.EntityLumen) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

ILumen (arekkuusu.solar.api.entanglement.energy.data.ILumen)3 EntityLumen (arekkuusu.solar.common.entity.EntityLumen)2 Quat (net.katsstuff.mirror.data.Quat)2 Vector3 (net.katsstuff.mirror.data.Vector3)2 IBlockState (net.minecraft.block.state.IBlockState)2 TileEntity (net.minecraft.tileentity.TileEntity)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 IEntangledStack (arekkuusu.solar.api.entanglement.IEntangledStack)1 BlockPholarizer (arekkuusu.solar.common.block.BlockPholarizer)1 Polarization (arekkuusu.solar.common.block.BlockPholarizer.Polarization)1 TileNeutronBattery (arekkuusu.solar.common.block.tile.TileNeutronBattery)1 ModCapability (arekkuusu.solar.common.handler.data.ModCapability)1 BlockDirectional (net.minecraft.block.BlockDirectional)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ITickable (net.minecraft.util.ITickable)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1