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;
}
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());
}
}
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());
}
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;
}
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;
}
Aggregations