Search in sources :

Example 26 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class TileBuffer method getSlotsForFace.

@Override
public int[] getSlotsForFace(Direction side) {
    int var1 = side.ordinal();
    Direction dir = getFacingDirection();
    if (side == dir) {
        int[] allSlots = new int[allInventories.size()];
        for (int i = 0; i < allSlots.length; i++) allSlots[i] = i;
        return allSlots;
    }
    if (var1 > dir.getOpposite().ordinal())
        var1--;
    int[] slots = new int[4];
    for (int i = 0; i < 4; i++) {
        slots[i] = var1 + i * 5;
    }
    return slots;
}
Also used : Direction(net.minecraft.util.Direction)

Example 27 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class TileIgniter method extinguish.

private void extinguish() {
    Direction facing = getBlockState().getValue(FACING);
    Block target = level.getBlockState(worldPosition.relative(facing)).getBlock();
    if (level.getBestNeighborSignal(worldPosition) == 0 && (target == Blocks.FIRE || target == Blocks.NETHER_PORTAL)) {
        level.setBlockAndUpdate(worldPosition.relative(facing), Blocks.AIR.defaultBlockState());
    }
}
Also used : Block(net.minecraft.block.Block) Direction(net.minecraft.util.Direction)

Example 28 with Direction

use of net.minecraft.util.Direction in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzer method calculateObserverPosition.

protected Vector3d calculateObserverPosition(double fov) {
    // calculate offset from the center of the looking glass based on fov
    double d = 0.75 * (0.5 / Math.tan(Math.PI * fov / 360));
    double dy = d * MathHelper.sin((float) Math.PI * 67.5F / 180);
    double dx = d * MathHelper.cos((float) Math.PI * 67.5F / 180);
    // fetch orientation, to determine the center of the looking glass
    BlockState state = this.getBlockState();
    Direction dir = BlockSeedAnalyzer.ORIENTATION.fetch(state);
    // apply observer position (center of looking glass + fov offset)
    return this.observerPosition = new Vector3d(this.getPos().getX() + 0.5 + (dx + 0.3125) * dir.getXOffset(), this.getPos().getY() + 0.6875 + dy, this.getPos().getZ() + 0.5 + (dx + 0.3125) * dir.getZOffset());
}
Also used : BlockState(net.minecraft.block.BlockState) Vector3d(net.minecraft.util.math.vector.Vector3d) Direction(net.minecraft.util.Direction)

Example 29 with Direction

use of net.minecraft.util.Direction in project AgriCraft by AgriCraft.

the class TileEntitySeedAnalyzer method getObserverOrientation.

@Override
public Vector2f getObserverOrientation() {
    if (this.observerOrientation == null) {
        BlockState state = this.getBlockState();
        Direction dir = BlockSeedAnalyzer.ORIENTATION.fetch(state);
        // The analyzer looking glass is tilted 22.5 degrees, therefore we have to pitch down 67.5 degrees
        this.observerOrientation = new Vector2f(67.5F, dir.getOpposite().getHorizontalAngle());
    }
    return this.observerOrientation;
}
Also used : BlockState(net.minecraft.block.BlockState) Vector2f(net.minecraft.util.math.vector.Vector2f) Direction(net.minecraft.util.Direction)

Example 30 with Direction

use of net.minecraft.util.Direction in project AgriCraft by AgriCraft.

the class BlockIrrigationChannelAbstract method getStateForPlacement.

@Nullable
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
    World world = context.getWorld();
    BlockPos pos = context.getPos();
    BlockState state = this.getDefaultState();
    for (Direction dir : Direction.values()) {
        Optional<InfProperty<Boolean>> prop = getConnection(dir);
        if (prop.isPresent()) {
            TileEntity tile = world.getTileEntity(pos.offset(dir));
            if (tile instanceof TileEntityIrrigationComponent) {
                TileEntityIrrigationComponent component = (TileEntityIrrigationComponent) tile;
                if (component.isSameMaterial(context.getItem())) {
                    state = prop.get().apply(state, true);
                }
            }
        }
    }
    return state;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlockState(net.minecraft.block.BlockState) InfProperty(com.infinityraider.infinitylib.block.property.InfProperty) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) IWorld(net.minecraft.world.IWorld) Direction(net.minecraft.util.Direction) Nullable(javax.annotation.Nullable)

Aggregations

Direction (net.minecraft.util.Direction)50 BlockState (net.minecraft.block.BlockState)18 TileEntity (net.minecraft.tileentity.TileEntity)17 BlockPos (net.minecraft.util.math.BlockPos)15 ItemStack (net.minecraft.item.ItemStack)12 Block (net.minecraft.block.Block)10 Nonnull (javax.annotation.Nonnull)8 Nullable (javax.annotation.Nullable)8 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 IPowerBase (com.bluepowermod.api.power.IPowerBase)5 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 World (net.minecraft.world.World)5 Capability (net.minecraftforge.common.capabilities.Capability)5 BlutricityStorage (com.bluepowermod.api.power.BlutricityStorage)4 CapabilityBlutricity (com.bluepowermod.api.power.CapabilityBlutricity)4 EnergyHelper (com.bluepowermod.helper.EnergyHelper)4 BPTileEntityType (com.bluepowermod.tile.BPTileEntityType)4 TileMachineBase (com.bluepowermod.tile.TileMachineBase)4 INBT (net.minecraft.nbt.INBT)4 LazyOptional (net.minecraftforge.common.util.LazyOptional)4