use of com.infinityraider.infinitylib.block.property.InfProperty 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