Search in sources :

Example 1 with EntityLumen

use of arekkuusu.solar.common.entity.EntityLumen 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)

Aggregations

ILumen (arekkuusu.solar.api.entanglement.energy.data.ILumen)1 EntityLumen (arekkuusu.solar.common.entity.EntityLumen)1 Quat (net.katsstuff.mirror.data.Quat)1 Vector3 (net.katsstuff.mirror.data.Vector3)1 IBlockState (net.minecraft.block.state.IBlockState)1 TileEntity (net.minecraft.tileentity.TileEntity)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1